From 0d1bc87f6b3e0bd5e1c078054f54165640d8bf4a Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 28 Mar 2023 14:34:40 +0800 Subject: [PATCH] =?UTF-8?q?notify=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/staging/enums/MsgTypeEnum.java | 22 +++++--- .../pmapi/sys/controller/NotifyController.java | 66 +++++----------------- .../ningdatech/pmapi/sys/manage/NotifyManage.java | 41 ++++++++++++++ .../ningdatech/pmapi/sys/mapper/NotifyMapper.xml | 2 +- .../pmapi/sys/model/req/NotifyListReq.java | 34 +++++++++++ .../ningdatech/pmapi/sys/model/vo/NotifyVO.java | 53 +++++++++++++++++ .../pmapi/todocenter/manage/TodoCenterManage.java | 8 +-- 7 files changed, 162 insertions(+), 64 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java index a12c4c5..486e8c0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java @@ -17,15 +17,21 @@ import java.util.Objects; @NoArgsConstructor public enum MsgTypeEnum { /** - * 消息类型 + * 消息类型 项目评审 */ - AUDIT(1, "项目审核(待审核)"), - PASS(2, "项目审核(通过)"), - REJECTED(3,"项目审核(被驳回)"), - BACKED(4,"项目审核(被退回)"), - WARING(5,"预警提醒"), - EXPORT_REVIEW(6,"专家评审"), - REVIEW_MEETING(7,"评审会议"); + PROJECT_REVIEW, + /** + * 异常告警 + */ + WARING, + /** + * 专家评审 + */ + EXPERT_REVIEW, + /** + * 专家会议 + */ + REVIEW_MEETING; private Integer code; private String desc; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NotifyController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NotifyController.java index 65512cf..d9d7aca 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NotifyController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/NotifyController.java @@ -1,21 +1,14 @@ package com.ningdatech.pmapi.sys.controller; -import com.ningdatech.basic.model.IdVo; import com.ningdatech.basic.model.PageVo; -import com.ningdatech.log.annotation.WebLog; -import com.ningdatech.pmapi.sys.manage.NoticeManage; -import com.ningdatech.pmapi.sys.model.req.NoticeListReq; -import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; -import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; -import com.ningdatech.pmapi.sys.model.vo.NoticeDetailVO; -import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; +import com.ningdatech.pmapi.sys.manage.NotifyManage; +import com.ningdatech.pmapi.sys.model.req.NotifyListReq; +import com.ningdatech.pmapi.sys.model.vo.NotifyVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; - /** *

* 通知消息 前端控制器 @@ -30,53 +23,24 @@ import javax.validation.Valid; @RequestMapping("/api/v1/notify") public class NotifyController { - private final NoticeManage noticeManage; + private final NotifyManage notifyManage; - @PostMapping("/save") - @ApiOperation("新增公告") - @WebLog("新增公告") - public IdVo save(@Valid @RequestBody NoticeSaveReq req) { - return noticeManage.saveOrModify(req); + @GetMapping("/list") + @ApiOperation("通知列表") + public PageVo page(@ModelAttribute NotifyListReq notifyListReq){ + return notifyManage.page(notifyListReq); } @GetMapping("/detail/{id}") - @ApiOperation("公告详情") - public NoticeDetailVO save(@PathVariable Long id) { - return noticeManage.detail(id); - } - - @PostMapping("/enabled") - @ApiOperation("启用/禁用") - @WebLog("启用/禁用") - public Boolean save(@Valid @RequestBody NoticeStatusModifyReq req) { - return noticeManage.changeEnabled(req); - } - - @PostMapping("/topped") - @ApiOperation("置顶") - @WebLog("置顶") - public void topped(@RequestBody IdVo id) { - noticeManage.topped(id.getId()); - } - - @GetMapping("/dashboard/list") - @ApiOperation("工作台公告列表") - public PageVo dashboardList(@RequestParam(required = false, defaultValue = "3") Integer limit, - @RequestParam(required = false) Integer type) { - return noticeManage.dashboardList(limit, type); - } - - @GetMapping("/manage/list") - @ApiOperation("公告管理列表") - public PageVo listByManager(NoticeListReq req) { - return noticeManage.listByManager(req); + @ApiOperation("通知详情") + public NotifyVO save(@PathVariable Long id) { + return notifyManage.detail(id); } - @DeleteMapping("/del") - @ApiOperation("删除公告") - @WebLog("删除公告") - public void delNotice(@RequestBody IdVo req) { - noticeManage.delNotice(req.getId()); + @PostMapping("/read/{id}") + @ApiOperation("已读") + public Boolean read(@PathVariable Long id) { + return notifyManage.read(id); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java index 7d19f94..9125b26 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NotifyManage.java @@ -1,9 +1,22 @@ package com.ningdatech.pmapi.sys.manage; +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.sys.model.entity.Notify; +import com.ningdatech.pmapi.sys.model.req.NotifyListReq; +import com.ningdatech.pmapi.sys.model.vo.NotifyVO; import com.ningdatech.pmapi.sys.service.INotifyService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + /** *

* NotifyManage @@ -18,4 +31,32 @@ public class NotifyManage { private final INotifyService notifyService; + public PageVo page(NotifyListReq notifyListReq) { + Page page = notifyListReq.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Notify.class) + .eq(Objects.nonNull(notifyListReq.getReaded()), Notify::getReaded, notifyListReq.getReaded()) + .eq(Objects.nonNull(notifyListReq.getUserId()), Notify::getUserId, notifyListReq.getUserId()) + .like(Objects.nonNull(notifyListReq.getTitle()), Notify::getTitle, notifyListReq.getTitle()) + .eq(Objects.nonNull(notifyListReq.getType()), Notify::getType, notifyListReq.getType()); + notifyService.page(page,wrapper); + if(page.getTotal() == 0L){ + return PageVo.empty(); + } + List list = page.getRecords().stream() + .map(n -> BeanUtil.copyProperties(n,NotifyVO.class)) + .collect(Collectors.toList()); + return PageVo.of(list,page.getTotal()); + } + + public NotifyVO detail(Long id) { + Notify one = notifyService.getById(id); + return BeanUtil.copyProperties(one,NotifyVO.class); + } + + public Boolean read(Long id) { + Notify one = notifyService.getById(id); + VUtils.isTrue(Objects.isNull(one)).throwMessage("该通知不存在"); + one.setReaded(Boolean.TRUE); + return notifyService.updateById(one); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/NotifyMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/NotifyMapper.xml index c9c9cd9..8fa823e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/NotifyMapper.xml +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/NotifyMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java new file mode 100644 index 0000000..c08e22b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/NotifyListReq.java @@ -0,0 +1,34 @@ +package com.ningdatech.pmapi.sys.model.req; + +import com.ningdatech.basic.model.PagePo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * NoticeListReq + *

+ * + * @author zpf + * @since 00:32 2023/3/23 + */ +@Data +@ApiModel("通知查询参数类") +@EqualsAndHashCode(callSuper = true) +public class NotifyListReq extends PagePo { + + @ApiModelProperty("用户ID") + private Integer userId; + + @ApiModelProperty("是否已读") + private Boolean readed; + + @ApiModelProperty("公告标题") + private String title; + + @ApiModelProperty("类型") + private String type; + +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java new file mode 100644 index 0000000..7197588 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NotifyVO.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.sys.model.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 通知 + *

+ * + * @author zpf + * @since 2023-03-21 + */ +@Data +@ApiModel(value = "消息通知VO", description = "消息通知") +public class NotifyVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("ID") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("消息类型") + private String type; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("实例id") + private String instanceId; + + @ApiModelProperty("是否已读") + private Boolean readed; + + @ApiModelProperty("用户ID") + private Long userId; + + @ApiModelProperty("link") + private String link; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index f8822d8..152ed7d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -371,7 +371,7 @@ public class TodoCenterManage { String passMsg2 = String.format(PASS_MSG_TEMPLATE2, projectName, processDefinitionName); passWorkNoticeInfo2.setMsg(passMsg2); // 放入工作通知暂存表中,通过扫表异步发送 - workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PASS); + workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PROJECT_REVIEW); } else { // 若有下一个审核人(当前节点的用户), // 向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。 @@ -383,7 +383,7 @@ public class TodoCenterManage { String msg = String.format(PASS_MSG_TEMPLATE, sendWorkNoticeInfo.getOrganizationName(), projectName); sendWorkNoticeInfo.setMsg(msg); // 放入工作通知暂存表中,通过扫表异步发送 - workNoticeStagingService.addByWorkNotice(sendWorkNoticeInfo, MsgTypeEnum.AUDIT); + workNoticeStagingService.addByWorkNotice(sendWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); } break; // 驳回 @@ -398,7 +398,7 @@ public class TodoCenterManage { String rejectMsg = String.format(REJECT_MSG_TEMPLATE, projectName, processDefinitionName); rejectWorkNoticeInfo.setMsg(rejectMsg); // 放入工作通知暂存表中,通过扫表异步发送 - workNoticeStagingService.addByWorkNotice(rejectWorkNoticeInfo, MsgTypeEnum.REJECTED); + workNoticeStagingService.addByWorkNotice(rejectWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); break; // 退回 case BACK: @@ -410,7 +410,7 @@ public class TodoCenterManage { String backMsg = String.format(BACK_MSG_TEMPLATE, projectName, processDefinitionName); backWorkNoticeInfo.setMsg(backMsg); // 放入工作通知暂存表中,通过扫表异步发送 - workNoticeStagingService.addByWorkNotice(backWorkNoticeInfo, MsgTypeEnum.BACKED); + workNoticeStagingService.addByWorkNotice(backWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); break; // 撤回(流程发起人和当前流程审核人的前一个审核人操作) case WITHDRAW: