WxHomeController.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.ruoyi.wx.web.controller;
  2. import com.ruoyi.common.core.domain.AjaxResult;
  3. import com.ruoyi.common.utils.ExceptionUtil;
  4. import com.ruoyi.framework.recovery.domain.RecContent;
  5. import com.ruoyi.framework.recovery.domain.RecContentUser;
  6. import com.ruoyi.wx.web.domain.vo.SaleInfoVo;
  7. import com.ruoyi.wx.web.service.IWxHomeService;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. import java.util.List;
  12. import java.util.concurrent.ExecutionException;
  13. /**
  14. * 首页服务
  15. */
  16. @RestController
  17. @RequestMapping("/wx/home")
  18. @Slf4j
  19. public class WxHomeController {
  20. @Autowired
  21. private IWxHomeService wxHomeService;
  22. // @ApiOperation(value = "查询首页所有信息")
  23. @GetMapping("/index")
  24. public AjaxResult getIndex() {
  25. try {
  26. return wxHomeService.getIndex();
  27. } catch (InterruptedException | ExecutionException e) {
  28. return AjaxResult.error(e.getMessage(), e);
  29. }
  30. }
  31. // @ApiOperation(value = "发售信息详情", notes = "根据id查询详情内容")
  32. @GetMapping("/sale/info/{id}")
  33. public AjaxResult getSaleInfo(@PathVariable("id") Long id) {
  34. try {
  35. List<SaleInfoVo> infoList = wxHomeService.getSaleInfo(id);
  36. return AjaxResult.success(infoList);
  37. } catch (Exception e) {
  38. return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
  39. }
  40. }
  41. /**
  42. * 销售日历
  43. *
  44. */
  45. @GetMapping("/sale/calendar")
  46. public AjaxResult saleCalendar() {
  47. try {
  48. List<SaleInfoVo> infoList = wxHomeService.getSaleCalendar();
  49. return AjaxResult.success(infoList);
  50. } catch (Exception e) {
  51. return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
  52. }
  53. }
  54. /**
  55. * 点赞
  56. *
  57. * @param id 评论Id
  58. * @return 结果集
  59. */
  60. @GetMapping("/thumbs/{id}")
  61. public AjaxResult thumbs(@PathVariable("id") Long id) {
  62. try {
  63. Long thumbs = wxHomeService.thumbs(id);
  64. return AjaxResult.success(thumbs);
  65. } catch (Exception e) {
  66. return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
  67. }
  68. }
  69. /**
  70. * 当前用户点过的赞
  71. *
  72. */
  73. @GetMapping("/thumbs")
  74. public AjaxResult userThumbs() {
  75. try {
  76. List<RecContentUser> thumbs = wxHomeService.userThumbs();
  77. return AjaxResult.success(thumbs);
  78. } catch (Exception e) {
  79. return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
  80. }
  81. }
  82. @PostMapping("/add/content")
  83. public AjaxResult thumbs(@RequestBody RecContent recContent) {
  84. try {
  85. int thumbs = wxHomeService.addRecContent(recContent);
  86. return AjaxResult.success(thumbs);
  87. } catch (Exception e) {
  88. return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
  89. }
  90. }
  91. }