WxLotteryUserController.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.ruoyi.wx.web.controller;
  2. import com.ruoyi.common.core.domain.AjaxResult;
  3. import com.ruoyi.wx.web.domain.dto.LotteryDto;
  4. import com.ruoyi.wx.web.domain.vo.AwardVo;
  5. import com.ruoyi.wx.web.domain.vo.LotteryVo;
  6. import com.ruoyi.wx.web.service.IWxLotteryUserService;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import java.util.List;
  11. /**
  12. *
  13. * 微信抽奖中心
  14. */
  15. @Slf4j
  16. @RestController
  17. @RequestMapping("/wx/lottery")
  18. public class WxLotteryUserController {
  19. @Autowired
  20. private IWxLotteryUserService wxLotteryUserService;
  21. /**
  22. * 获取全量抽奖详情
  23. *
  24. * @param type 查询历史或者当前内容,now:查询当前抽奖,history:查询历史抽奖
  25. * @return 结果集
  26. */
  27. @GetMapping("/info/list")
  28. public AjaxResult getLotteryUserList(String type) {
  29. try {
  30. List<AwardVo> lotteryVo = wxLotteryUserService.getList(type);
  31. return AjaxResult.success(lotteryVo);
  32. } catch (SecurityException e) {
  33. return AjaxResult.error(e.getMessage());
  34. }
  35. }
  36. /**
  37. *
  38. * 获取当前人的抽奖内容
  39. * @return
  40. */
  41. @GetMapping("/info/list/{lotteryId}")
  42. public AjaxResult getIndex(@PathVariable("lotteryId") Long lotteryId) {
  43. try {
  44. List<LotteryVo> lotteryVo = wxLotteryUserService.getListById(lotteryId);
  45. return AjaxResult.success(lotteryVo);
  46. } catch (SecurityException e) {
  47. return AjaxResult.error(e.getMessage());
  48. }
  49. }
  50. /**
  51. * 当前人员进行抽奖
  52. *
  53. * @return
  54. */
  55. @PostMapping("/info/add")
  56. public AjaxResult addLottery(@RequestBody LotteryDto lotteryDto) {
  57. try {
  58. LotteryVo lotteryVo = wxLotteryUserService.addLottery(lotteryDto);
  59. return AjaxResult.success(lotteryVo);
  60. } catch (SecurityException e) {
  61. return AjaxResult.error(e.getMessage());
  62. }
  63. }
  64. }