🔧 简化 notify 模块的 VO
parent
27710435b2
commit
2ba43bede8
|
@ -3,15 +3,15 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
|
|||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
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.convert.notify.NotifyMessageConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -39,8 +39,8 @@ public class NotifyMessageController {
|
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:notify-message:query')")
|
||||
public CommonResult<NotifyMessageRespVO> getNotifyMessage(@RequestParam("id") Long id) {
|
||||
NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
|
||||
return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
|
||||
NotifyMessageDO message = notifyMessageService.getNotifyMessage(id);
|
||||
return success(BeanUtils.toBean(message, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -48,7 +48,7 @@ public class NotifyMessageController {
|
|||
@PreAuthorize("@ss.hasPermission('system:notify-message:query')")
|
||||
public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
|
||||
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
// ========== 查看自己的站内信 ==========
|
||||
|
@ -58,7 +58,7 @@ public class NotifyMessageController {
|
|||
public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
|
||||
getLoginUserId(), UserTypeEnum.ADMIN.getValue());
|
||||
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/update-read")
|
||||
|
@ -83,13 +83,14 @@ public class NotifyMessageController {
|
|||
@RequestParam(name = "size", defaultValue = "10") Integer size) {
|
||||
List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(
|
||||
getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
|
||||
return success(NotifyMessageConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-unread-count")
|
||||
@Operation(summary = "获得当前用户的未读站内信数量")
|
||||
public CommonResult<Long> getUnreadNotifyMessageCount() {
|
||||
return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
|
||||
return success(notifyMessageService.getUnreadNotifyMessageCount(
|
||||
getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,11 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
|
|||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*;
|
||||
import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
|
||||
import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
|
||||
|
@ -35,14 +38,14 @@ public class NotifyTemplateController {
|
|||
@PostMapping("/create")
|
||||
@Operation(summary = "创建站内信模版")
|
||||
@PreAuthorize("@ss.hasPermission('system:notify-template:create')")
|
||||
public CommonResult<Long> createNotifyTemplate(@Valid @RequestBody NotifyTemplateCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createNotifyTemplate(@Valid @RequestBody NotifyTemplateSaveReqVO createReqVO) {
|
||||
return success(notifyTemplateService.createNotifyTemplate(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新站内信模版")
|
||||
@PreAuthorize("@ss.hasPermission('system:notify-template:update')")
|
||||
public CommonResult<Boolean> updateNotifyTemplate(@Valid @RequestBody NotifyTemplateUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateNotifyTemplate(@Valid @RequestBody NotifyTemplateSaveReqVO updateReqVO) {
|
||||
notifyTemplateService.updateNotifyTemplate(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
@ -61,8 +64,8 @@ public class NotifyTemplateController {
|
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:notify-template:query')")
|
||||
public CommonResult<NotifyTemplateRespVO> getNotifyTemplate(@RequestParam("id") Long id) {
|
||||
NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplate(id);
|
||||
return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
|
||||
NotifyTemplateDO template = notifyTemplateService.getNotifyTemplate(id);
|
||||
return success(BeanUtils.toBean(template, NotifyTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -70,7 +73,7 @@ public class NotifyTemplateController {
|
|||
@PreAuthorize("@ss.hasPermission('system:notify-template:query')")
|
||||
public CommonResult<PageResult<NotifyTemplateRespVO>> getNotifyTemplatePage(@Valid NotifyTemplatePageReqVO pageVO) {
|
||||
PageResult<NotifyTemplateDO> pageResult = notifyTemplateService.getNotifyTemplatePage(pageVO);
|
||||
return success(NotifyTemplateConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, NotifyTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/send-notify")
|
||||
|
@ -85,5 +88,4 @@ public class NotifyTemplateController {
|
|||
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 站内信消息 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class NotifyMessageBaseVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25025")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Byte userType;
|
||||
|
||||
@Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13013")
|
||||
@NotNull(message = "模版编号不能为空")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
|
||||
@NotNull(message = "模板编码不能为空")
|
||||
private String templateCode;
|
||||
|
||||
@Schema(description = "模版发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotNull(message = "模版发送人名称不能为空")
|
||||
private String templateNickname;
|
||||
|
||||
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试内容")
|
||||
@NotNull(message = "模版内容不能为空")
|
||||
private String templateContent;
|
||||
|
||||
@Schema(description = "模版类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "模版类型不能为空")
|
||||
private Integer templateType;
|
||||
|
||||
@Schema(description = "模版参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "模版参数不能为空")
|
||||
private Map<String, Object> templateParams;
|
||||
|
||||
@Schema(description = "是否已读", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否已读不能为空")
|
||||
private Boolean readStatus;
|
||||
|
||||
@Schema(description = "阅读时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime readTime;
|
||||
|
||||
}
|
|
@ -2,20 +2,47 @@ package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
|
|||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 站内信 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class NotifyMessageRespVO extends NotifyMessageBaseVO {
|
||||
public class NotifyMessageRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25025")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Byte userType;
|
||||
|
||||
@Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13013")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
|
||||
private String templateCode;
|
||||
|
||||
@Schema(description = "模版发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
private String templateNickname;
|
||||
|
||||
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试内容")
|
||||
private String templateContent;
|
||||
|
||||
@Schema(description = "模版类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer templateType;
|
||||
|
||||
@Schema(description = "模版参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Map<String, Object> templateParams;
|
||||
|
||||
@Schema(description = "是否已读", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean readStatus;
|
||||
|
||||
@Schema(description = "阅读时间")
|
||||
private LocalDateTime readTime;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "管理后台 - 站内信模版创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class NotifyTemplateCreateReqVO extends NotifyTemplateBaseVO {
|
||||
}
|
|
@ -2,24 +2,41 @@ package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
|
|||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 站内信模版 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class NotifyTemplateRespVO extends NotifyTemplateBaseVO {
|
||||
public class NotifyTemplateRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "参数数组", example = "name,code")
|
||||
private List<String> params;
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ import lombok.Data;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 站内信模版 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 站内信模版创建/修改 Request VO")
|
||||
@Data
|
||||
public class NotifyTemplateBaseVO {
|
||||
public class NotifyTemplateSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版")
|
||||
@NotEmpty(message = "模版名称不能为空")
|
|
@ -25,4 +25,5 @@ public class NotifyTemplateSendReqVO {
|
|||
|
||||
@Schema(description = "模板参数")
|
||||
private Map<String, Object> templateParams;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 站内信模版更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class NotifyTemplateUpdateReqVO extends NotifyTemplateBaseVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "ID 不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package cn.iocoder.yudao.module.system.convert.notify;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 站内信 Convert
|
||||
*
|
||||
* @author xrcoder
|
||||
*/
|
||||
@Mapper
|
||||
public interface NotifyMessageConvert {
|
||||
|
||||
NotifyMessageConvert INSTANCE = Mappers.getMapper(NotifyMessageConvert.class);
|
||||
|
||||
NotifyMessageRespVO convert(NotifyMessageDO bean);
|
||||
|
||||
List<NotifyMessageRespVO> convertList(List<NotifyMessageDO> list);
|
||||
|
||||
PageResult<NotifyMessageRespVO> convertPage(PageResult<NotifyMessageDO> page);
|
||||
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package cn.iocoder.yudao.module.system.convert.notify;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 站内信模版 Convert
|
||||
*
|
||||
* @author xrcoder
|
||||
*/
|
||||
@Mapper(uses = DateUtils.class)
|
||||
public interface NotifyTemplateConvert {
|
||||
|
||||
NotifyTemplateConvert INSTANCE = Mappers.getMapper(NotifyTemplateConvert.class);
|
||||
|
||||
NotifyTemplateDO convert(NotifyTemplateCreateReqVO bean);
|
||||
|
||||
NotifyTemplateDO convert(NotifyTemplateUpdateReqVO bean);
|
||||
|
||||
NotifyTemplateRespVO convert(NotifyTemplateDO bean);
|
||||
|
||||
List<NotifyTemplateRespVO> convertList(List<NotifyTemplateDO> list);
|
||||
|
||||
PageResult<NotifyTemplateRespVO> convertPage(PageResult<NotifyTemplateDO> page);
|
||||
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
package cn.iocoder.yudao.module.system.service.notify;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
|
||||
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.NotifyTemplateSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -22,14 +21,14 @@ public interface NotifyTemplateService {
|
|||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createNotifyTemplate(@Valid NotifyTemplateCreateReqVO createReqVO);
|
||||
Long createNotifyTemplate(@Valid NotifyTemplateSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新站内信模版
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateNotifyTemplate(@Valid NotifyTemplateUpdateReqVO updateReqVO);
|
||||
void updateNotifyTemplate(@Valid NotifyTemplateSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除站内信模版
|
||||
|
|
|
@ -3,10 +3,9 @@ package cn.iocoder.yudao.module.system.service.notify;
|
|||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.convert.notify.NotifyTemplateConvert;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
||||
|
@ -45,12 +44,12 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
|
|||
private NotifyTemplateMapper notifyTemplateMapper;
|
||||
|
||||
@Override
|
||||
public Long createNotifyTemplate(NotifyTemplateCreateReqVO createReqVO) {
|
||||
public Long createNotifyTemplate(NotifyTemplateSaveReqVO createReqVO) {
|
||||
// 校验站内信编码是否重复
|
||||
validateNotifyTemplateCodeDuplicate(null, createReqVO.getCode());
|
||||
|
||||
// 插入
|
||||
NotifyTemplateDO notifyTemplate = NotifyTemplateConvert.INSTANCE.convert(createReqVO);
|
||||
NotifyTemplateDO notifyTemplate = BeanUtils.toBean(createReqVO, NotifyTemplateDO.class);
|
||||
notifyTemplate.setParams(parseTemplateContentParams(notifyTemplate.getContent()));
|
||||
notifyTemplateMapper.insert(notifyTemplate);
|
||||
return notifyTemplate.getId();
|
||||
|
@ -59,14 +58,14 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
|
|||
@Override
|
||||
@CacheEvict(cacheNames = RedisKeyConstants.NOTIFY_TEMPLATE,
|
||||
allEntries = true) // allEntries 清空所有缓存,因为可能修改到 code 字段,不好清理
|
||||
public void updateNotifyTemplate(NotifyTemplateUpdateReqVO updateReqVO) {
|
||||
public void updateNotifyTemplate(NotifyTemplateSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateNotifyTemplateExists(updateReqVO.getId());
|
||||
// 校验站内信编码是否重复
|
||||
validateNotifyTemplateCodeDuplicate(updateReqVO.getId(), updateReqVO.getCode());
|
||||
|
||||
// 更新
|
||||
NotifyTemplateDO updateObj = NotifyTemplateConvert.INSTANCE.convert(updateReqVO);
|
||||
NotifyTemplateDO updateObj = BeanUtils.toBean(updateReqVO, NotifyTemplateDO.class);
|
||||
updateObj.setParams(parseTemplateContentParams(updateObj.getContent()));
|
||||
notifyTemplateMapper.updateById(updateObj);
|
||||
}
|
||||
|
@ -135,4 +134,5 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
|
|||
public String formatNotifyTemplateContent(String content, Map<String, Object> params) {
|
||||
return StrUtil.format(content, params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,8 @@ package cn.iocoder.yudao.module.system.service.notify;
|
|||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
|
||||
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.NotifyTemplateSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -41,8 +40,9 @@ public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
|
|||
@Test
|
||||
public void testCreateNotifyTemplate_success() {
|
||||
// 准备参数
|
||||
NotifyTemplateCreateReqVO reqVO = randomPojo(NotifyTemplateCreateReqVO.class,
|
||||
o -> o.setStatus(randomCommonStatus()));
|
||||
NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class,
|
||||
o -> o.setStatus(randomCommonStatus()))
|
||||
.setId(null); // 防止 id 被赋值
|
||||
|
||||
// 调用
|
||||
Long notifyTemplateId = notifyTemplateService.createNotifyTemplate(reqVO);
|
||||
|
@ -50,7 +50,7 @@ public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
|
|||
assertNotNull(notifyTemplateId);
|
||||
// 校验记录的属性是否正确
|
||||
NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(notifyTemplateId);
|
||||
assertPojoEquals(reqVO, notifyTemplate);
|
||||
assertPojoEquals(reqVO, notifyTemplate, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -59,7 +59,7 @@ public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
|
|||
NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class);
|
||||
notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class, o -> {
|
||||
NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class, o -> {
|
||||
o.setId(dbNotifyTemplate.getId()); // 设置更新的 ID
|
||||
o.setStatus(randomCommonStatus());
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
|
|||
@Test
|
||||
public void testUpdateNotifyTemplate_notExists() {
|
||||
// 准备参数
|
||||
NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class);
|
||||
NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> notifyTemplateService.updateNotifyTemplate(reqVO), NOTIFY_TEMPLATE_NOT_EXISTS);
|
||||
|
|
Loading…
Reference in New Issue