Commit e8dd66c6f848963e4b4329e14ecac3c80a18d844

Authored by YunaiV
1 parent 131adad9

review 部分站内信的实现

yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
... ... @@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5   -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
6 5 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
7 6 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
8   -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
9 7 import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
10 8 import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
11 9 import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
... ... @@ -30,30 +28,6 @@ public class NotifyMessageController {
30 28 @Resource
31 29 private NotifyMessageService notifyMessageService;
32 30  
33   - @PostMapping("/create")
34   - @ApiOperation("创建站内信")
35   - @PreAuthorize("@ss.hasPermission('system:notify-message:create')")
36   - public CommonResult<Long> createNotifyMessage(@Valid @RequestBody NotifyMessageCreateReqVO createReqVO) {
37   - return success(notifyMessageService.createNotifyMessage(createReqVO));
38   - }
39   -
40   - @PutMapping("/update")
41   - @ApiOperation("更新站内信")
42   - @PreAuthorize("@ss.hasPermission('system:notify-message:update')")
43   - public CommonResult<Boolean> updateNotifyMessage(@Valid @RequestBody NotifyMessageUpdateReqVO updateReqVO) {
44   - notifyMessageService.updateNotifyMessage(updateReqVO);
45   - return success(true);
46   - }
47   -
48   - @DeleteMapping("/delete")
49   - @ApiOperation("删除站内信")
50   - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
51   - @PreAuthorize("@ss.hasPermission('system:notify-message:delete')")
52   - public CommonResult<Boolean> deleteNotifyMessage(@RequestParam("id") Long id) {
53   - notifyMessageService.deleteNotifyMessage(id);
54   - return success(true);
55   - }
56   -
57 31 @GetMapping("/get")
58 32 @ApiOperation("获得站内信")
59 33 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
... ... @@ -70,4 +44,5 @@ public class NotifyMessageController {
70 44 PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
71 45 return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
72 46 }
  47 +
73 48 }
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
... ... @@ -19,12 +19,12 @@ import javax.annotation.Resource;
19 19 import javax.servlet.http.HttpServletResponse;
20 20 import javax.validation.Valid;
21 21 import java.io.IOException;
22   -import java.util.Collection;
23 22 import java.util.List;
24 23  
25 24 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
26 25 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
27 26  
  27 +// TODO 芋艿:VO 类上的 swagger 注解完善下,例如说 swagger,枚举等等
28 28 @Api(tags = "管理后台 - 站内信模版")
29 29 @RestController
30 30 @RequestMapping("/system/notify-template")
... ... @@ -67,15 +67,6 @@ public class NotifyTemplateController {
67 67 return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
68 68 }
69 69  
70   - @GetMapping("/list")
71   - @ApiOperation("获得站内信模版列表")
72   - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
73   - @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
74   - public CommonResult<List<NotifyTemplateRespVO>> getNotifyTemplateList(@RequestParam("ids") Collection<Long> ids) {
75   - List<NotifyTemplateDO> list = notifyTemplateService.getNotifyTemplateList(ids);
76   - return success(NotifyTemplateConvert.INSTANCE.convertList(list));
77   - }
78   -
79 70 @GetMapping("/page")
80 71 @ApiOperation("获得站内信模版分页")
81 72 @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
... ... @@ -96,4 +87,8 @@ public class NotifyTemplateController {
96 87 ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
97 88 }
98 89  
  90 + // TODO @芋艿:参考 SmsTemplateController 的 sendNotify 写一个发送站内信的接口
  91 +
  92 + // TODO @芋艿:参考 SmsSendServiceImpl,新建一个 NotifySendServiceImpl,用于提供出来给发送消息。注意,不要考虑异步发送,直接 insert 就可以了。也不用考虑发送后的回调
  93 +
99 94 }
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
... ... @@ -38,7 +38,7 @@ public class UserNotifyMessageController {
38 38 @Resource
39 39 private NotifyMessageService notifyMessageService;
40 40  
41   -
  41 + // TODO 芋艿:和 NotifyMessageController 的 page 合并
42 42 @GetMapping("/page")
43 43 @ApiOperation("获得站内信分页")
44 44 public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
... ... @@ -48,6 +48,7 @@ public class UserNotifyMessageController {
48 48 return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
49 49 }
50 50  
  51 + // TODO @芋艿:url 改成 get-recent-list;方法名也改下。默认传入 size = 10;
51 52 @GetMapping("/latest/list")
52 53 @ApiOperation("获得最新10站内信列表")
53 54 public CommonResult<List<NotifyMessageRespVO>> getNotifyLatestMessageList() {
... ... @@ -56,6 +57,7 @@ public class UserNotifyMessageController {
56 57 reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
57 58 reqVO.setPageNo(1);
58 59 reqVO.setPageSize(10);
  60 + // TODO 芋艿:不要用分页写;
59 61 PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
60 62 if (CollUtil.isNotEmpty(pageResult.getList())) {
61 63 return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList()));
... ... @@ -63,12 +65,14 @@ public class UserNotifyMessageController {
63 65 return success(Collections.emptyList());
64 66 }
65 67  
  68 + // TODO @芋艿:get-unread-count
66 69 @GetMapping("/unread/count")
67 70 @ApiOperation("获得未读站内信数量")
68 71 public CommonResult<Long> getUnreadNotifyMessageCount() {
69 72 return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
70 73 }
71 74  
  75 + // TODO @芋艿:把 get 站内信,和更新站内信已经读分开。其中更新单条和多条,使用一个接口就好列
72 76 @GetMapping("/read")
73 77 @ApiOperation("获得站内信")
74 78 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
... ... @@ -79,6 +83,7 @@ public class UserNotifyMessageController {
79 83 return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
80 84 }
81 85  
  86 + // TODO @芋艿:PutMapping;update-list-read
82 87 @GetMapping("/read/list")
83 88 @ApiOperation("批量标记已读")
84 89 @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
... ... @@ -87,6 +92,7 @@ public class UserNotifyMessageController {
87 92 return success(Boolean.TRUE);
88 93 }
89 94  
  95 + // TODO @芋艿:PutMapping:update-all-read
90 96 @GetMapping("/read/all")
91 97 @ApiOperation("所有未读消息标记已读")
92 98 public CommonResult<Boolean> batchUpdateAllNotifyMessageReadStatus() {
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java deleted
1   -package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
2   -
3   -import lombok.*;
4   -import io.swagger.annotations.*;
5   -
6   -@ApiModel("管理后台 - 站内信创建 Request VO")
7   -@Data
8   -@EqualsAndHashCode(callSuper = true)
9   -@ToString(callSuper = true)
10   -public class NotifyMessageCreateReqVO extends NotifyMessageBaseVO {
11   -
12   - @ApiModelProperty(value = "站内信模版编号")
13   - private Long templateId;
14   -
15   -}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
1 1 package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
2 2  
3   -import lombok.*;
4   -import java.util.*;
5   -import io.swagger.annotations.*;
6 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
7 9 import org.springframework.format.annotation.DateTimeFormat;
8 10  
  11 +import java.util.Date;
  12 +
9 13 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10 14  
11 15 @ApiModel("管理后台 - 站内信分页 Request VO")
... ... @@ -18,12 +22,13 @@ public class NotifyMessagePageReqVO extends PageParam {
18 22 private String title;
19 23  
20 24 @ApiModelProperty(value = "是否已读 0-未读 1-已读")
21   - private Integer readStatus;
  25 + private Boolean readStatus;
22 26  
23 27 @ApiModelProperty(value = "创建时间")
24 28 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
25 29 private Date[] createTime;
26 30  
  31 + // TODO 芋艿:去掉 userId 和 userType,不要在 VO 里
27 32  
28 33 @ApiModelProperty(value = "用户编号", hidden = true)
29 34 private Long userId;
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java deleted
1   -package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
2   -
3   -import lombok.*;
4   -import io.swagger.annotations.*;
5   -import javax.validation.constraints.*;
6   -
7   -@ApiModel("管理后台 - 站内信更新 Request VO")
8   -@Data
9   -@EqualsAndHashCode(callSuper = true)
10   -@ToString(callSuper = true)
11   -public class NotifyMessageUpdateReqVO extends NotifyMessageBaseVO {
12   -
13   - @ApiModelProperty(value = "ID", required = true)
14   - @NotNull(message = "ID不能为空")
15   - private Long id;
16   -
17   - @ApiModelProperty(value = "站内信模版编号")
18   - private Long templateId;
19   -
20   -}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
1 1 package cn.iocoder.yudao.module.system.service.notify;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
5 4 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
6   -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
7 5 import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
8 6  
9   -import javax.validation.Valid;
10 7 import java.util.Collection;
11 8 import java.util.List;
12 9  
... ... @@ -18,28 +15,6 @@ import java.util.List;
18 15 public interface NotifyMessageService {
19 16  
20 17 /**
21   - * 创建站内信
22   - *
23   - * @param createReqVO 创建信息
24   - * @return 编号
25   - */
26   - Long createNotifyMessage(@Valid NotifyMessageCreateReqVO createReqVO);
27   -
28   - /**
29   - * 更新站内信
30   - *
31   - * @param updateReqVO 更新信息
32   - */
33   - void updateNotifyMessage(@Valid NotifyMessageUpdateReqVO updateReqVO);
34   -
35   - /**
36   - * 删除站内信
37   - *
38   - * @param id 编号
39   - */
40   - void deleteNotifyMessage(Long id);
41   -
42   - /**
43 18 * 获得站内信
44 19 *
45 20 * @param id 编号
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
... ... @@ -71,32 +71,6 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
71 71 }).collect(Collectors.toList());
72 72 }
73 73  
74   - @Override
75   - public Long createNotifyMessage(NotifyMessageCreateReqVO createReqVO) {
76   - // 插入
77   - NotifyMessageDO notifyMessage = NotifyMessageConvert.INSTANCE.convert(createReqVO);
78   - notifyMessageMapper.insert(notifyMessage);
79   - // 返回
80   - return notifyMessage.getId();
81   - }
82   -
83   - @Override
84   - public void updateNotifyMessage(NotifyMessageUpdateReqVO updateReqVO) {
85   - // 校验存在
86   - this.validateNotifyMessageExists(updateReqVO.getId());
87   - // 更新
88   - NotifyMessageDO updateObj = NotifyMessageConvert.INSTANCE.convert(updateReqVO);
89   - notifyMessageMapper.updateById(updateObj);
90   - }
91   -
92   - @Override
93   - public void deleteNotifyMessage(Long id) {
94   - // 校验存在
95   - this.validateNotifyMessageExists(id);
96   - // 删除
97   - notifyMessageMapper.deleteById(id);
98   - }
99   -
100 74 private void validateNotifyMessageExists(Long id) {
101 75 if (notifyMessageMapper.selectById(id) == null) {
102 76 throw exception(NOTIFY_MESSAGE_NOT_EXISTS);
... ... @@ -185,6 +159,7 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
185 159 }
186 160 }
187 161  
  162 + // TODO 芋艿:批量更新,不要单条遍历哈。
188 163 private void batchUpdateReadStatus(Collection<Long> ids) {
189 164 if (CollUtil.isNotEmpty(ids)) {
190 165 for (Long id : ids) {
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
1 1 package cn.iocoder.yudao.module.system.service.notify;
2 2  
3   -import java.util.*;
4   -import javax.validation.*;
5   -
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 4 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
7 5 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
8 6 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
9 7 import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
10 8 import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
11   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
12   -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
  9 +
  10 +import javax.validation.Valid;
  11 +import java.util.Collection;
  12 +import java.util.List;
  13 +import java.util.Map;
13 14  
14 15 /**
15 16 * 站内信模版 Service 接口
16 17 *
17 18 * @author xrcoder
18 19 */
  20 +// TODO 芋艿:缺少单测,可以参考 SmsTemplateServiceTest 写下
19 21 public interface NotifyTemplateService {
20 22  
21 23 /**
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
... ... @@ -114,7 +114,6 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
114 114 initLocalCache();
115 115 }
116 116  
117   -
118 117 /**
119 118 * 获得站内信模板,从缓存中
120 119 *
... ...