1. 基本完成通知模块的迁移

pull/2/head
YunaiV 2021-01-13 09:39:54 +08:00
parent 42a984c8d0
commit 6a36fe65b2
28 changed files with 384 additions and 233 deletions

View File

@ -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<SysNotice> 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);
}
}

View File

@ -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'
})
}
}

View File

@ -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',
}
/**

View File

@ -1,9 +1,9 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公告标题" prop="noticeTitle">
<el-form-item label="公告标题" prop="title">
<el-input
v-model="queryParams.noticeTitle"
v-model="queryParams.title"
placeholder="请输入公告标题"
clearable
size="small"
@ -19,13 +19,13 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="noticeType">
<el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small">
<el-form-item label="类型" prop="type">
<el-select v-model="queryParams.type" placeholder="公告类型" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
v-for="dict in noticeTypeDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
@ -45,42 +45,21 @@
v-hasPermi="['system:notice:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:notice:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:notice:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table v-loading="loading" :data="noticeList">
<el-table-column label="序号" align="center" prop="noticeId" width="100" />
<el-table-column
label="公告标题"
align="center"
prop="noticeTitle"
prop="title"
:show-overflow-tooltip="true"
/>
<el-table-column
label="公告类型"
align="center"
prop="noticeType"
prop="type"
:formatter="typeFormat"
width="100"
/>
@ -120,7 +99,7 @@
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
@ -130,13 +109,13 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入公告标题" />
<el-form-item label="公告标题" prop="title">
<el-input v-model="form.title" placeholder="请输入公告标题" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公告类型" prop="noticeType">
<el-select v-model="form.noticeType" placeholder="请选择">
<el-form-item label="公告类型" prop="type">
<el-select v-model="form.type" placeholder="请选择">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
@ -150,16 +129,16 @@
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
</el-radio-group>
v-for="dict in statusDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192"/>
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
</el-col>
</el-row>
@ -173,9 +152,12 @@
</template>
<script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice } from "@/api/system/notice";
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
import Editor from '@/components/Editor';
import {SysCommonStatusEnum} from '@/utils/constants'
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
export default {
name: "Notice",
components: {
@ -185,12 +167,6 @@ export default {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
@ -207,9 +183,9 @@ export default {
typeOptions: [],
//
queryParams: {
pageNum: 1,
pageNo: 1,
pageSize: 10,
noticeTitle: undefined,
title: undefined,
createBy: undefined,
status: undefined
},
@ -217,41 +193,41 @@ export default {
form: {},
//
rules: {
noticeTitle: [
title: [
{ required: true, message: "公告标题不能为空", trigger: "blur" }
],
noticeType: [
type: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
}
},
//
CommonStatusEnum: SysCommonStatusEnum,
//
noticeTypeDictDatas: getDictDatas(DICT_TYPE.SYS_NOTICE_TYPE),
statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)
};
},
created() {
this.getList();
this.getDicts("sys_notice_status").then(response => {
this.statusOptions = response.data;
});
this.getDicts("sys_notice_type").then(response => {
this.typeOptions = response.data;
});
},
methods: {
/** 查询公告列表 */
getList() {
this.loading = true;
listNotice(this.queryParams).then(response => {
this.noticeList = response.rows;
this.total = response.total;
this.noticeList = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
//
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status);
return getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, row.status)
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.noticeType);
return getDictDataLabel(DICT_TYPE.SYS_NOTICE_TYPE, row.status)
},
//
cancel() {
@ -262,16 +238,16 @@ export default {
reset() {
this.form = {
noticeId: undefined,
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
status: "0"
title: undefined,
type: undefined,
content: undefined,
status: SysCommonStatusEnum.ENABLE
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
@ -279,12 +255,6 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
@ -305,7 +275,7 @@ export default {
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.noticeId != undefined) {
if (this.form.noticeId !== undefined) {
updateNotice(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
@ -337,4 +307,4 @@ export default {
}
}
};
</script>
</script>

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<SysNotice> list = noticeService.selectNoticeList(notice);
// return getDataTable(list);
// }
//
// /**
// * 根据通知公告编号获取详细信息
// */
public CommonResult<PageResult<SysNoticeRespVO>> 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<SysNoticeRespVO> 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<Long> 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<Boolean> 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<Boolean> deleteNotice(@RequestParam("id") Long id) {
noticeService.deleteNotice(id);
return success(true);
}
}

View File

@ -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;
}

View File

@ -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 {
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<SysNoticeRespVO> convertPage(PageResult<SysNoticeDO> page);
SysNoticeRespVO convert(SysNoticeDO bean);
SysNoticeDO convert(SysNoticeUpdateReqVO bean);
SysNoticeDO convert(SysNoticeCreateReqVO bean);
@Mapping(source = "records", target = "list")
PageResult<SysNoticeDO> convertPage02(IPage<SysNoticeDO> page);
}

View File

@ -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<SysNoticeDO> {
default IPage<SysNoticeDO> selectList(SysNoticePageReqVO reqVO) {
return selectPage(MyBatisUtils.buildPage(reqVO),
new QueryWrapperX<SysNoticeDO>().likeIfPresent("title", reqVO.getTitle())
.eqIfPresent("status", reqVO.getStatus()));
}
}

View File

@ -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;
/**
*
*/

View File

@ -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, "当前通知公告不存在");
}

View File

@ -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<SysNoticeDO> 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);
}

View File

@ -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<SysNoticeDO> 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);
}
}
}