NewsController.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.hhsx.minigame.controller;
  2. import com.hhsx.minigame.entity.vo.NewsVO;
  3. import com.hhsx.minigame.service.NewsService;
  4. import com.hhsx.minigame.utils.HttpRespMsg;
  5. import io.swagger.annotations.ApiOperation;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.beans.factory.annotation.Value;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import java.io.IOException;
  12. import java.security.KeyManagementException;
  13. import java.security.NoSuchAlgorithmException;
  14. import java.security.NoSuchProviderException;
  15. /**
  16. * @author 吴涛涛
  17. * @since 2019-09-17
  18. */
  19. @Controller
  20. @RequestMapping("/news")
  21. public class NewsController {
  22. @Autowired
  23. NewsService newsService;
  24. @Value("${callbackURL}")
  25. private String callbackURL;
  26. /**
  27. * 添加分享信息
  28. *
  29. * 传递的参数:
  30. * type: 0 -微信 1 -微博
  31. * type=0时,所需其他参数: message:寄语 openid:用户openid
  32. *
  33. * type=1时,所需其他参数:message:寄语 uid:微博身份唯一凭证
  34. * @return
  35. */
  36. @ApiOperation(value = "添加分享信息", notes = "添加分享信息方法")
  37. @RequestMapping("/addNews")
  38. @ResponseBody
  39. public HttpRespMsg addUserNews(NewsVO newsVO){
  40. HttpRespMsg msg = newsService.addUserNews(newsVO);
  41. return msg;
  42. }
  43. /**
  44. * 微博授权登录
  45. *
  46. * 传递的参数:
  47. * type: 0 -微信 1 -微博
  48. * type=0时,所需其他参数: message:寄语 openid:用户openid
  49. *
  50. * type=1时,所需其他参数:message:寄语 uid:微博身份唯一凭证
  51. * @return
  52. */
  53. @ApiOperation(value = "微博授权登录", notes = "微博授权登录方法")
  54. @RequestMapping("/microblogLogin")
  55. @ResponseBody
  56. public HttpRespMsg microblogLogin(NewsVO newsVO) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
  57. HttpRespMsg msg = newsService.login(newsVO,callbackURL);
  58. return msg;
  59. }
  60. }