WxPersonCenterController.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package com.ruoyi.wx.web.controller;
  2. import com.ruoyi.common.core.domain.AjaxResult;
  3. import com.ruoyi.framework.recovery.domain.dto.UserCouponsDto;
  4. import com.ruoyi.framework.recovery.domain.vo.CreditVo;
  5. import com.ruoyi.framework.recovery.domain.vo.UserCouponsVo;
  6. import com.ruoyi.wx.web.domain.dto.CreditDto;
  7. import com.ruoyi.wx.web.service.IWxPersonCenterService;
  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. /**
  13. *
  14. * 微信个人中心
  15. */
  16. @Slf4j
  17. @RestController
  18. @RequestMapping("/wx/person")
  19. public class WxPersonCenterController {
  20. @Autowired
  21. private IWxPersonCenterService wxPersonCenterService;
  22. /**
  23. *
  24. * 个人中心首页用户内容
  25. * @return
  26. */
  27. @GetMapping("/info")
  28. public AjaxResult getIndex() {
  29. try {
  30. return wxPersonCenterService.getIndex();
  31. } catch (SecurityException e) {
  32. return AjaxResult.error(e.getMessage());
  33. }
  34. }
  35. /**
  36. * 新增积分
  37. */
  38. @PostMapping("/add/credit")
  39. public AjaxResult addCredit(@RequestBody CreditDto creditDto) {
  40. try {
  41. boolean add = wxPersonCenterService.addCredit(creditDto);
  42. if (add) {
  43. return AjaxResult.success();
  44. }
  45. return AjaxResult.error();
  46. } catch (Exception e) {
  47. return AjaxResult.error(e.getMessage());
  48. }
  49. }
  50. /**
  51. * 新增积分
  52. */
  53. @GetMapping("/get/credit")
  54. public AjaxResult getCredit() {
  55. try {
  56. List<CreditVo> creditVos = wxPersonCenterService.getCredit();
  57. return AjaxResult.success(creditVos);
  58. } catch (Exception e) {
  59. return AjaxResult.error(e.getMessage());
  60. }
  61. }
  62. /**
  63. * 查询用户领取的优惠卷
  64. */
  65. @GetMapping("/coupons/list")
  66. public AjaxResult getCoupons() {
  67. try {
  68. List<UserCouponsVo> add = wxPersonCenterService.getCoupons();
  69. return AjaxResult.success(add);
  70. } catch (Exception e) {
  71. return AjaxResult.error(e.getMessage());
  72. }
  73. }
  74. /**
  75. * 用户领取优惠卷
  76. */
  77. @PostMapping("/receive/coupons")
  78. public AjaxResult receive(@RequestBody UserCouponsDto dto) {
  79. try {
  80. boolean add = wxPersonCenterService.receiveCoupons(dto);
  81. if (add) {
  82. return AjaxResult.success();
  83. }
  84. return AjaxResult.error();
  85. } catch (Exception e) {
  86. return AjaxResult.error(e.getMessage());
  87. }
  88. }
  89. }