Commit 5eb5472dec6314e5aaaf1a5361b153ebd16bcaf2
1 parent
b77b6322
🔧 简化 notice 模块的 VO
Showing
9 changed files
with
58 additions
and
101 deletions
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java
| @@ -4,17 +4,16 @@ import cn.hutool.core.lang.Assert; | @@ -4,17 +4,16 @@ import cn.hutool.core.lang.Assert; | ||
| 4 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 7 | import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi; | 8 | import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi; |
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeCreateReqVO; | ||
| 9 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; | 9 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| 10 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeRespVO; | 10 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeRespVO; |
| 11 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeUpdateReqVO; | ||
| 12 | -import cn.iocoder.yudao.module.system.convert.notice.NoticeConvert; | 11 | +import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 13 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 12 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 14 | import cn.iocoder.yudao.module.system.service.notice.NoticeService; | 13 | import cn.iocoder.yudao.module.system.service.notice.NoticeService; |
| 15 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 16 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 17 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 18 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 19 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 20 | import org.springframework.web.bind.annotation.*; | 19 | import org.springframework.web.bind.annotation.*; |
| @@ -39,16 +38,16 @@ public class NoticeController { | @@ -39,16 +38,16 @@ public class NoticeController { | ||
| 39 | @PostMapping("/create") | 38 | @PostMapping("/create") |
| 40 | @Operation(summary = "创建通知公告") | 39 | @Operation(summary = "创建通知公告") |
| 41 | @PreAuthorize("@ss.hasPermission('system:notice:create')") | 40 | @PreAuthorize("@ss.hasPermission('system:notice:create')") |
| 42 | - public CommonResult<Long> createNotice(@Valid @RequestBody NoticeCreateReqVO reqVO) { | ||
| 43 | - Long noticeId = noticeService.createNotice(reqVO); | 41 | + public CommonResult<Long> createNotice(@Valid @RequestBody NoticeSaveReqVO createReqVO) { |
| 42 | + Long noticeId = noticeService.createNotice(createReqVO); | ||
| 44 | return success(noticeId); | 43 | return success(noticeId); |
| 45 | } | 44 | } |
| 46 | 45 | ||
| 47 | @PutMapping("/update") | 46 | @PutMapping("/update") |
| 48 | @Operation(summary = "修改通知公告") | 47 | @Operation(summary = "修改通知公告") |
| 49 | @PreAuthorize("@ss.hasPermission('system:notice:update')") | 48 | @PreAuthorize("@ss.hasPermission('system:notice:update')") |
| 50 | - public CommonResult<Boolean> updateNotice(@Valid @RequestBody NoticeUpdateReqVO reqVO) { | ||
| 51 | - noticeService.updateNotice(reqVO); | 49 | + public CommonResult<Boolean> updateNotice(@Valid @RequestBody NoticeSaveReqVO updateReqVO) { |
| 50 | + noticeService.updateNotice(updateReqVO); | ||
| 52 | return success(true); | 51 | return success(true); |
| 53 | } | 52 | } |
| 54 | 53 | ||
| @@ -64,8 +63,9 @@ public class NoticeController { | @@ -64,8 +63,9 @@ public class NoticeController { | ||
| 64 | @GetMapping("/page") | 63 | @GetMapping("/page") |
| 65 | @Operation(summary = "获取通知公告列表") | 64 | @Operation(summary = "获取通知公告列表") |
| 66 | @PreAuthorize("@ss.hasPermission('system:notice:query')") | 65 | @PreAuthorize("@ss.hasPermission('system:notice:query')") |
| 67 | - public CommonResult<PageResult<NoticeRespVO>> getNoticePage(@Validated NoticePageReqVO reqVO) { | ||
| 68 | - return success(NoticeConvert.INSTANCE.convertPage(noticeService.getNoticePage(reqVO))); | 66 | + public CommonResult<PageResult<NoticeRespVO>> getNoticePage(@Validated NoticePageReqVO pageReqVO) { |
| 67 | + PageResult<NoticeDO> pageResult = noticeService.getNoticePage(pageReqVO); | ||
| 68 | + return success(BeanUtils.toBean(pageResult, NoticeRespVO.class)); | ||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | @GetMapping("/get") | 71 | @GetMapping("/get") |
| @@ -73,7 +73,8 @@ public class NoticeController { | @@ -73,7 +73,8 @@ public class NoticeController { | ||
| 73 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 73 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 74 | @PreAuthorize("@ss.hasPermission('system:notice:query')") | 74 | @PreAuthorize("@ss.hasPermission('system:notice:query')") |
| 75 | public CommonResult<NoticeRespVO> getNotice(@RequestParam("id") Long id) { | 75 | public CommonResult<NoticeRespVO> getNotice(@RequestParam("id") Long id) { |
| 76 | - return success(NoticeConvert.INSTANCE.convert(noticeService.getNotice(id))); | 76 | + NoticeDO notice = noticeService.getNotice(id); |
| 77 | + return success(BeanUtils.toBean(notice, NoticeRespVO.class)); | ||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | @PostMapping("/push") | 80 | @PostMapping("/push") |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/vo/NoticeCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.notice.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | - | ||
| 7 | -@Schema(description = "管理后台 - 通知公告创建 Request VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -public class NoticeCreateReqVO extends NoticeBaseVO { | ||
| 11 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/vo/NoticeRespVO.java
| @@ -2,18 +2,28 @@ package cn.iocoder.yudao.module.system.controller.admin.notice.vo; | @@ -2,18 +2,28 @@ package cn.iocoder.yudao.module.system.controller.admin.notice.vo; | ||
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | 5 | ||
| 7 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 8 | 7 | ||
| 9 | @Schema(description = "管理后台 - 通知公告信息 Response VO") | 8 | @Schema(description = "管理后台 - 通知公告信息 Response VO") |
| 10 | @Data | 9 | @Data |
| 11 | -@EqualsAndHashCode(callSuper = true) | ||
| 12 | -public class NoticeRespVO extends NoticeBaseVO { | 10 | +public class NoticeRespVO { |
| 13 | 11 | ||
| 14 | @Schema(description = "通知公告序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 12 | @Schema(description = "通知公告序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 15 | private Long id; | 13 | private Long id; |
| 16 | 14 | ||
| 15 | + @Schema(description = "公告标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "小博主") | ||
| 16 | + private String title; | ||
| 17 | + | ||
| 18 | + @Schema(description = "公告类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "小博主") | ||
| 19 | + private Integer type; | ||
| 20 | + | ||
| 21 | + @Schema(description = "公告内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "半生编码") | ||
| 22 | + private String content; | ||
| 23 | + | ||
| 24 | + @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 25 | + private Integer status; | ||
| 26 | + | ||
| 17 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") | 27 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") |
| 18 | private LocalDateTime createTime; | 28 | private LocalDateTime createTime; |
| 19 | 29 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/vo/NoticeBaseVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/vo/NoticeSaveReqVO.java
| @@ -7,12 +7,13 @@ import javax.validation.constraints.NotBlank; | @@ -7,12 +7,13 @@ import javax.validation.constraints.NotBlank; | ||
| 7 | import javax.validation.constraints.NotNull; | 7 | import javax.validation.constraints.NotNull; |
| 8 | import javax.validation.constraints.Size; | 8 | import javax.validation.constraints.Size; |
| 9 | 9 | ||
| 10 | -/** | ||
| 11 | - * 通知公告 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 12 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 13 | - */ | 10 | +@Schema(description = "管理后台 - 通知公告创建/修改 Request VO") |
| 14 | @Data | 11 | @Data |
| 15 | -public class NoticeBaseVO { | 12 | +public class NoticeSaveReqVO { |
| 13 | + | ||
| 14 | + @Schema(description = "岗位公告编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 15 | + @NotNull(message = "岗位公告编号不能为空") | ||
| 16 | + private Long id; | ||
| 16 | 17 | ||
| 17 | @Schema(description = "公告标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "小博主") | 18 | @Schema(description = "公告标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "小博主") |
| 18 | @NotBlank(message = "公告标题不能为空") | 19 | @NotBlank(message = "公告标题不能为空") |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/vo/NoticeUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.notice.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | - | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - 岗位公告更新 Request VO") | ||
| 10 | -@Data | ||
| 11 | -@EqualsAndHashCode(callSuper = true) | ||
| 12 | -public class NoticeUpdateReqVO extends NoticeBaseVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "岗位公告编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 15 | - @NotNull(message = "岗位公告编号不能为空") | ||
| 16 | - private Long id; | ||
| 17 | - | ||
| 18 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notice/NoticeConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.system.convert.notice; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeRespVO; | ||
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeUpdateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | ||
| 8 | -import org.mapstruct.Mapper; | ||
| 9 | -import org.mapstruct.factory.Mappers; | ||
| 10 | - | ||
| 11 | -@Mapper | ||
| 12 | -public interface NoticeConvert { | ||
| 13 | - | ||
| 14 | - NoticeConvert INSTANCE = Mappers.getMapper(NoticeConvert.class); | ||
| 15 | - | ||
| 16 | - PageResult<NoticeRespVO> convertPage(PageResult<NoticeDO> page); | ||
| 17 | - | ||
| 18 | - NoticeRespVO convert(NoticeDO bean); | ||
| 19 | - | ||
| 20 | - NoticeDO convert(NoticeUpdateReqVO bean); | ||
| 21 | - | ||
| 22 | - NoticeDO convert(NoticeCreateReqVO bean); | ||
| 23 | - | ||
| 24 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notice/NoticeService.java
| 1 | package cn.iocoder.yudao.module.system.service.notice; | 1 | package cn.iocoder.yudao.module.system.service.notice; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeCreateReqVO; | ||
| 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeUpdateReqVO; | 5 | +import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 8 | 7 | ||
| 9 | /** | 8 | /** |
| @@ -12,29 +11,29 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | @@ -12,29 +11,29 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | ||
| 12 | public interface NoticeService { | 11 | public interface NoticeService { |
| 13 | 12 | ||
| 14 | /** | 13 | /** |
| 15 | - * 创建岗位公告公告 | 14 | + * 创建通知公告 |
| 16 | * | 15 | * |
| 17 | - * @param reqVO 岗位公告公告信息 | ||
| 18 | - * @return 岗位公告公告编号 | 16 | + * @param createReqVO 通知公告 |
| 17 | + * @return 编号 | ||
| 19 | */ | 18 | */ |
| 20 | - Long createNotice(NoticeCreateReqVO reqVO); | 19 | + Long createNotice(NoticeSaveReqVO createReqVO); |
| 21 | 20 | ||
| 22 | /** | 21 | /** |
| 23 | - * 更新岗位公告公告 | 22 | + * 更新通知公告 |
| 24 | * | 23 | * |
| 25 | - * @param reqVO 岗位公告公告信息 | 24 | + * @param reqVO 通知公告 |
| 26 | */ | 25 | */ |
| 27 | - void updateNotice(NoticeUpdateReqVO reqVO); | 26 | + void updateNotice(NoticeSaveReqVO reqVO); |
| 28 | 27 | ||
| 29 | /** | 28 | /** |
| 30 | - * 删除岗位公告公告信息 | 29 | + * 删除通知公告 |
| 31 | * | 30 | * |
| 32 | - * @param id 岗位公告公告编号 | 31 | + * @param id 编号 |
| 33 | */ | 32 | */ |
| 34 | void deleteNotice(Long id); | 33 | void deleteNotice(Long id); |
| 35 | 34 | ||
| 36 | /** | 35 | /** |
| 37 | - * 获得岗位公告公告分页列表 | 36 | + * 获得通知公告分页列表 |
| 38 | * | 37 | * |
| 39 | * @param reqVO 分页条件 | 38 | * @param reqVO 分页条件 |
| 40 | * @return 部门分页列表 | 39 | * @return 部门分页列表 |
| @@ -42,10 +41,10 @@ public interface NoticeService { | @@ -42,10 +41,10 @@ public interface NoticeService { | ||
| 42 | PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO); | 41 | PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO); |
| 43 | 42 | ||
| 44 | /** | 43 | /** |
| 45 | - * 获得岗位公告公告信息 | 44 | + * 获得通知公告 |
| 46 | * | 45 | * |
| 47 | - * @param id 岗位公告公告编号 | ||
| 48 | - * @return 岗位公告公告信息 | 46 | + * @param id 编号 |
| 47 | + * @return 通知公告 | ||
| 49 | */ | 48 | */ |
| 50 | NoticeDO getNotice(Long id); | 49 | NoticeDO getNotice(Long id); |
| 51 | 50 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.notice; | 1 | package cn.iocoder.yudao.module.system.service.notice; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeCreateReqVO; | 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeUpdateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.system.convert.notice.NoticeConvert; | 6 | +import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 9 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; | 8 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; |
| 10 | import com.google.common.annotations.VisibleForTesting; | 9 | import com.google.common.annotations.VisibleForTesting; |
| @@ -27,18 +26,18 @@ public class NoticeServiceImpl implements NoticeService { | @@ -27,18 +26,18 @@ public class NoticeServiceImpl implements NoticeService { | ||
| 27 | private NoticeMapper noticeMapper; | 26 | private NoticeMapper noticeMapper; |
| 28 | 27 | ||
| 29 | @Override | 28 | @Override |
| 30 | - public Long createNotice(NoticeCreateReqVO reqVO) { | ||
| 31 | - NoticeDO notice = NoticeConvert.INSTANCE.convert(reqVO); | 29 | + public Long createNotice(NoticeSaveReqVO createReqVO) { |
| 30 | + NoticeDO notice = BeanUtils.toBean(createReqVO, NoticeDO.class); | ||
| 32 | noticeMapper.insert(notice); | 31 | noticeMapper.insert(notice); |
| 33 | return notice.getId(); | 32 | return notice.getId(); |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | @Override | 35 | @Override |
| 37 | - public void updateNotice(NoticeUpdateReqVO reqVO) { | 36 | + public void updateNotice(NoticeSaveReqVO updateReqVO) { |
| 38 | // 校验是否存在 | 37 | // 校验是否存在 |
| 39 | - validateNoticeExists(reqVO.getId()); | 38 | + validateNoticeExists(updateReqVO.getId()); |
| 40 | // 更新通知公告 | 39 | // 更新通知公告 |
| 41 | - NoticeDO updateObj = NoticeConvert.INSTANCE.convert(reqVO); | 40 | + NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class); |
| 42 | noticeMapper.updateById(updateObj); | 41 | noticeMapper.updateById(updateObj); |
| 43 | } | 42 | } |
| 44 | 43 |
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java
| @@ -3,9 +3,8 @@ package cn.iocoder.yudao.module.system.service.notice; | @@ -3,9 +3,8 @@ package cn.iocoder.yudao.module.system.service.notice; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeCreateReqVO; | ||
| 7 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; | 6 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeUpdateReqVO; | 7 | +import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 9 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 10 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; | 9 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; |
| 11 | import org.junit.jupiter.api.Test; | 10 | import org.junit.jupiter.api.Test; |
| @@ -72,14 +71,15 @@ class NoticeServiceImplTest extends BaseDbUnitTest { | @@ -72,14 +71,15 @@ class NoticeServiceImplTest extends BaseDbUnitTest { | ||
| 72 | @Test | 71 | @Test |
| 73 | public void testCreateNotice_success() { | 72 | public void testCreateNotice_success() { |
| 74 | // 准备参数 | 73 | // 准备参数 |
| 75 | - NoticeCreateReqVO reqVO = randomPojo(NoticeCreateReqVO.class); | 74 | + NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class) |
| 75 | + .setId(null); // 避免 id 被赋值 | ||
| 76 | 76 | ||
| 77 | // 调用 | 77 | // 调用 |
| 78 | Long noticeId = noticeService.createNotice(reqVO); | 78 | Long noticeId = noticeService.createNotice(reqVO); |
| 79 | // 校验插入属性是否正确 | 79 | // 校验插入属性是否正确 |
| 80 | assertNotNull(noticeId); | 80 | assertNotNull(noticeId); |
| 81 | NoticeDO notice = noticeMapper.selectById(noticeId); | 81 | NoticeDO notice = noticeMapper.selectById(noticeId); |
| 82 | - assertPojoEquals(reqVO, notice); | 82 | + assertPojoEquals(reqVO, notice, "id"); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | @Test | 85 | @Test |
| @@ -89,7 +89,7 @@ class NoticeServiceImplTest extends BaseDbUnitTest { | @@ -89,7 +89,7 @@ class NoticeServiceImplTest extends BaseDbUnitTest { | ||
| 89 | noticeMapper.insert(dbNoticeDO); | 89 | noticeMapper.insert(dbNoticeDO); |
| 90 | 90 | ||
| 91 | // 准备更新参数 | 91 | // 准备更新参数 |
| 92 | - NoticeUpdateReqVO reqVO = randomPojo(NoticeUpdateReqVO.class, o -> o.setId(dbNoticeDO.getId())); | 92 | + NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class, o -> o.setId(dbNoticeDO.getId())); |
| 93 | 93 | ||
| 94 | // 更新 | 94 | // 更新 |
| 95 | noticeService.updateNotice(reqVO); | 95 | noticeService.updateNotice(reqVO); |