diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppNewsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppNewsController.java index e30ee4f1..501f9830 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppNewsController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppNewsController.java @@ -314,5 +314,4 @@ public class AppNewsController extends BaseController { IPage news = inspectionNewsService.msgList(page,partnerId); return success(news); } - } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/WarnMessageController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/WarnMessageController.java index 5dd5a138..f27f17c6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/WarnMessageController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/WarnMessageController.java @@ -5,16 +5,12 @@ import javax.servlet.http.HttpServletResponse; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.util.ExcelUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import cn.iocoder.yudao.module.core.controller.BaseController; import cn.iocoder.yudao.module.inspection.entity.WarnMessage; import cn.iocoder.yudao.module.inspection.service.IWarnMessageService; @@ -27,8 +23,7 @@ import cn.iocoder.yudao.module.inspection.service.IWarnMessageService; */ @RestController @RequestMapping("/admin-api/warnMsg/warnMsg") -public class WarnMessageController extends BaseController -{ +public class WarnMessageController extends BaseController { @Autowired private IWarnMessageService warnMessageService; @@ -42,11 +37,12 @@ public class WarnMessageController extends BaseController } @GetMapping("/pageList") - public CommonResult pageList(WarnMessage warnMessage,Integer pageNo,Integer pageSize) throws Exception { - Page page =new Page(pageNo,pageSize); - IPage list = warnMessageService.pageList(page,warnMessage); + public CommonResult pageList(WarnMessage warnMessage, Integer pageNo, Integer pageSize) throws Exception { + Page page = new Page(pageNo, pageSize); + IPage list = warnMessageService.pageList(page, warnMessage); return success(list); } + @PostMapping("/export") public void export(HttpServletResponse response, WarnMessage warnMessage) throws Exception { List list = warnMessageService.selectWarnMessageList(warnMessage); @@ -58,29 +54,56 @@ public class WarnMessageController extends BaseController * 获取warnMsg详细信息 */ @GetMapping(value = "/{id}") - public CommonResult getInfo(@PathVariable("id") Long id) - { + public CommonResult getInfo(@PathVariable("id") Long id) { + WarnMessage warnMessage = new WarnMessage(); + warnMessage.setId(id); + warnMessage.setIsRead("1"); + warnMessageService.updateById(warnMessage); return success(warnMessageService.selectWarnMessageById(id)); } @PostMapping("/add") - public CommonResult add(@RequestBody WarnMessage warnMessage) - { + public CommonResult add(@RequestBody WarnMessage warnMessage) { return toAjax(warnMessageService.insertWarnMessage(warnMessage)); } @PostMapping("/edit") - public CommonResult edit(@RequestBody WarnMessage warnMessage) - { + public CommonResult edit(@RequestBody WarnMessage warnMessage) { return toAjax(warnMessageService.updateWarnMessage(warnMessage)); } - @DeleteMapping("/{ids}") - public CommonResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public CommonResult remove(@PathVariable Long[] ids) { return toAjax(warnMessageService.deleteWarnMessageByIds(ids)); } + + /** + * 获取未读的提醒数量 + * + * @author 小李 + * @date 14:33 2024/12/16 + **/ + @GetMapping("/getCount") + public CommonResult getCount() { + long count = warnMessageService.count(new LambdaQueryWrapper().eq(WarnMessage::getIsRead, "0")); + return success(count); + } + + /** + * 已读全部 + * + * @author 小李 + * @date 15:57 2024/12/16 + **/ + @GetMapping("/readAll") + public CommonResult readAll() { + warnMessageService.update(new LambdaUpdateWrapper() + .set(WarnMessage::getIsRead, "1") + .eq(WarnMessage::getIsRead, "0") + ); + return CommonResult.ok(); + } } diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/WarnMessageMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/WarnMessageMapper.xml index eb070d4e..a0f4914e 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/WarnMessageMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/WarnMessageMapper.xml @@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"