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) { export function listNotice(query) {
return request({ return request({
url: '/system/notice/list', url: '/system/notice/page',
method: 'get', method: 'get',
params: query params: query
}) })
@ -12,7 +12,7 @@ export function listNotice(query) {
// 查询公告详细 // 查询公告详细
export function getNotice(noticeId) { export function getNotice(noticeId) {
return request({ return request({
url: '/system/notice/' + noticeId, url: '/system/notice/get?id=' + noticeId,
method: 'get' method: 'get'
}) })
} }
@ -20,7 +20,7 @@ export function getNotice(noticeId) {
// 新增公告 // 新增公告
export function addNotice(data) { export function addNotice(data) {
return request({ return request({
url: '/system/notice', url: '/system/notice/create',
method: 'post', method: 'post',
data: data data: data
}) })
@ -29,7 +29,7 @@ export function addNotice(data) {
// 修改公告 // 修改公告
export function updateNotice(data) { export function updateNotice(data) {
return request({ return request({
url: '/system/notice', url: '/system/notice/update',
method: 'put', method: 'put',
data: data data: data
}) })
@ -38,7 +38,7 @@ export function updateNotice(data) {
// 删除公告 // 删除公告
export function delNotice(noticeId) { export function delNotice(noticeId) {
return request({ return request({
url: '/system/notice/' + noticeId, url: '/system/notice/delete?id=' + noticeId,
method: 'delete' method: 'delete'
}) })
} }

View File

@ -11,6 +11,7 @@ export const DICT_TYPE = {
SYS_ROLE_TYPE: 'sys_role_type', SYS_ROLE_TYPE: 'sys_role_type',
SYS_DATA_SCOPE: 'sys_data_scope', SYS_DATA_SCOPE: 'sys_data_scope',
SYS_USER_SEX: 'sys_user_sex', SYS_USER_SEX: 'sys_user_sex',
SYS_NOTICE_TYPE: 'sys_notice_type',
} }
/** /**

View File

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

View File

@ -13,7 +13,7 @@ import java.util.Date;
public class SysDeptRespVO extends SysDeptBaseVO { public class SysDeptRespVO extends SysDeptBaseVO {
@ApiModelProperty(value = "部门编号", required = true, example = "1024") @ApiModelProperty(value = "部门编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
private Integer status; private Integer status;

View File

@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
public class SysDeptSimpleRespVO { public class SysDeptSimpleRespVO {
@ApiModelProperty(value = "部门编号", required = true, example = "1024") @ApiModelProperty(value = "部门编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "部门名称", required = true, example = "芋道") @ApiModelProperty(value = "部门名称", required = true, example = "芋道")
private String name; private String name;

View File

@ -13,7 +13,7 @@ import java.util.Date;
public class SysPostRespVO extends SysPostBaseVO { public class SysPostRespVO extends SysPostBaseVO {
@ApiModelProperty(value = "岗位序号", required = true, example = "1024") @ApiModelProperty(value = "岗位序号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime; private Date createTime;

View File

@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
public class SysPostSimpleRespVO { public class SysPostSimpleRespVO {
@ApiModelProperty(value = "岗位编号", required = true, example = "1024") @ApiModelProperty(value = "岗位编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "岗位名称", required = true, example = "芋道") @ApiModelProperty(value = "岗位名称", required = true, example = "芋道")
private String name; private String name;

View File

@ -17,7 +17,7 @@ import java.util.Date;
public class SysDictDataRespVO extends SysDictDataBaseVO { public class SysDictDataRespVO extends SysDictDataBaseVO {
@ApiModelProperty(value = "字典数据编号", required = true, example = "1024") @ApiModelProperty(value = "字典数据编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime; private Date createTime;

View File

@ -17,7 +17,7 @@ import java.util.Date;
public class SysDictTypeRespVO extends SysDictTypeBaseVO { public class SysDictTypeRespVO extends SysDictTypeBaseVO {
@ApiModelProperty(value = "字典类型编号", required = true, example = "1024") @ApiModelProperty(value = "字典类型编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "字典类型", required = true, example = "sys_common_sex") @ApiModelProperty(value = "字典类型", required = true, example = "sys_common_sex")
private String type; private String type;

View File

@ -1,64 +1,72 @@
package cn.iocoder.dashboard.modules.system.controller.notice; 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 io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping; import io.swagger.annotations.ApiImplicitParam;
import org.springframework.web.bind.annotation.RestController; 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") @Api(tags = "通知公告 API")
@RestController @RestController
@RequestMapping("/system/notice") @RequestMapping("/system/notice")
public class SysNoticeController { public class SysNoticeController {
// /** @Resource
// * 获取通知公告列表 private SysNoticeService noticeService;
// */
@ApiOperation("获取通知公告列表")
@GetMapping("/page")
// @PreAuthorize("@ss.hasPermi('system:notice:list')") // @PreAuthorize("@ss.hasPermi('system:notice:list')")
// @GetMapping("/list") public CommonResult<PageResult<SysNoticeRespVO>> pageNotices(@Validated SysNoticePageReqVO reqVO) {
// public TableDataInfo list(SysNotice notice) { return success(SysNoticeConvert.INSTANCE.convertPage(noticeService.pageNotices(reqVO)));
// startPage(); }
// List<SysNotice> list = noticeService.selectNoticeList(notice);
// return getDataTable(list); @ApiOperation("获得通知公告")
// } @ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class)
//
// /**
// * 根据通知公告编号获取详细信息
// */
// @PreAuthorize("@ss.hasPermi('system:notice:query')") // @PreAuthorize("@ss.hasPermi('system:notice:query')")
// @GetMapping(value = "/{noticeId}") @GetMapping(value = "/get")
// public AjaxResult getInfo(@PathVariable Long noticeId) { public CommonResult<SysNoticeRespVO> getNotice(@RequestParam("id") Long id) {
// return AjaxResult.success(noticeService.selectNoticeById(noticeId)); return success(SysNoticeConvert.INSTANCE.convert(noticeService.getNotice(id)));
// } }
//
// /** @ApiOperation("新增通知公告")
// * 新增通知公告
// */
// @PreAuthorize("@ss.hasPermi('system:notice:add')") // @PreAuthorize("@ss.hasPermi('system:notice:add')")
// @Log(title = "通知公告", businessType = BusinessType.INSERT) // @Log(title = "通知公告", businessType = BusinessType.INSERT)
// @PostMapping @PostMapping("/create")
// public AjaxResult add(@Validated @RequestBody SysNotice notice) { public CommonResult<Long> createNotice(@Validated @RequestBody SysNoticeCreateReqVO reqVO) {
// notice.setCreateBy(SecurityUtils.getUsername()); Long noticeId = noticeService.createNotice(reqVO);
// return toAjax(noticeService.insertNotice(notice)); return success(noticeId);
// } }
//
// /** @ApiOperation("修改通知公告")
// * 修改通知公告
// */
// @PreAuthorize("@ss.hasPermi('system:notice:edit')") // @PreAuthorize("@ss.hasPermi('system:notice:edit')")
// @Log(title = "通知公告", businessType = BusinessType.UPDATE) // @Log(title = "通知公告", businessType = BusinessType.UPDATE)
// @PutMapping @PostMapping("/update")
// public AjaxResult edit(@Validated @RequestBody SysNotice notice) { public CommonResult<Boolean> updateNotice(@Validated @RequestBody SysNoticeUpdateReqVO reqVO) {
// notice.setUpdateBy(SecurityUtils.getUsername()); noticeService.updateNotice(reqVO);
// return toAjax(noticeService.updateNotice(notice)); return success(true);
// } }
//
// /** @ApiOperation("删除通知公告")
// * 删除通知公告 @ApiImplicitParam(name = "id", value = "编号", readOnly = true, example = "1024", dataTypeClass = Long.class)
// */
// @PreAuthorize("@ss.hasPermi('system:notice:remove')") // @PreAuthorize("@ss.hasPermi('system:notice:remove')")
// @Log(title = "通知公告", businessType = BusinessType.DELETE) // @Log(title = "通知公告", businessType = BusinessType.DELETE)
// @DeleteMapping("/{noticeIds}") @PostMapping("/delete")
// public AjaxResult remove(@PathVariable Long[] noticeIds) { public CommonResult<Boolean> deleteNotice(@RequestParam("id") Long id) {
// return toAjax(noticeService.deleteNoticeByIds(noticeIds)); 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 { public class SysMenuRespVO extends SysMenuBaseVO {
@ApiModelProperty(value = "菜单编号", required = true, example = "1024") @ApiModelProperty(value = "菜单编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
private Integer status; private Integer status;

View File

@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
public class SysMenuSimpleRespVO { public class SysMenuSimpleRespVO {
@ApiModelProperty(value = "菜单编号", required = true, example = "1024") @ApiModelProperty(value = "菜单编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "菜单名称", required = true, example = "芋道") @ApiModelProperty(value = "菜单名称", required = true, example = "芋道")
private String name; private String name;

View File

@ -18,7 +18,7 @@ import java.util.Set;
public class SysRoleRespVO extends SysRoleBaseVO { public class SysRoleRespVO extends SysRoleBaseVO {
@ApiModelProperty(value = "角色编号", required = true, example = "1") @ApiModelProperty(value = "角色编号", required = true, example = "1")
private Integer id; private Long id;
@ApiModelProperty(value = "数据范围", required = true, example = "1", notes = "参见 DataScopeEnum 枚举类") @ApiModelProperty(value = "数据范围", required = true, example = "1", notes = "参见 DataScopeEnum 枚举类")
private Integer dataScope; private Integer dataScope;

View File

@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
public class SysRoleSimpleRespVO { public class SysRoleSimpleRespVO {
@ApiModelProperty(value = "角色编号", required = true, example = "1024") @ApiModelProperty(value = "角色编号", required = true, example = "1024")
private Integer id; private Long id;
@ApiModelProperty(value = "角色名称", required = true, example = "芋道") @ApiModelProperty(value = "角色名称", required = true, example = "芋道")
private String name; private String name;

View File

@ -24,7 +24,7 @@ public class SysUserPageItemRespVO extends SysUserRespVO {
public static class Dept { public static class Dept {
@ApiModelProperty(value = "部门编号", required = true, example = "1") @ApiModelProperty(value = "部门编号", required = true, example = "1")
private Integer id; private Long id;
@ApiModelProperty(value = "部门名称", required = true, example = "研发部") @ApiModelProperty(value = "部门名称", required = true, example = "研发部")
private String name; private String name;

View File

@ -17,7 +17,7 @@ import java.util.Date;
public class SysUserRespVO extends SysUserBaseVO { public class SysUserRespVO extends SysUserBaseVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1") @ApiModelProperty(value = "用户编号", required = true, example = "1")
private Integer id; private Long id;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
private Integer status; private Integer status;

View File

@ -1,6 +1,13 @@
package cn.iocoder.dashboard.modules.system.convert.notice; 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.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper @Mapper
@ -8,4 +15,15 @@ public interface SysNoticeConvert {
SysNoticeConvert INSTANCE = Mappers.getMapper(SysNoticeConvert.class); 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; 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 cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface SysNoticeMapper extends BaseMapper<SysNoticeDO> { 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.Data;
import lombok.EqualsAndHashCode; 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; private String title;
/** /**
* *
@ -37,7 +33,7 @@ public class SysNoticeDO extends BaseDO {
* {@link SysNoticeTypeEnum} * {@link SysNoticeTypeEnum}
*/ */
@TableField("notice_type") @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_NOT_ENABLE = new ErrorCode(1002007002, "字典数据不处于开启状态,不允许选择");
ErrorCode DICT_DATA_VALUE_DUPLICATE = new ErrorCode(1002007003, "已经存在该值的字典数据"); 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);
}
}
}