mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
完成岗位的迁移
This commit is contained in:
parent
e4fd022ce1
commit
ba6c879ee1
@ -1,130 +0,0 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
public class SysPostController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysPost post)
|
||||
{
|
||||
startPage();
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysPost post)
|
||||
{
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
return util.exportExcel(list, "岗位数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public AjaxResult getInfo(@PathVariable Long postId)
|
||||
{
|
||||
return AjaxResult.success(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
||||
{
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return AjaxResult.success(posts);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.ruoyi.common.constant;
|
||||
|
||||
/**
|
||||
* 用户常量信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class UserConstants
|
||||
{
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
|
||||
/** 正常状态 */
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/** 异常状态 */
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/** 用户封禁状态 */
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/** 角色封禁状态 */
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/** 部门正常状态 */
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/** 部门停用状态 */
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/** 字典正常状态 */
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/** 是否为系统默认(是) */
|
||||
public static final String YES = "Y";
|
||||
|
||||
/** 是否菜单外链(是) */
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/** 是否菜单外链(否) */
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/** Layout组件标识 */
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/** ParentView组件标识 */
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/** 校验返回结果码 */
|
||||
public final static String UNIQUE = "0";
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.ruoyi.common.core.controller;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
setValue(DateUtils.parseDate(text));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* 请求方式
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum HttpMethod
|
||||
{
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
||||
|
||||
static
|
||||
{
|
||||
for (HttpMethod httpMethod : values())
|
||||
{
|
||||
mappings.put(httpMethod.name(), httpMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HttpMethod resolve(@Nullable String method)
|
||||
{
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
public boolean matches(String method)
|
||||
{
|
||||
return (this == resolve(method));
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import request from '@/utils/request'
|
||||
// 查询岗位列表
|
||||
export function listPost(query) {
|
||||
return request({
|
||||
url: '/system/post/list',
|
||||
url: '/system/post/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
@ -20,7 +20,7 @@ export function listSimplePosts() {
|
||||
// 查询岗位详细
|
||||
export function getPost(postId) {
|
||||
return request({
|
||||
url: '/system/post/' + postId,
|
||||
url: '/system/post/get?id=' + postId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export function getPost(postId) {
|
||||
// 新增岗位
|
||||
export function addPost(data) {
|
||||
return request({
|
||||
url: '/system/post',
|
||||
url: '/system/post/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -37,8 +37,8 @@ export function addPost(data) {
|
||||
// 修改岗位
|
||||
export function updatePost(data) {
|
||||
return request({
|
||||
url: '/system/post',
|
||||
method: 'put',
|
||||
url: '/system/post/update',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -46,8 +46,8 @@ export function updatePost(data) {
|
||||
// 删除岗位
|
||||
export function delPost(postId) {
|
||||
return request({
|
||||
url: '/system/post/' + postId,
|
||||
method: 'delete'
|
||||
url: '/system/post/delete?id=' + postId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ import { listDept, getDept, delDept, addDept, updateDept } from "@/api/system/de
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
import {SysCommonStatusEnum, SysMenuTypeEnum} from '@/utils/constants'
|
||||
import {SysCommonStatusEnum} from '@/utils/constants'
|
||||
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
export default {
|
||||
@ -249,7 +249,7 @@ export default {
|
||||
leader: undefined,
|
||||
phone: undefined,
|
||||
email: undefined,
|
||||
status: "0"
|
||||
status: SysCommonStatusEnum.ENABLE,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
|
@ -1,18 +1,18 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="岗位编码" prop="postCode">
|
||||
<el-form-item label="岗位编码" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.postCode"
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入岗位编码"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="岗位名称" prop="postName">
|
||||
<el-form-item label="岗位名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.postName"
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入岗位名称"
|
||||
clearable
|
||||
size="small"
|
||||
@ -22,10 +22,10 @@
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
v-for="dict in statusDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@ -45,26 +45,6 @@
|
||||
v-hasPermi="['system:post: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:post: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:post:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
@ -77,12 +57,11 @@
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="岗位编号" align="center" prop="postId" />
|
||||
<el-table-column label="岗位编码" align="center" prop="postCode" />
|
||||
<el-table-column label="岗位名称" align="center" prop="postName" />
|
||||
<el-table-column label="岗位排序" align="center" prop="postSort" />
|
||||
<el-table v-loading="loading" :data="postList">
|
||||
<el-table-column label="岗位编号" align="center" prop="id" />
|
||||
<el-table-column label="岗位编码" align="center" prop="code" />
|
||||
<el-table-column label="岗位名称" align="center" prop="name" />
|
||||
<el-table-column label="岗位排序" align="center" prop="sort" />
|
||||
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
@ -108,11 +87,11 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
@ -120,22 +99,22 @@
|
||||
<!-- 添加或修改岗位对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="岗位名称" prop="postName">
|
||||
<el-input v-model="form.postName" placeholder="请输入岗位名称" />
|
||||
<el-form-item label="岗位名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入岗位名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="岗位编码" prop="postCode">
|
||||
<el-input v-model="form.postCode" placeholder="请输入编码名称" />
|
||||
<el-form-item label="岗位编码" prop="code">
|
||||
<el-input v-model="form.code" placeholder="请输入编码名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="岗位顺序" prop="postSort">
|
||||
<el-input-number v-model="form.postSort" controls-position="right" :min="0" />
|
||||
<el-form-item label="岗位顺序" prop="sort">
|
||||
<el-input-number v-model="form.sort" controls-position="right" :min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="岗位状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue"
|
||||
>{{dict.dictLabel}}</el-radio>
|
||||
v-for="dict in statusDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
@ -153,6 +132,9 @@
|
||||
<script>
|
||||
import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post";
|
||||
|
||||
import {SysCommonStatusEnum} from '@/utils/constants'
|
||||
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
export default {
|
||||
name: "Post",
|
||||
data() {
|
||||
@ -179,47 +161,49 @@ export default {
|
||||
statusOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
postCode: undefined,
|
||||
postName: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
status: undefined
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
postName: [
|
||||
name: [
|
||||
{ required: true, message: "岗位名称不能为空", trigger: "blur" }
|
||||
],
|
||||
postCode: [
|
||||
code: [
|
||||
{ required: true, message: "岗位编码不能为空", trigger: "blur" }
|
||||
],
|
||||
postSort: [
|
||||
sort: [
|
||||
{ required: true, message: "岗位顺序不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// 枚举
|
||||
CommonStatusEnum: SysCommonStatusEnum,
|
||||
// 数据字典
|
||||
statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("sys_normal_disable").then(response => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询岗位列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listPost(this.queryParams).then(response => {
|
||||
this.postList = response.rows;
|
||||
this.total = response.total;
|
||||
this.postList = 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)
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
@ -229,18 +213,18 @@ export default {
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
postId: undefined,
|
||||
postCode: undefined,
|
||||
postName: undefined,
|
||||
postSort: 0,
|
||||
status: "0",
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
sort: 0,
|
||||
status: SysCommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
@ -248,12 +232,6 @@ export default {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.postId)
|
||||
this.single = selection.length!=1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
@ -263,8 +241,8 @@ export default {
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const postId = row.postId || this.ids
|
||||
getPost(postId).then(response => {
|
||||
const id = row.id
|
||||
getPost(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改岗位";
|
||||
@ -274,7 +252,7 @@ export default {
|
||||
submitForm: function() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.postId != undefined) {
|
||||
if (this.form.id !== undefined) {
|
||||
updatePost(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
@ -292,13 +270,13 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const postIds = row.postId || this.ids;
|
||||
this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", {
|
||||
const ids = row.id;
|
||||
this.$confirm('是否确认删除岗位编号为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delPost(postIds);
|
||||
return delPost(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
@ -319,4 +297,4 @@ export default {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
@ -2,15 +2,16 @@ package cn.iocoder.dashboard.modules.system.controller.dept;
|
||||
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostSimpleRespVO;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.*;
|
||||
import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
@ -37,4 +38,54 @@ public class SysPostController {
|
||||
return success(SysPostConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
|
||||
@ApiOperation("获得岗位分页列表")
|
||||
@GetMapping("/page")
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
public CommonResult<PageResult<SysPostRespVO>> pagePosts(@Validated SysPostPageReqVO reqVO) {
|
||||
return success(SysPostConvert.INSTANCE.convertPage(postService.pagePosts(reqVO)));
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping("/create")
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
// @Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
public CommonResult<Long> createPost(@Validated @RequestBody SysPostCreateReqVO reqVO) {
|
||||
Long postId = postService.createPost(reqVO);
|
||||
return success(postId);
|
||||
}
|
||||
|
||||
@ApiOperation("修改岗位")
|
||||
@PostMapping("/update")
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
// @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
public CommonResult<Boolean> updatePost(@Validated @RequestBody SysPostUpdateReqVO reqVO) {
|
||||
postService.updatePost(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ApiOperation("删除岗位")
|
||||
@PostMapping("/delete")
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
// @Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
|
||||
postService.deletePost(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ApiOperation("获得岗位信息")
|
||||
@ApiImplicitParam(name = "id", value = "岗位编号", readOnly = true, example = "1024")
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/get")
|
||||
public CommonResult<SysPostRespVO> getPost(@RequestParam("id") Long id) {
|
||||
return success(SysPostConvert.INSTANCE.convert(postService.getPost(id)));
|
||||
}
|
||||
|
||||
// @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
// @GetMapping("/export")
|
||||
// public AjaxResult export(SysPost post) {
|
||||
// List<SysPost> list = postService.selectPostList(post);
|
||||
// ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
// return util.exportExcel(list, "岗位数据");
|
||||
// }
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ public class SysPostBaseVO {
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "快乐的备注")
|
||||
private String remark;
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.dept.vo.post;
|
||||
|
||||
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 SysPostPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "岗位名称", example = "芋道", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -15,9 +15,6 @@ public class SysPostRespVO extends SysPostBaseVO {
|
||||
@ApiModelProperty(value = "岗位序号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
|
@ -14,6 +14,6 @@ public class SysPostUpdateReqVO extends SysPostBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "岗位编号", required = true, example = "1024")
|
||||
@NotNull(message = "岗位编号不能为空")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package cn.iocoder.dashboard.modules.system.convert.dept;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostSimpleRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -14,4 +20,15 @@ public interface SysPostConvert {
|
||||
|
||||
List<SysPostSimpleRespVO> convertList02(List<SysPostDO> list);
|
||||
|
||||
PageResult<SysPostRespVO> convertPage(PageResult<SysPostDO> page);
|
||||
|
||||
SysPostRespVO convert(SysPostDO id);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<SysPostDO> convertPage02(IPage<SysPostDO> page);
|
||||
|
||||
SysPostDO convert(SysPostCreateReqVO bean);
|
||||
|
||||
SysPostDO convert(SysPostUpdateReqVO reqVO);
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept;
|
||||
|
||||
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.dept.vo.post.SysPostPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -16,4 +20,18 @@ public interface SysPostMapper extends BaseMapper<SysPostDO> {
|
||||
.inIfPresent("status", statuses));
|
||||
}
|
||||
|
||||
default IPage<SysPostDO> selectList(SysPostPageReqVO reqVO) {
|
||||
return selectPage(MyBatisUtils.buildPage(reqVO),
|
||||
new QueryWrapperX<SysPostDO>().likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default SysPostDO selectByName(String name) {
|
||||
return selectOne(new QueryWrapper<SysPostDO>().eq("name", name));
|
||||
}
|
||||
|
||||
default SysPostDO selectByCode(String code) {
|
||||
return selectOne(new QueryWrapper<SysPostDO>().eq("code", code));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,5 +51,7 @@ public interface SysErrorCodeConstants {
|
||||
// ========== 岗位模块 1002005000 ==========
|
||||
ErrorCode POST_NOT_FOUND = new ErrorCode(1002005001, "当前岗位不存在");
|
||||
ErrorCode POST_NOT_ENABLE = new ErrorCode(1002005002, "岗位({}) 不处于开启状态,不允许选择");
|
||||
ErrorCode POST_NAME_DUPLICATE = new ErrorCode(1002004001, "已经存在该名字的岗位");
|
||||
ErrorCode POST_CODE_DUPLICATE = new ErrorCode(1002004001, "已经存在该标识的岗位");
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.dept;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -22,4 +26,42 @@ public interface SysPostService {
|
||||
*/
|
||||
List<SysPostDO> listPosts(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
|
||||
|
||||
/**
|
||||
* 获得岗位分页列表
|
||||
*
|
||||
* @param reqVO 分页条件
|
||||
* @return 部门分页列表
|
||||
*/
|
||||
PageResult<SysPostDO> pagePosts(SysPostPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得岗位信息
|
||||
*
|
||||
* @param id 岗位编号
|
||||
* @return 岗位信息
|
||||
*/
|
||||
SysPostDO getPost(Long id);
|
||||
|
||||
/**
|
||||
* 创建岗位
|
||||
*
|
||||
* @param reqVO 岗位信息
|
||||
* @return 岗位编号
|
||||
*/
|
||||
Long createPost(SysPostCreateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 更新岗位
|
||||
*
|
||||
* @param reqVO 岗位信息
|
||||
*/
|
||||
void updatePost(SysPostUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
*
|
||||
* @param id 岗位编号
|
||||
*/
|
||||
void deletePost(Long id);
|
||||
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class SysDeptServiceImpl implements SysDeptService {
|
||||
if (parentId.equals(id)) {
|
||||
throw ServiceExceptionUtil.exception(DEPT_PARENT_ERROR);
|
||||
}
|
||||
// 父菜单不存在
|
||||
// 父岗位不存在
|
||||
SysDeptDO dept = deptMapper.selectById(parentId);
|
||||
if (dept == null) {
|
||||
throw ServiceExceptionUtil.exception(DEPT_PARENT_NOT_EXITS);
|
||||
@ -206,7 +206,7 @@ public class SysDeptServiceImpl implements SysDeptService {
|
||||
if (menu == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的菜单
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
|
||||
if (id == null) {
|
||||
throw ServiceExceptionUtil.exception(DEPT_NAME_DUPLICATE);
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.dept.impl;
|
||||
|
||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept.SysPostMapper;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
|
||||
@ -9,6 +15,8 @@ import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 岗位 Service 实现类
|
||||
*
|
||||
@ -25,4 +33,88 @@ public class SysPostServiceImpl implements SysPostService {
|
||||
return postMapper.selectList(ids, statuses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysPostDO> pagePosts(SysPostPageReqVO reqVO) {
|
||||
return SysPostConvert.INSTANCE.convertPage02(postMapper.selectList(reqVO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysPostDO getPost(Long id) {
|
||||
return postMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createPost(SysPostCreateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
this.checkCreateOrUpdate(null, reqVO.getName(), reqVO.getCode());
|
||||
// 插入岗位
|
||||
SysPostDO post = SysPostConvert.INSTANCE.convert(reqVO);
|
||||
postMapper.insert(post);
|
||||
return post.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePost(SysPostUpdateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
this.checkCreateOrUpdate(reqVO.getId(), reqVO.getName(), reqVO.getCode());
|
||||
// 更新岗位
|
||||
SysPostDO updateObj = SysPostConvert.INSTANCE.convert(reqVO);
|
||||
postMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void checkCreateOrUpdate(Long id, String name, String code) {
|
||||
// 校验自己存在
|
||||
checkPostExists(id);
|
||||
// 校验岗位名的唯一性
|
||||
checkPostNameUnique(id, name);
|
||||
// 校验岗位编码的唯一性
|
||||
checkPostCodeUnique(id, code);
|
||||
}
|
||||
|
||||
private void checkPostNameUnique(Long id, String name) {
|
||||
SysPostDO post = postMapper.selectByName(name);
|
||||
if (post == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
|
||||
if (id == null) {
|
||||
throw ServiceExceptionUtil.exception(POST_NAME_DUPLICATE);
|
||||
}
|
||||
if (!post.getId().equals(id)) {
|
||||
throw ServiceExceptionUtil.exception(POST_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPostCodeUnique(Long id, String code) {
|
||||
SysPostDO post = postMapper.selectByCode(code);
|
||||
if (post == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
|
||||
if (id == null) {
|
||||
throw ServiceExceptionUtil.exception(POST_CODE_DUPLICATE);
|
||||
}
|
||||
if (!post.getId().equals(id)) {
|
||||
throw ServiceExceptionUtil.exception(POST_CODE_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePost(Long id) {
|
||||
// 校验是否存在
|
||||
this.checkPostExists(id);
|
||||
// 删除部门
|
||||
postMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void checkPostExists(Long id) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
SysPostDO post = postMapper.selectById(id);
|
||||
if (post == null) {
|
||||
throw ServiceExceptionUtil.exception(POST_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user