From 6a36fe65b2732e9f8787ccefbb9069d60fb76139 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 13 Jan 2021 09:39:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=A8=A1=E5=9D=97=E7=9A=84=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysNoticeServiceImpl.java | 86 ------------ ruoyi-ui/src/api/system/notice.js | 12 +- ruoyi-ui/src/utils/dict.js | 1 + ruoyi-ui/src/views/system/notice/index.vue | 126 +++++++----------- .../dept/vo/dept/SysDeptRespVO.java | 2 +- .../dept/vo/dept/SysDeptSimpleRespVO.java | 2 +- .../dept/vo/post/SysPostRespVO.java | 2 +- .../dept/vo/post/SysPostSimpleRespVO.java | 2 +- .../dict/vo/data/SysDictDataRespVO.java | 2 +- .../dict/vo/type/SysDictTypeRespVO.java | 2 +- .../notice/SysNoticeController.java | 98 +++++++------- .../controller/notice/vo/SysNoticeBaseVO.java | 32 +++++ .../notice/vo/SysNoticeCreateReqVO.java | 12 ++ .../notice/vo/SysNoticePageReqVO.java | 20 +++ .../controller/notice/vo/SysNoticeRespVO.java | 22 +++ .../notice/vo/SysNoticeUpdateReqVO.java | 20 +++ .../permission/vo/menu/SysMenuRespVO.java | 2 +- .../vo/menu/SysMenuSimpleRespVO.java | 2 +- .../permission/vo/role/SysRoleRespVO.java | 2 +- .../vo/role/SysRoleSimpleRespVO.java | 2 +- .../user/vo/user/SysUserPageItemRespVO.java | 2 +- .../user/vo/user/SysUserRespVO.java | 2 +- .../convert/notice/SysNoticeConvert.java | 18 +++ .../dal/mysql/dao/notice/SysNoticeMapper.java | 11 ++ .../mysql/dataobject/notice/SysNoticeDO.java | 8 +- .../system/enums/SysErrorCodeConstants.java | 3 + .../service/notice/SysNoticeService.java | 51 +++++++ .../notice/impl/SysNoticeServiceImpl.java | 73 ++++++++++ 28 files changed, 384 insertions(+), 233 deletions(-) delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeBaseVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeCreateReqVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticePageReqVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeRespVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeUpdateReqVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/service/notice/SysNoticeService.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/service/notice/impl/SysNoticeServiceImpl.java diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java deleted file mode 100644 index 0f049f66b..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.system.domain.SysNotice; -import com.ruoyi.system.mapper.SysNoticeMapper; -import com.ruoyi.system.service.ISysNoticeService; - -/** - * 公告 服务层实现 - * - * @author ruoyi - */ -@Service -public class SysNoticeServiceImpl implements ISysNoticeService { - @Autowired - private SysNoticeMapper noticeMapper; - - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - @Override - public SysNotice selectNoticeById(Long noticeId) { - return noticeMapper.selectNoticeById(noticeId); - } - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - @Override - public List selectNoticeList(SysNotice notice) { - return noticeMapper.selectNoticeList(notice); - } - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - @Override - public int insertNotice(SysNotice notice) { - return noticeMapper.insertNotice(notice); - } - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - @Override - public int updateNotice(SysNotice notice) { - return noticeMapper.updateNotice(notice); - } - - /** - * 删除公告对象 - * - * @param noticeId 公告ID - * @return 结果 - */ - @Override - public int deleteNoticeById(Long noticeId) { - return noticeMapper.deleteNoticeById(noticeId); - } - - /** - * 批量删除公告信息 - * - * @param noticeIds 需要删除的公告ID - * @return 结果 - */ - @Override - public int deleteNoticeByIds(Long[] noticeIds) { - return noticeMapper.deleteNoticeByIds(noticeIds); - } -} diff --git a/ruoyi-ui/src/api/system/notice.js b/ruoyi-ui/src/api/system/notice.js index 737fc169d..b8c7cf709 100644 --- a/ruoyi-ui/src/api/system/notice.js +++ b/ruoyi-ui/src/api/system/notice.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询公告列表 export function listNotice(query) { return request({ - url: '/system/notice/list', + url: '/system/notice/page', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listNotice(query) { // 查询公告详细 export function getNotice(noticeId) { return request({ - url: '/system/notice/' + noticeId, + url: '/system/notice/get?id=' + noticeId, method: 'get' }) } @@ -20,7 +20,7 @@ export function getNotice(noticeId) { // 新增公告 export function addNotice(data) { return request({ - url: '/system/notice', + url: '/system/notice/create', method: 'post', data: data }) @@ -29,7 +29,7 @@ export function addNotice(data) { // 修改公告 export function updateNotice(data) { return request({ - url: '/system/notice', + url: '/system/notice/update', method: 'put', data: data }) @@ -38,7 +38,7 @@ export function updateNotice(data) { // 删除公告 export function delNotice(noticeId) { return request({ - url: '/system/notice/' + noticeId, + url: '/system/notice/delete?id=' + noticeId, method: 'delete' }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/utils/dict.js b/ruoyi-ui/src/utils/dict.js index f465106a9..07df5fd8c 100644 --- a/ruoyi-ui/src/utils/dict.js +++ b/ruoyi-ui/src/utils/dict.js @@ -11,6 +11,7 @@ export const DICT_TYPE = { SYS_ROLE_TYPE: 'sys_role_type', SYS_DATA_SCOPE: 'sys_data_scope', SYS_USER_SEX: 'sys_user_sex', + SYS_NOTICE_TYPE: 'sys_notice_type', } /** diff --git a/ruoyi-ui/src/views/system/notice/index.vue b/ruoyi-ui/src/views/system/notice/index.vue index 44bd5ed3e..24105bc0a 100644 --- a/ruoyi-ui/src/views/system/notice/index.vue +++ b/ruoyi-ui/src/views/system/notice/index.vue @@ -1,9 +1,9 @@ \ No newline at end of file + diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java index cc8f2a0fc..f5fa1b2e4 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java @@ -13,7 +13,7 @@ import java.util.Date; public class SysDeptRespVO extends SysDeptBaseVO { @ApiModelProperty(value = "部门编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") private Integer status; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java index 8bba0c82b..fb6f47fef 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; public class SysDeptSimpleRespVO { @ApiModelProperty(value = "部门编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "部门名称", required = true, example = "芋道") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostRespVO.java index f7e249511..fb180681b 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostRespVO.java @@ -13,7 +13,7 @@ import java.util.Date; public class SysPostRespVO extends SysPostBaseVO { @ApiModelProperty(value = "岗位序号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") private Date createTime; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostSimpleRespVO.java index a24299569..312d1b9ec 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostSimpleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostSimpleRespVO.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; public class SysPostSimpleRespVO { @ApiModelProperty(value = "岗位编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "岗位名称", required = true, example = "芋道") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataRespVO.java index 2cad91af4..cb2595c8c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataRespVO.java @@ -17,7 +17,7 @@ import java.util.Date; public class SysDictDataRespVO extends SysDictDataBaseVO { @ApiModelProperty(value = "字典数据编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") private Date createTime; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeRespVO.java index e9c5116b5..d9a5f806b 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeRespVO.java @@ -17,7 +17,7 @@ import java.util.Date; public class SysDictTypeRespVO extends SysDictTypeBaseVO { @ApiModelProperty(value = "字典类型编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "字典类型", required = true, example = "sys_common_sex") private String type; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java index 64c3542e2..cf968ac50 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java @@ -1,64 +1,72 @@ package cn.iocoder.dashboard.modules.system.controller.notice; +import cn.iocoder.dashboard.common.pojo.CommonResult; +import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeRespVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.convert.notice.SysNoticeConvert; +import cn.iocoder.dashboard.modules.system.service.notice.SysNoticeService; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; @Api(tags = "通知公告 API") @RestController @RequestMapping("/system/notice") public class SysNoticeController { -// /** -// * 获取通知公告列表 -// */ + @Resource + private SysNoticeService noticeService; + + @ApiOperation("获取通知公告列表") + @GetMapping("/page") // @PreAuthorize("@ss.hasPermi('system:notice:list')") -// @GetMapping("/list") -// public TableDataInfo list(SysNotice notice) { -// startPage(); -// List list = noticeService.selectNoticeList(notice); -// return getDataTable(list); -// } -// -// /** -// * 根据通知公告编号获取详细信息 -// */ + public CommonResult> pageNotices(@Validated SysNoticePageReqVO reqVO) { + return success(SysNoticeConvert.INSTANCE.convertPage(noticeService.pageNotices(reqVO))); + } + + @ApiOperation("获得通知公告") + @ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class) // @PreAuthorize("@ss.hasPermi('system:notice:query')") -// @GetMapping(value = "/{noticeId}") -// public AjaxResult getInfo(@PathVariable Long noticeId) { -// return AjaxResult.success(noticeService.selectNoticeById(noticeId)); -// } -// -// /** -// * 新增通知公告 -// */ + @GetMapping(value = "/get") + public CommonResult getNotice(@RequestParam("id") Long id) { + return success(SysNoticeConvert.INSTANCE.convert(noticeService.getNotice(id))); + } + + @ApiOperation("新增通知公告") // @PreAuthorize("@ss.hasPermi('system:notice:add')") // @Log(title = "通知公告", businessType = BusinessType.INSERT) -// @PostMapping -// public AjaxResult add(@Validated @RequestBody SysNotice notice) { -// notice.setCreateBy(SecurityUtils.getUsername()); -// return toAjax(noticeService.insertNotice(notice)); -// } -// -// /** -// * 修改通知公告 -// */ + @PostMapping("/create") + public CommonResult createNotice(@Validated @RequestBody SysNoticeCreateReqVO reqVO) { + Long noticeId = noticeService.createNotice(reqVO); + return success(noticeId); + } + + @ApiOperation("修改通知公告") // @PreAuthorize("@ss.hasPermi('system:notice:edit')") // @Log(title = "通知公告", businessType = BusinessType.UPDATE) -// @PutMapping -// public AjaxResult edit(@Validated @RequestBody SysNotice notice) { -// notice.setUpdateBy(SecurityUtils.getUsername()); -// return toAjax(noticeService.updateNotice(notice)); -// } -// -// /** -// * 删除通知公告 -// */ + @PostMapping("/update") + public CommonResult updateNotice(@Validated @RequestBody SysNoticeUpdateReqVO reqVO) { + noticeService.updateNotice(reqVO); + return success(true); + } + + @ApiOperation("删除通知公告") + @ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class) // @PreAuthorize("@ss.hasPermi('system:notice:remove')") // @Log(title = "通知公告", businessType = BusinessType.DELETE) -// @DeleteMapping("/{noticeIds}") -// public AjaxResult remove(@PathVariable Long[] noticeIds) { -// return toAjax(noticeService.deleteNoticeByIds(noticeIds)); -// } + @PostMapping("/delete") + public CommonResult deleteNotice(@RequestParam("id") Long id) { + noticeService.deleteNotice(id); + return success(true); + } } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeBaseVO.java new file mode 100644 index 000000000..5fc4f9017 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeBaseVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.dashboard.modules.system.controller.notice.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * 通知公告 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class SysNoticeBaseVO { + + @ApiModelProperty(value = "公告标题", required = true, example = "小博主") + @NotBlank(message = "公告标题不能为空") + @Size(max = 50, message = "公告标题不能超过50个字符") + private String title; + + @ApiModelProperty(value = "公告标题", required = true, example = "小博主") + @NotNull(message = "公告类型不能为空") + private Integer type; + + @ApiModelProperty(value = "公告内容", required = true, example = "半生编码") + private String content; + + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") + private Integer status; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeCreateReqVO.java new file mode 100644 index 000000000..9cfe3b31f --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeCreateReqVO.java @@ -0,0 +1,12 @@ +package cn.iocoder.dashboard.modules.system.controller.notice.vo; + +import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel("通知公告创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysNoticeCreateReqVO extends SysPostBaseVO { +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticePageReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticePageReqVO.java new file mode 100644 index 000000000..a463bfc0a --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticePageReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.dashboard.modules.system.controller.notice.vo; + +import cn.iocoder.dashboard.common.pojo.PageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel("通知公告分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysNoticePageReqVO extends PageParam { + + @ApiModelProperty(value = "通知公告名称", example = "芋道", notes = "模糊匹配") + private String title; + + @ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类") + private Integer status; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeRespVO.java new file mode 100644 index 000000000..bb917e35f --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.dashboard.modules.system.controller.notice.vo; + +import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +@ApiModel("通知公告信息 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysNoticeRespVO extends SysPostBaseVO { + + @ApiModelProperty(value = "通知公告序号", required = true, example = "1024") + private Long id; + + @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") + private Date createTime; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeUpdateReqVO.java new file mode 100644 index 000000000..b8c82032e --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeUpdateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.dashboard.modules.system.controller.notice.vo; + +import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; + +@ApiModel("岗位公告更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysNoticeUpdateReqVO extends SysPostBaseVO { + + @ApiModelProperty(value = "岗位公告编号", required = true, example = "1024") + @NotNull(message = "岗位公告编号不能为空") + private Long id; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java index ff8c2f0b8..ef1e7acad 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java @@ -17,7 +17,7 @@ import java.util.Date; public class SysMenuRespVO extends SysMenuBaseVO { @ApiModelProperty(value = "菜单编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") private Integer status; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuSimpleRespVO.java index fa0051a71..121afe5d2 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuSimpleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuSimpleRespVO.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; public class SysMenuSimpleRespVO { @ApiModelProperty(value = "菜单编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "菜单名称", required = true, example = "芋道") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java index f65da453d..bb5e3cc0f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java @@ -18,7 +18,7 @@ import java.util.Set; public class SysRoleRespVO extends SysRoleBaseVO { @ApiModelProperty(value = "角色编号", required = true, example = "1") - private Integer id; + private Long id; @ApiModelProperty(value = "数据范围", required = true, example = "1", notes = "参见 DataScopeEnum 枚举类") private Integer dataScope; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleSimpleRespVO.java index b52a6c50c..6ac990c4b 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleSimpleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleSimpleRespVO.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; public class SysRoleSimpleRespVO { @ApiModelProperty(value = "角色编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "角色名称", required = true, example = "芋道") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java index e98b07298..dc6963c58 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java @@ -24,7 +24,7 @@ public class SysUserPageItemRespVO extends SysUserRespVO { public static class Dept { @ApiModelProperty(value = "部门编号", required = true, example = "1") - private Integer id; + private Long id; @ApiModelProperty(value = "部门名称", required = true, example = "研发部") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserRespVO.java index 11a0ec84e..aa995fb92 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserRespVO.java @@ -17,7 +17,7 @@ import java.util.Date; public class SysUserRespVO extends SysUserBaseVO { @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Integer id; + private Long id; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") private Integer status; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java index e5f17649b..30f80b3f7 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java @@ -1,6 +1,13 @@ package cn.iocoder.dashboard.modules.system.convert.notice; +import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeRespVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO; +import com.baomidou.mybatisplus.core.metadata.IPage; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @Mapper @@ -8,4 +15,15 @@ public interface SysNoticeConvert { SysNoticeConvert INSTANCE = Mappers.getMapper(SysNoticeConvert.class); + PageResult convertPage(PageResult page); + + SysNoticeRespVO convert(SysNoticeDO bean); + + SysNoticeDO convert(SysNoticeUpdateReqVO bean); + + SysNoticeDO convert(SysNoticeCreateReqVO bean); + + @Mapping(source = "records", target = "list") + PageResult convertPage02(IPage page); + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java index 131ce3797..1b2470771 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java @@ -1,9 +1,20 @@ package cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice; +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.dashboard.framework.mybatis.core.util.MyBatisUtils; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; @Mapper public interface SysNoticeMapper extends BaseMapper { + + default IPage selectList(SysNoticePageReqVO reqVO) { + return selectPage(MyBatisUtils.buildPage(reqVO), + new QueryWrapperX().likeIfPresent("title", reqVO.getTitle()) + .eqIfPresent("status", reqVO.getStatus())); + } + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java index 626e58acc..e7f157b62 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java @@ -8,9 +8,6 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - /** * 通知公告表 * @@ -28,8 +25,7 @@ public class SysNoticeDO extends BaseDO { /** * 公告标题 */ - @NotBlank(message = "公告标题不能为空") - @Size(max = 50, message = "公告标题不能超过50个字符") + private String title; /** * 公告类型 @@ -37,7 +33,7 @@ public class SysNoticeDO extends BaseDO { * 枚举 {@link SysNoticeTypeEnum} */ @TableField("notice_type") - private String type; + private Integer type; /** * 公告内容 */ diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java index 29bebd751..06a12653a 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java @@ -66,4 +66,7 @@ public interface SysErrorCodeConstants { ErrorCode DICT_DATA_NOT_ENABLE = new ErrorCode(1002007002, "字典数据不处于开启状态,不允许选择"); ErrorCode DICT_DATA_VALUE_DUPLICATE = new ErrorCode(1002007003, "已经存在该值的字典数据"); + // ========== 通知公告 1002008000 ========== + ErrorCode NOTICE_NOT_FOUND = new ErrorCode(1002008001, "当前通知公告不存在"); + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/SysNoticeService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/SysNoticeService.java new file mode 100644 index 000000000..9e4d77c25 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/SysNoticeService.java @@ -0,0 +1,51 @@ +package cn.iocoder.dashboard.modules.system.service.notice; + +import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO; + +/** + * 通知公告 Service 接口 + */ +public interface SysNoticeService { + + /** + * 获得岗位公告公告分页列表 + * + * @param reqVO 分页条件 + * @return 部门分页列表 + */ + PageResult pageNotices(SysNoticePageReqVO reqVO); + + /** + * 获得岗位公告公告信息 + * + * @param id 岗位公告公告编号 + * @return 岗位公告公告信息 + */ + SysNoticeDO getNotice(Long id); + + /** + * 创建岗位公告公告 + * + * @param reqVO 岗位公告公告信息 + * @return 岗位公告公告编号 + */ + Long createNotice(SysNoticeCreateReqVO reqVO); + + /** + * 更新岗位公告公告 + * + * @param reqVO 岗位公告公告信息 + */ + void updateNotice(SysNoticeUpdateReqVO reqVO); + + /** + * 删除岗位公告公告信息 + * + * @param id 岗位公告公告编号 + */ + void deleteNotice(Long id); +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/impl/SysNoticeServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/impl/SysNoticeServiceImpl.java new file mode 100644 index 000000000..04097f7ef --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/notice/impl/SysNoticeServiceImpl.java @@ -0,0 +1,73 @@ +package cn.iocoder.dashboard.modules.system.service.notice.impl; + +import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; +import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert; +import cn.iocoder.dashboard.modules.system.convert.notice.SysNoticeConvert; +import cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice.SysNoticeMapper; +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO; +import cn.iocoder.dashboard.modules.system.service.notice.SysNoticeService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.NOTICE_NOT_FOUND; + +/** + * 通知公告 Service 实现类 + * + * @author 芋道源码 + */ +@Service +public class SysNoticeServiceImpl implements SysNoticeService { + + @Resource + private SysNoticeMapper noticeMapper; + + @Override + public PageResult pageNotices(SysNoticePageReqVO reqVO) { + return SysNoticeConvert.INSTANCE.convertPage02(noticeMapper.selectList(reqVO)); + } + + @Override + public SysNoticeDO getNotice(Long id) { + return noticeMapper.selectById(id); + } + + @Override + public Long createNotice(SysNoticeCreateReqVO reqVO) { + SysNoticeDO notice = SysNoticeConvert.INSTANCE.convert(reqVO); + return notice.getId(); + } + + @Override + public void updateNotice(SysNoticeUpdateReqVO reqVO) { + // 校验是否存在 + this.checkNoticeExists(reqVO.getId()); + // 更新通知公告 + SysNoticeDO updateObj = SysNoticeConvert.INSTANCE.convert(reqVO); + noticeMapper.updateById(updateObj); + } + + @Override + public void deleteNotice(Long id) { + // 校验是否存在 + this.checkNoticeExists(id); + // 删除通知公告 + noticeMapper.deleteById(id); + } + + private void checkNoticeExists(Long id) { + if (id == null) { + return; + } + SysNoticeDO notice = noticeMapper.selectById(id); + if (notice == null) { + throw ServiceExceptionUtil.exception(NOTICE_NOT_FOUND); + } + } + +}