|
|
@@ -0,0 +1,211 @@
|
|
|
+package com.ruoyi.web.controller;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.web.domain.GrzdVO;
|
|
|
+import com.ruoyi.web.domain.HdUser;
|
|
|
+import com.ruoyi.web.domain.HisZd;
|
|
|
+import com.ruoyi.web.service.IHdUserService;
|
|
|
+import com.ruoyi.web.service.IHisZdService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
+import com.ruoyi.web.domain.HdInfo;
|
|
|
+import com.ruoyi.web.service.IHdInfoService;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 活动信息Controller
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2025-08-25
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/hd/info")
|
|
|
+@Validated
|
|
|
+public class HdInfoController extends BaseController
|
|
|
+{
|
|
|
+ private IHdInfoService hdInfoService;
|
|
|
+ @Autowired
|
|
|
+ public void setHdInfoService(IHdInfoService hdInfoService) {
|
|
|
+ this.hdInfoService = hdInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IHdUserService hdUserService;
|
|
|
+ @Autowired
|
|
|
+ public void setHdUserService(IHdUserService hdUserService) {
|
|
|
+ this.hdUserService = hdUserService;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IHisZdService hisZdService;
|
|
|
+ @Autowired
|
|
|
+ public void setHisZdService(IHisZdService hisZdService) {
|
|
|
+ this.hisZdService = hisZdService;
|
|
|
+ }
|
|
|
+
|
|
|
+ private HdInfo getHdInfo(Date date){
|
|
|
+ QueryWrapper<HdInfo> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(HdInfo::getHdrq,date);
|
|
|
+ return hdInfoService.getOne(qw);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/user/verify")
|
|
|
+ @ApiOperation("校验是否签到")
|
|
|
+ public AjaxResult verify(String date) {
|
|
|
+ Date hdrq = DateUtils.getNowDate();
|
|
|
+ if(StringUtils.isNotEmpty(date)) hdrq = DateUtils.parseDate(date);
|
|
|
+ HdInfo hdInfo = getHdInfo(hdrq);
|
|
|
+ if (Objects.isNull(hdInfo)) return success(false);
|
|
|
+ QueryWrapper<HdUser> huQW = new QueryWrapper<>();
|
|
|
+ huQW.lambda().eq(HdUser::getFid,hdInfo.getId()).eq(HdUser::getUserId,SecurityUtils.getUserId());
|
|
|
+ return success(!Objects.isNull(hdUserService.getOne(huQW)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/user/qd")
|
|
|
+ @ApiOperation("签到")
|
|
|
+ public AjaxResult userQd(String date){
|
|
|
+ Date hdrq = DateUtils.getNowDate();
|
|
|
+ if(StringUtils.isNotEmpty(date)) hdrq = DateUtils.parseDate(date);
|
|
|
+ HdInfo hdInfo = getHdInfo(hdrq);
|
|
|
+ if (Objects.isNull(hdInfo)) {
|
|
|
+ hdInfo = new HdInfo();
|
|
|
+ hdInfo.setHdrq(hdrq);
|
|
|
+ hdInfoService.save(hdInfo);
|
|
|
+ }
|
|
|
+ Long id = hdInfo.getId();
|
|
|
+ HdUser hdUser = new HdUser();
|
|
|
+ hdUser.setFid(id);
|
|
|
+ hdUser.setUserId(SecurityUtils.getUserId());
|
|
|
+ hdUserService.save(hdUser);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/user/qd/cancel")
|
|
|
+ @ApiOperation("取消签到")
|
|
|
+ public AjaxResult userQdCancel(String date){
|
|
|
+ Date hdrq = DateUtils.getNowDate();
|
|
|
+ if(StringUtils.isNotEmpty(date)) hdrq = DateUtils.parseDate(date);
|
|
|
+ HdInfo hdInfo = getHdInfo(hdrq);
|
|
|
+ HdUser hdUser = new HdUser();
|
|
|
+ hdUser.setFid(hdInfo.getId());
|
|
|
+ hdUser.setUserId(SecurityUtils.getUserId());
|
|
|
+ QueryWrapper<HdUser> qw = new QueryWrapper<>();
|
|
|
+ qw.setEntity(hdUser);
|
|
|
+ hdUserService.remove(qw);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/user/his")
|
|
|
+ @ApiOperation("历史记录")
|
|
|
+ public TableDataInfo userHis(){
|
|
|
+ QueryWrapper<HdUser> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(HdUser::getUserId,SecurityUtils.getUserId());
|
|
|
+ List<Long> idList = hdUserService.list(qw).stream().map(HdUser::getFid).collect(Collectors.toList());
|
|
|
+ if (idList.isEmpty()) return getDataTable(new ArrayList<>());
|
|
|
+ startPage();
|
|
|
+ return getDataTable(hdInfoService.listByIds(idList));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/user/grzd")
|
|
|
+ @ApiOperation("个人账单")
|
|
|
+ public TableDataInfo grzd(String ny){
|
|
|
+ startPage();
|
|
|
+ return getDataTable(hdInfoService.grzd(ny));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/user/grzd/{ny}")
|
|
|
+ @ApiOperation("个人账单详情")
|
|
|
+ public AjaxResult grzdDetail(@PathVariable String ny){
|
|
|
+ List<GrzdVO> voList = hdInfoService.grzd(ny);
|
|
|
+ return success(voList.get(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/user/grzd/zf")
|
|
|
+ @ApiOperation("个人账单支付")
|
|
|
+ public AjaxResult grzdZf(@RequestBody HisZd hisZd){
|
|
|
+ hisZd.setUserId(SecurityUtils.getUserId());
|
|
|
+ hisZdService.save(hisZd);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询活动信息列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(HdInfo hdInfo)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ QueryWrapper<HdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.setEntity(hdInfo);
|
|
|
+ List<HdInfo> hdInfoList = hdInfoService.list(queryWrapper);
|
|
|
+ return getDataTable(hdInfoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出活动信息列表
|
|
|
+ */
|
|
|
+ @Log(title = "活动信息", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, HdInfo hdInfo)
|
|
|
+ {
|
|
|
+ QueryWrapper<HdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.setEntity(hdInfo);
|
|
|
+ List<HdInfo> list = hdInfoService.list(queryWrapper);
|
|
|
+ ExcelUtil<HdInfo> util = new ExcelUtil<>(HdInfo.class);
|
|
|
+ util.exportExcel(response, list, "活动信息数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取活动信息详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ return success(hdInfoService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增活动信息
|
|
|
+ */
|
|
|
+ @Log(title = "活动信息", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody HdInfo hdInfo)
|
|
|
+ {
|
|
|
+ hdInfoService.save(hdInfo);
|
|
|
+ return success(hdInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改活动信息
|
|
|
+ */
|
|
|
+ @Log(title = "活动信息", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody HdInfo hdInfo)
|
|
|
+ {
|
|
|
+ hdInfoService.updateById(hdInfo);
|
|
|
+ return success(hdInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除活动信息
|
|
|
+ */
|
|
|
+ @Log(title = "活动信息", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
+ {
|
|
|
+ return toAjax(hdInfoService.removeByIds(Arrays.asList(ids)));
|
|
|
+ }
|
|
|
+}
|