|
@@ -0,0 +1,156 @@
|
|
|
|
+package com.wtkj.controller;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
+import com.wtkj.entity.Announcement;
|
|
|
|
+import com.wtkj.entity.AnnouncementSend;
|
|
|
|
+import com.wtkj.service.IAnnouncementSendService;
|
|
|
|
+import com.wtkj.service.IAnnouncementService;
|
|
|
|
+import com.wtkj.vo.AnnouncementSendVO;
|
|
|
|
+import com.wtkj.wrapper.AnnouncementSendWrapper;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author Blizzard
|
|
|
|
+ * @create at 2023-09-23 11:24
|
|
|
|
+ * @describe
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@RequestMapping("/announcement")
|
|
|
|
+@Api(value = "通知公告模块", tags = "通知公告模块")
|
|
|
|
+public class AnnouncementController {
|
|
|
|
+
|
|
|
|
+ private final IAnnouncementService announcementService;
|
|
|
|
+ private final IAnnouncementSendService announcementSendService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 详情
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/detail")
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
+ @ApiOperation(value = "详情", notes = "传入announcement")
|
|
|
|
+ public R<Announcement> detail(Announcement announcement) {
|
|
|
|
+ Announcement detail = announcementService.getOne(Condition.getQueryWrapper(announcement));
|
|
|
|
+ return R.data(detail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页 系统通告表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
+ @ApiOperation(value = "分页", notes = "传入announcement")
|
|
|
|
+ public R<IPage<Announcement>> list(Announcement announcement, Query query) {
|
|
|
|
+ IPage<Announcement> pages = announcementService.page(Condition.getPage(query), Condition.getQueryWrapper(announcement));
|
|
|
|
+ return R.data(pages);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增或修改 系统通告表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/submit")
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
+ @ApiOperation(value = "新增或修改", notes = "传入announcement")
|
|
|
|
+ public R submit(@Valid @RequestBody Announcement announcement) {
|
|
|
|
+ return R.status(announcementService.saveOrUpdate(announcement));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除 系统通告表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/remove")
|
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
|
+ return R.status(announcementService.deleteLogic(Func.toLongList(ids)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/send-detail")
|
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
|
+ @ApiOperation(value = "发送详情", notes = "传入announcementSend")
|
|
|
|
+ public R<AnnouncementSendVO> detail(AnnouncementSend announcementSend) {
|
|
|
|
+ AnnouncementSend detail = announcementSendService.getOne(Condition.getQueryWrapper(announcementSend));
|
|
|
|
+ return R.data(AnnouncementSendWrapper.build().entityVO(detail));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 自定义分页 获取用户消息列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/send-page")
|
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
|
+ @ApiOperation(value = "发送分页", notes = "")
|
|
|
|
+ public R<IPage<AnnouncementSendVO>> page(Query query) {
|
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
|
+ if (userId == -1L) {
|
|
|
|
+ return R.fail("获取用户信息失败!");
|
|
|
|
+ }
|
|
|
|
+ IPage<AnnouncementSend> pages = announcementSendService.selectAnnouncementSendPage(Condition.getPage(query), userId);
|
|
|
|
+ return R.data(AnnouncementSendWrapper.build().pageVO(pages));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取用户未读消息数量
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/send-notReadCount")
|
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
|
+ @ApiOperation(value = "获取用户未读消息数量", notes = "")
|
|
|
|
+ public R notReadCount() {
|
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
|
+ if (userId == -1L) {
|
|
|
|
+ return R.fail("获取用户信息失败!");
|
|
|
|
+ }
|
|
|
|
+ return R.data(announcementSendService.notReadCount(userId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户阅读状态修改
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/send-read")
|
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
|
+ @ApiOperation(value = "用户阅读状态修改", notes = "传入id")
|
|
|
|
+ public R read(@ApiParam(value = "主键ID", required = true) @RequestParam Long id) {
|
|
|
|
+ return R.status(announcementSendService.updateReadFlag(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户阅读状态修改
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/send-allRead")
|
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
|
+ @ApiOperation(value = "一键全部已读", notes = "")
|
|
|
|
+ public R allRead() {
|
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
|
+ if (userId == -1L) {
|
|
|
|
+ return R.fail("获取用户信息失败!");
|
|
|
|
+ }
|
|
|
|
+ return R.status(announcementSendService.allRead(userId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除 用户通告阅读标记表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/send-remove")
|
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
|
+ @ApiOperation(value = "发送逻辑删除", notes = "传入ids")
|
|
|
|
+ public R removeSend(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
|
+ return R.status(announcementSendService.deleteLogic(Func.toLongList(ids)));
|
|
|
|
+ }
|
|
|
|
+}
|