package com.ruoyi.wx.web.controller; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.framework.recovery.domain.dto.UserCouponsDto; import com.ruoyi.framework.recovery.domain.vo.CreditVo; import com.ruoyi.framework.recovery.domain.vo.UserCouponsVo; import com.ruoyi.wx.web.domain.dto.CreditDto; import com.ruoyi.wx.web.service.IWxPersonCenterService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * * 微信个人中心 */ @Slf4j @RestController @RequestMapping("/wx/person") public class WxPersonCenterController { @Autowired private IWxPersonCenterService wxPersonCenterService; /** * * 个人中心首页用户内容 * @return */ @GetMapping("/info") public AjaxResult getIndex() { try { return wxPersonCenterService.getIndex(); } catch (SecurityException e) { return AjaxResult.error(e.getMessage()); } } /** * 新增积分 */ @PostMapping("/add/credit") public AjaxResult addCredit(@RequestBody CreditDto creditDto) { try { boolean add = wxPersonCenterService.addCredit(creditDto); if (add) { return AjaxResult.success(); } return AjaxResult.error(); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } /** * 新增积分 */ @GetMapping("/get/credit") public AjaxResult getCredit() { try { List creditVos = wxPersonCenterService.getCredit(); return AjaxResult.success(creditVos); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } /** * 查询用户领取的优惠卷 */ @GetMapping("/coupons/list") public AjaxResult getCoupons() { try { List add = wxPersonCenterService.getCoupons(); return AjaxResult.success(add); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } /** * 用户领取优惠卷 */ @PostMapping("/receive/coupons") public AjaxResult receive(@RequestBody UserCouponsDto dto) { try { boolean add = wxPersonCenterService.receiveCoupons(dto); if (add) { return AjaxResult.success(); } return AjaxResult.error(); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } }