review 部分站内信的实现

This commit is contained in:
YunaiV 2022-11-21 13:01:16 +08:00
parent 131adad9c0
commit e8dd66c6f8
10 changed files with 30 additions and 133 deletions

View File

@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert; import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService; import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
@ -30,30 +28,6 @@ public class NotifyMessageController {
@Resource @Resource
private NotifyMessageService notifyMessageService; private NotifyMessageService notifyMessageService;
@PostMapping("/create")
@ApiOperation("创建站内信")
@PreAuthorize("@ss.hasPermission('system:notify-message:create')")
public CommonResult<Long> createNotifyMessage(@Valid @RequestBody NotifyMessageCreateReqVO createReqVO) {
return success(notifyMessageService.createNotifyMessage(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新站内信")
@PreAuthorize("@ss.hasPermission('system:notify-message:update')")
public CommonResult<Boolean> updateNotifyMessage(@Valid @RequestBody NotifyMessageUpdateReqVO updateReqVO) {
notifyMessageService.updateNotifyMessage(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('system:notify-message:delete')")
public CommonResult<Boolean> deleteNotifyMessage(@RequestParam("id") Long id) {
notifyMessageService.deleteNotifyMessage(id);
return success(true);
}
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得站内信") @ApiOperation("获得站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@ -70,4 +44,5 @@ public class NotifyMessageController {
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO); PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult)); return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
} }
} }

View File

@ -19,12 +19,12 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO 芋艿VO 类上的 swagger 注解完善下例如说 swagger枚举等等
@Api(tags = "管理后台 - 站内信模版") @Api(tags = "管理后台 - 站内信模版")
@RestController @RestController
@RequestMapping("/system/notify-template") @RequestMapping("/system/notify-template")
@ -67,15 +67,6 @@ public class NotifyTemplateController {
return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate)); return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
} }
@GetMapping("/list")
@ApiOperation("获得站内信模版列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('system:notify-template:query')")
public CommonResult<List<NotifyTemplateRespVO>> getNotifyTemplateList(@RequestParam("ids") Collection<Long> ids) {
List<NotifyTemplateDO> list = notifyTemplateService.getNotifyTemplateList(ids);
return success(NotifyTemplateConvert.INSTANCE.convertList(list));
}
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得站内信模版分页") @ApiOperation("获得站内信模版分页")
@PreAuthorize("@ss.hasPermission('system:notify-template:query')") @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
@ -96,4 +87,8 @@ public class NotifyTemplateController {
ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas); ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
} }
// TODO @芋艿参考 SmsTemplateController sendNotify 写一个发送站内信的接口
// TODO @芋艿参考 SmsSendServiceImpl新建一个 NotifySendServiceImpl用于提供出来给发送消息注意不要考虑异步发送直接 insert 就可以了也不用考虑发送后的回调
} }

View File

@ -38,7 +38,7 @@ public class UserNotifyMessageController {
@Resource @Resource
private NotifyMessageService notifyMessageService; private NotifyMessageService notifyMessageService;
// TODO 芋艿 NotifyMessageController page 合并
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得站内信分页") @ApiOperation("获得站内信分页")
public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) { public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
@ -48,6 +48,7 @@ public class UserNotifyMessageController {
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult)); return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
} }
// TODO @芋艿url 改成 get-recent-list方法名也改下默认传入 size = 10
@GetMapping("/latest/list") @GetMapping("/latest/list")
@ApiOperation("获得最新10站内信列表") @ApiOperation("获得最新10站内信列表")
public CommonResult<List<NotifyMessageRespVO>> getNotifyLatestMessageList() { public CommonResult<List<NotifyMessageRespVO>> getNotifyLatestMessageList() {
@ -56,6 +57,7 @@ public class UserNotifyMessageController {
reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
reqVO.setPageNo(1); reqVO.setPageNo(1);
reqVO.setPageSize(10); reqVO.setPageSize(10);
// TODO 芋艿不要用分页写
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO); PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
if (CollUtil.isNotEmpty(pageResult.getList())) { if (CollUtil.isNotEmpty(pageResult.getList())) {
return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList())); return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList()));
@ -63,12 +65,14 @@ public class UserNotifyMessageController {
return success(Collections.emptyList()); return success(Collections.emptyList());
} }
// TODO @芋艿get-unread-count
@GetMapping("/unread/count") @GetMapping("/unread/count")
@ApiOperation("获得未读站内信数量") @ApiOperation("获得未读站内信数量")
public CommonResult<Long> getUnreadNotifyMessageCount() { public CommonResult<Long> getUnreadNotifyMessageCount() {
return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue())); return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
} }
// TODO @芋艿 get 站内信和更新站内信已经读分开其中更新单条和多条使用一个接口就好列
@GetMapping("/read") @GetMapping("/read")
@ApiOperation("获得站内信") @ApiOperation("获得站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@ -79,6 +83,7 @@ public class UserNotifyMessageController {
return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage)); return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
} }
// TODO @芋艿PutMappingupdate-list-read
@GetMapping("/read/list") @GetMapping("/read/list")
@ApiOperation("批量标记已读") @ApiOperation("批量标记已读")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@ -87,6 +92,7 @@ public class UserNotifyMessageController {
return success(Boolean.TRUE); return success(Boolean.TRUE);
} }
// TODO @芋艿PutMappingupdate-all-read
@GetMapping("/read/all") @GetMapping("/read/all")
@ApiOperation("所有未读消息标记已读") @ApiOperation("所有未读消息标记已读")
public CommonResult<Boolean> batchUpdateAllNotifyMessageReadStatus() { public CommonResult<Boolean> batchUpdateAllNotifyMessageReadStatus() {

View File

@ -1,15 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
import lombok.*;
import io.swagger.annotations.*;
@ApiModel("管理后台 - 站内信创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class NotifyMessageCreateReqVO extends NotifyMessageBaseVO {
@ApiModelProperty(value = "站内信模版编号")
private Long templateId;
}

View File

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message; package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 站内信分页 Request VO") @ApiModel("管理后台 - 站内信分页 Request VO")
@ -18,12 +22,13 @@ public class NotifyMessagePageReqVO extends PageParam {
private String title; private String title;
@ApiModelProperty(value = "是否已读 0-未读 1-已读") @ApiModelProperty(value = "是否已读 0-未读 1-已读")
private Integer readStatus; private Boolean readStatus;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] createTime; private Date[] createTime;
// TODO 芋艿去掉 userId userType不要在 VO
@ApiModelProperty(value = "用户编号", hidden = true) @ApiModelProperty(value = "用户编号", hidden = true)
private Long userId; private Long userId;

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
import lombok.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 站内信更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class NotifyMessageUpdateReqVO extends NotifyMessageBaseVO {
@ApiModelProperty(value = "ID", required = true)
@NotNull(message = "ID不能为空")
private Long id;
@ApiModelProperty(value = "站内信模版编号")
private Long templateId;
}

View File

@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.system.service.notify; package cn.iocoder.yudao.module.system.service.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import javax.validation.Valid;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -17,28 +14,6 @@ import java.util.List;
*/ */
public interface NotifyMessageService { public interface NotifyMessageService {
/**
* 创建站内信
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createNotifyMessage(@Valid NotifyMessageCreateReqVO createReqVO);
/**
* 更新站内信
*
* @param updateReqVO 更新信息
*/
void updateNotifyMessage(@Valid NotifyMessageUpdateReqVO updateReqVO);
/**
* 删除站内信
*
* @param id 编号
*/
void deleteNotifyMessage(Long id);
/** /**
* 获得站内信 * 获得站内信
* *

View File

@ -71,32 +71,6 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public Long createNotifyMessage(NotifyMessageCreateReqVO createReqVO) {
// 插入
NotifyMessageDO notifyMessage = NotifyMessageConvert.INSTANCE.convert(createReqVO);
notifyMessageMapper.insert(notifyMessage);
// 返回
return notifyMessage.getId();
}
@Override
public void updateNotifyMessage(NotifyMessageUpdateReqVO updateReqVO) {
// 校验存在
this.validateNotifyMessageExists(updateReqVO.getId());
// 更新
NotifyMessageDO updateObj = NotifyMessageConvert.INSTANCE.convert(updateReqVO);
notifyMessageMapper.updateById(updateObj);
}
@Override
public void deleteNotifyMessage(Long id) {
// 校验存在
this.validateNotifyMessageExists(id);
// 删除
notifyMessageMapper.deleteById(id);
}
private void validateNotifyMessageExists(Long id) { private void validateNotifyMessageExists(Long id) {
if (notifyMessageMapper.selectById(id) == null) { if (notifyMessageMapper.selectById(id) == null) {
throw exception(NOTIFY_MESSAGE_NOT_EXISTS); throw exception(NOTIFY_MESSAGE_NOT_EXISTS);
@ -185,6 +159,7 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
} }
} }
// TODO 芋艿批量更新不要单条遍历哈
private void batchUpdateReadStatus(Collection<Long> ids) { private void batchUpdateReadStatus(Collection<Long> ids) {
if (CollUtil.isNotEmpty(ids)) { if (CollUtil.isNotEmpty(ids)) {
for (Long id : ids) { for (Long id : ids) {

View File

@ -1,21 +1,23 @@
package cn.iocoder.yudao.module.system.service.notify; package cn.iocoder.yudao.module.system.service.notify;
import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/** /**
* 站内信模版 Service 接口 * 站内信模版 Service 接口
* *
* @author xrcoder * @author xrcoder
*/ */
// TODO 芋艿缺少单测可以参考 SmsTemplateServiceTest 写下
public interface NotifyTemplateService { public interface NotifyTemplateService {
/** /**

View File

@ -114,7 +114,6 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
initLocalCache(); initLocalCache();
} }
/** /**
* 获得站内信模板从缓存中 * 获得站内信模板从缓存中
* *