package com.ruoyi.wx.web.controller; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.wx.web.domain.dto.LotteryDto; import com.ruoyi.wx.web.domain.vo.AwardVo; import com.ruoyi.wx.web.domain.vo.LotteryVo; import com.ruoyi.wx.web.service.IWxLotteryUserService; 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/lottery") public class WxLotteryUserController { @Autowired private IWxLotteryUserService wxLotteryUserService; /** * 获取全量抽奖详情 * * @param type 查询历史或者当前内容,now:查询当前抽奖,history:查询历史抽奖 * @return 结果集 */ @GetMapping("/info/list") public AjaxResult getLotteryUserList(String type) { try { List lotteryVo = wxLotteryUserService.getList(type); return AjaxResult.success(lotteryVo); } catch (SecurityException e) { return AjaxResult.error(e.getMessage()); } } /** * * 获取当前人的抽奖内容 * @return */ @GetMapping("/info/list/{lotteryId}") public AjaxResult getIndex(@PathVariable("lotteryId") Long lotteryId) { try { List lotteryVo = wxLotteryUserService.getListById(lotteryId); return AjaxResult.success(lotteryVo); } catch (SecurityException e) { return AjaxResult.error(e.getMessage()); } } /** * 当前人员进行抽奖 * * @return */ @PostMapping("/info/add") public AjaxResult addLottery(@RequestBody LotteryDto lotteryDto) { try { LotteryVo lotteryVo = wxLotteryUserService.addLottery(lotteryDto); return AjaxResult.success(lotteryVo); } catch (SecurityException e) { return AjaxResult.error(e.getMessage()); } } }