Commit 04feb57ed8a6915a1cc15be32b0cf98078b739e9
1 parent
6edd4d7e
初始化 dept 部门模块
Showing
12 changed files
with
157 additions
and
81 deletions
ruoyi-ui/src/api/system/dept.js
| @@ -26,6 +26,7 @@ export function getDept(deptId) { | @@ -26,6 +26,7 @@ export function getDept(deptId) { | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | // 查询部门下拉树结构 | 28 | // 查询部门下拉树结构 |
| 29 | +// TODO 准备删除 | ||
| 29 | export function treeselect() { | 30 | export function treeselect() { |
| 30 | return request({ | 31 | return request({ |
| 31 | url: '/system/dept/treeselect', | 32 | url: '/system/dept/treeselect', |
| @@ -34,6 +35,7 @@ export function treeselect() { | @@ -34,6 +35,7 @@ export function treeselect() { | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | // 根据角色ID查询部门树结构 | 37 | // 根据角色ID查询部门树结构 |
| 38 | +// TODO 准备删除 | ||
| 37 | export function roleDeptTreeselect(roleId) { | 39 | export function roleDeptTreeselect(roleId) { |
| 38 | return request({ | 40 | return request({ |
| 39 | url: '/system/dept/roleDeptTreeselect/' + roleId, | 41 | url: '/system/dept/roleDeptTreeselect/' + roleId, |
| @@ -41,6 +43,14 @@ export function roleDeptTreeselect(roleId) { | @@ -41,6 +43,14 @@ export function roleDeptTreeselect(roleId) { | ||
| 41 | }) | 43 | }) |
| 42 | } | 44 | } |
| 43 | 45 | ||
| 46 | +// 获取部门精简信息列表 | ||
| 47 | +export function listSimpleDepts() { | ||
| 48 | + return request({ | ||
| 49 | + url: '/system/dept/list-all-simple', | ||
| 50 | + method: 'get' | ||
| 51 | + }) | ||
| 52 | +} | ||
| 53 | + | ||
| 44 | // 新增部门 | 54 | // 新增部门 |
| 45 | export function addDept(data) { | 55 | export function addDept(data) { |
| 46 | return request({ | 56 | return request({ |
| @@ -65,4 +75,4 @@ export function delDept(deptId) { | @@ -65,4 +75,4 @@ export function delDept(deptId) { | ||
| 65 | url: '/system/dept/' + deptId, | 75 | url: '/system/dept/' + deptId, |
| 66 | method: 'delete' | 76 | method: 'delete' |
| 67 | }) | 77 | }) |
| 68 | -} | ||
| 69 | \ No newline at end of file | 78 | \ No newline at end of file |
| 79 | +} |
ruoyi-ui/src/utils/constants.js
| @@ -24,7 +24,18 @@ export const SysMenuTypeEnum = { | @@ -24,7 +24,18 @@ export const SysMenuTypeEnum = { | ||
| 24 | /** | 24 | /** |
| 25 | * 角色的类型枚举 | 25 | * 角色的类型枚举 |
| 26 | */ | 26 | */ |
| 27 | -export const RoleTypeEnum = { | 27 | +export const SysRoleTypeEnum = { |
| 28 | SYSTEM: 1, // 内置角色 | 28 | SYSTEM: 1, // 内置角色 |
| 29 | CUSTOM: 2 // 自定义角色 | 29 | CUSTOM: 2 // 自定义角色 |
| 30 | } | 30 | } |
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * 数据权限的泛微枚举 | ||
| 34 | + */ | ||
| 35 | +export const SysDataScopeEnum = { | ||
| 36 | + ALL: 1, // 全部数据权限 | ||
| 37 | + DEPT_CUSTOM: 2, // 指定部门数据权限 | ||
| 38 | + DEPT_ONLY: 3, // 部门数据权限 | ||
| 39 | + DEPT_AND_CHILD: 4, // 部门及以下数据权限 | ||
| 40 | + DEPT_SELF: 5 // 仅本人数据权限 | ||
| 41 | +} |
ruoyi-ui/src/utils/dict.js
| @@ -9,6 +9,7 @@ export const DICT_TYPE = { | @@ -9,6 +9,7 @@ export const DICT_TYPE = { | ||
| 9 | SYS_COMMON_STATUS: 'sys_common_status', | 9 | SYS_COMMON_STATUS: 'sys_common_status', |
| 10 | SYS_MENU_TYPE: 'sys_menu_type', | 10 | SYS_MENU_TYPE: 'sys_menu_type', |
| 11 | SYS_ROLE_TYPE: 'sys_role_type', | 11 | SYS_ROLE_TYPE: 'sys_role_type', |
| 12 | + SYS_DATA_SCOPE: 'sys_data_scope', | ||
| 12 | } | 13 | } |
| 13 | 14 | ||
| 14 | /** | 15 | /** |
ruoyi-ui/src/views/system/role/index.vue
| @@ -163,7 +163,7 @@ | @@ -163,7 +163,7 @@ | ||
| 163 | </el-dialog> | 163 | </el-dialog> |
| 164 | 164 | ||
| 165 | <!-- 分配角色的数据权限对话框 --> | 165 | <!-- 分配角色的数据权限对话框 --> |
| 166 | - <el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body> | 166 | + <el-dialog title="分配数据权限" :visible.sync="openDataScope" width="500px" append-to-body> |
| 167 | <el-form :model="form" label-width="80px"> | 167 | <el-form :model="form" label-width="80px"> |
| 168 | <el-form-item label="角色名称"> | 168 | <el-form-item label="角色名称"> |
| 169 | <el-input v-model="form.name" :disabled="true" /> | 169 | <el-input v-model="form.name" :disabled="true" /> |
| @@ -174,15 +174,15 @@ | @@ -174,15 +174,15 @@ | ||
| 174 | <el-form-item label="权限范围"> | 174 | <el-form-item label="权限范围"> |
| 175 | <el-select v-model="form.dataScope"> | 175 | <el-select v-model="form.dataScope"> |
| 176 | <el-option | 176 | <el-option |
| 177 | - v-for="item in dataScopeOptions" | ||
| 178 | - :key="item.value" | 177 | + v-for="item in dataScopeDictDatas" |
| 178 | + :key="parseInt(item.value)" | ||
| 179 | :label="item.label" | 179 | :label="item.label" |
| 180 | - :value="item.value" | 180 | + :value="parseInt(item.value)" |
| 181 | ></el-option> | 181 | ></el-option> |
| 182 | </el-select> | 182 | </el-select> |
| 183 | </el-form-item> | 183 | </el-form-item> |
| 184 | - <el-form-item label="数据权限" v-show="form.dataScope == 2"> | ||
| 185 | - <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox> | 184 | + <el-form-item label="数据权限" v-show="form.dataScope === SysDataScopeEnum.DEPT_CUSTOM"> |
| 185 | + <el-checkbox v-model="!form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动(选中父节点,自动选择子节点)</el-checkbox> | ||
| 186 | <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox> | 186 | <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox> |
| 187 | <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox> | 187 | <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox> |
| 188 | <el-tree | 188 | <el-tree |
| @@ -237,11 +237,20 @@ | @@ -237,11 +237,20 @@ | ||
| 237 | </template> | 237 | </template> |
| 238 | 238 | ||
| 239 | <script> | 239 | <script> |
| 240 | -import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role"; | ||
| 241 | -import { listSimpleMenus } from "@/api/system/menu"; | ||
| 242 | -import { listRoleMenus, assignRoleMenu } from "@/api/system/permission"; | ||
| 243 | -import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; | ||
| 244 | -import {SysCommonStatusEnum, SysMenuTypeEnum} from "@/utils/constants"; | 240 | +import { |
| 241 | + addRole, | ||
| 242 | + changeRoleStatus, | ||
| 243 | + dataScope, | ||
| 244 | + delRole, | ||
| 245 | + exportRole, | ||
| 246 | + getRole, | ||
| 247 | + listRole, | ||
| 248 | + updateRole | ||
| 249 | +} from "@/api/system/role"; | ||
| 250 | +import {listSimpleMenus} from "@/api/system/menu"; | ||
| 251 | +import {assignRoleMenu, listRoleMenus} from "@/api/system/permission"; | ||
| 252 | +import {listSimpleDepts, treeselect as deptTreeselect} from "@/api/system/dept"; | ||
| 253 | +import {SysCommonStatusEnum, SysDataScopeEnum} from "@/utils/constants"; | ||
| 245 | import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict"; | 254 | import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict"; |
| 246 | 255 | ||
| 247 | export default { | 256 | export default { |
| @@ -264,38 +273,12 @@ export default { | @@ -264,38 +273,12 @@ export default { | ||
| 264 | openDataScope: false, | 273 | openDataScope: false, |
| 265 | // 是否显示弹出层(菜单权限) | 274 | // 是否显示弹出层(菜单权限) |
| 266 | openMenu: false, | 275 | openMenu: false, |
| 267 | - // TODO 需要简化下 | ||
| 268 | menuExpand: false, | 276 | menuExpand: false, |
| 269 | menuNodeAll: false, | 277 | menuNodeAll: false, |
| 270 | deptExpand: true, | 278 | deptExpand: true, |
| 271 | deptNodeAll: false, | 279 | deptNodeAll: false, |
| 272 | // 日期范围 | 280 | // 日期范围 |
| 273 | dateRange: [], | 281 | dateRange: [], |
| 274 | - // 状态数据字典 | ||
| 275 | - statusOptions: [], | ||
| 276 | - // 数据范围选项 | ||
| 277 | - dataScopeOptions: [ | ||
| 278 | - { | ||
| 279 | - value: "1", | ||
| 280 | - label: "全部数据权限" | ||
| 281 | - }, | ||
| 282 | - { | ||
| 283 | - value: "2", | ||
| 284 | - label: "自定数据权限" | ||
| 285 | - }, | ||
| 286 | - { | ||
| 287 | - value: "3", | ||
| 288 | - label: "本部门数据权限" | ||
| 289 | - }, | ||
| 290 | - { | ||
| 291 | - value: "4", | ||
| 292 | - label: "本部门及以下数据权限" | ||
| 293 | - }, | ||
| 294 | - { | ||
| 295 | - value: "5", | ||
| 296 | - label: "仅本人数据权限" | ||
| 297 | - } | ||
| 298 | - ], | ||
| 299 | // 菜单列表 | 282 | // 菜单列表 |
| 300 | menuOptions: [], | 283 | menuOptions: [], |
| 301 | // 部门列表 | 284 | // 部门列表 |
| @@ -328,10 +311,12 @@ export default { | @@ -328,10 +311,12 @@ export default { | ||
| 328 | }, | 311 | }, |
| 329 | 312 | ||
| 330 | // 枚举 | 313 | // 枚举 |
| 331 | - CommonStatusEnum: SysCommonStatusEnum, | 314 | + SysCommonStatusEnum: SysCommonStatusEnum, |
| 315 | + SysDataScopeEnum: SysDataScopeEnum, | ||
| 332 | // 数据字典 | 316 | // 数据字典 |
| 333 | roleTypeDictDatas: getDictDatas(DICT_TYPE.SYS_ROLE_TYPE), | 317 | roleTypeDictDatas: getDictDatas(DICT_TYPE.SYS_ROLE_TYPE), |
| 334 | - statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS) | 318 | + statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS), |
| 319 | + dataScopeDictDatas: getDictDatas(DICT_TYPE.SYS_DATA_SCOPE) | ||
| 335 | }; | 320 | }; |
| 336 | }, | 321 | }, |
| 337 | created() { | 322 | created() { |
| @@ -349,28 +334,6 @@ export default { | @@ -349,28 +334,6 @@ export default { | ||
| 349 | } | 334 | } |
| 350 | ); | 335 | ); |
| 351 | }, | 336 | }, |
| 352 | - /** 查询部门树结构 */ | ||
| 353 | - getDeptTreeselect() { | ||
| 354 | - deptTreeselect().then(response => { | ||
| 355 | - this.deptOptions = response.data; | ||
| 356 | - }); | ||
| 357 | - }, | ||
| 358 | - // 所有部门节点数据 | ||
| 359 | - getDeptAllCheckedKeys() { | ||
| 360 | - // 目前被选中的部门节点 | ||
| 361 | - let checkedKeys = this.$refs.dept.getCheckedKeys(); | ||
| 362 | - // 半选中的部门节点 | ||
| 363 | - let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys(); | ||
| 364 | - checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); | ||
| 365 | - return checkedKeys; | ||
| 366 | - }, | ||
| 367 | - /** 根据角色ID查询部门树结构 */ | ||
| 368 | - getRoleDeptTreeselect(id) { | ||
| 369 | - return roleDeptTreeselect(id).then(response => { | ||
| 370 | - this.deptOptions = response.depts; | ||
| 371 | - return response; | ||
| 372 | - }); | ||
| 373 | - }, | ||
| 374 | // 角色状态修改 | 337 | // 角色状态修改 |
| 375 | handleStatusChange(row) { | 338 | handleStatusChange(row) { |
| 376 | // 此时,row 已经变成目标状态了,所以可以直接提交请求和提示 | 339 | // 此时,row 已经变成目标状态了,所以可以直接提交请求和提示 |
| @@ -511,16 +474,22 @@ export default { | @@ -511,16 +474,22 @@ export default { | ||
| 511 | /** 分配数据权限操作 */ | 474 | /** 分配数据权限操作 */ |
| 512 | handleDataScope(row) { | 475 | handleDataScope(row) { |
| 513 | this.reset(); | 476 | this.reset(); |
| 514 | - const roleDeptTreeselect = this.getRoleDeptTreeselect(row.id); | 477 | + // 处理了 form 的角色 name 和 code 的展示 |
| 478 | + this.form.id = row.id; | ||
| 479 | + this.form.name = row.name; | ||
| 480 | + this.form.code = row.code; | ||
| 481 | + // 打开弹窗 | ||
| 482 | + this.openDataScope = true; | ||
| 483 | + // 获得部门列表 | ||
| 484 | + listSimpleDepts().then(response => { | ||
| 485 | + // 处理 menuOptions 参数 | ||
| 486 | + this.deptOptions = []; | ||
| 487 | + this.deptOptions.push(...this.handleTree(response.data, "id")); | ||
| 488 | + }); | ||
| 489 | + // 获得角色拥有的数据权限 | ||
| 515 | getRole(row.id).then(response => { | 490 | getRole(row.id).then(response => { |
| 516 | - this.form = response.data; | ||
| 517 | - this.openDataScope = true; | ||
| 518 | - this.$nextTick(() => { | ||
| 519 | - roleDeptTreeselect.then(res => { | ||
| 520 | - this.$refs.dept.setCheckedKeys(res.checkedKeys); | ||
| 521 | - }); | ||
| 522 | - }); | ||
| 523 | - this.title = "分配数据权限"; | 491 | + // TODO 搞一搞 |
| 492 | + // this.$refs.dept.setCheckedKeys(res.checkedKeys); | ||
| 524 | }); | 493 | }); |
| 525 | }, | 494 | }, |
| 526 | /** 提交按钮 */ | 495 | /** 提交按钮 */ |
| @@ -546,8 +515,13 @@ export default { | @@ -546,8 +515,13 @@ export default { | ||
| 546 | /** 提交按钮(数据权限) */ | 515 | /** 提交按钮(数据权限) */ |
| 547 | submitDataScope: function() { | 516 | submitDataScope: function() { |
| 548 | if (this.form.id !== undefined) { | 517 | if (this.form.id !== undefined) { |
| 549 | - this.form.deptIds = this.getDeptAllCheckedKeys(); | ||
| 550 | - dataScope(this.form).then(response => { | 518 | + // this.form.deptIds = this.getDeptAllCheckedKeys(); |
| 519 | + debugger | ||
| 520 | + dataScope({ | ||
| 521 | + roleId: this.form.id, | ||
| 522 | + deptIds: this.form.dataScope !== SysDataScopeEnum.DEPT_CUSTOM ? [] : | ||
| 523 | + this.$refs.dept.getCheckedKeys(false) | ||
| 524 | + }).then(response => { | ||
| 551 | this.msgSuccess("修改成功"); | 525 | this.msgSuccess("修改成功"); |
| 552 | this.openDataScope = false; | 526 | this.openDataScope = false; |
| 553 | this.getList(); | 527 | this.getList(); |
| @@ -556,7 +530,6 @@ export default { | @@ -556,7 +530,6 @@ export default { | ||
| 556 | }, | 530 | }, |
| 557 | /** 提交按钮(菜单权限) */ | 531 | /** 提交按钮(菜单权限) */ |
| 558 | submitMenu: function() { | 532 | submitMenu: function() { |
| 559 | - // TODO 需要改动下 | ||
| 560 | if (this.form.id !== undefined) { | 533 | if (this.form.id !== undefined) { |
| 561 | assignRoleMenu({ | 534 | assignRoleMenu({ |
| 562 | roleId: this.form.id, | 535 | roleId: this.form.id, |
src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java
| 1 | package cn.iocoder.dashboard.modules.system.controller.dept; | 1 | package cn.iocoder.dashboard.modules.system.controller.dept; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | ||
| 5 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO; | ||
| 6 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptRespVO; | ||
| 7 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptSimpleRespVO; | ||
| 8 | +import cn.iocoder.dashboard.modules.system.convert.dept.SysDeptConvert; | ||
| 9 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | ||
| 10 | +import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService; | ||
| 3 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 12 | +import io.swagger.annotations.ApiOperation; | ||
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 4 | import org.springframework.web.bind.annotation.RequestMapping; | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 5 | import org.springframework.web.bind.annotation.RestController; | 15 | import org.springframework.web.bind.annotation.RestController; |
| 6 | 16 | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import java.util.Comparator; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 7 | @Api(tags = "部门 API") | 23 | @Api(tags = "部门 API") |
| 8 | @RestController | 24 | @RestController |
| 9 | @RequestMapping("/system/dept") | 25 | @RequestMapping("/system/dept") |
| 10 | public class SysDeptController { | 26 | public class SysDeptController { |
| 11 | 27 | ||
| 28 | + @Resource | ||
| 29 | + private SysDeptService sysDeptService; | ||
| 30 | + | ||
| 31 | + @ApiOperation("获取部门列表") | ||
| 32 | +// @PreAuthorize("@ss.hasPermi('system:dept:list')") | ||
| 33 | + @GetMapping("/list") | ||
| 34 | + public CommonResult<List<SysDeptRespVO>> listDepts(SysDeptListReqVO reqVO) { | ||
| 35 | + List<SysDeptDO> list = sysDeptService.listDepts(reqVO); | ||
| 36 | + list.sort(Comparator.comparing(SysDeptDO::getSort)); | ||
| 37 | + return success(SysDeptConvert.INSTANCE.convertList(list)); | ||
| 38 | + } | ||
| 12 | 39 | ||
| 40 | + @ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项") | ||
| 41 | + @GetMapping("/list-all-simple") | ||
| 42 | + public CommonResult<List<SysDeptSimpleRespVO>> listSimpleDepts() { | ||
| 43 | + // 获得部门列表,只要开启状态的 | ||
| 44 | + SysDeptListReqVO reqVO = new SysDeptListReqVO(); | ||
| 45 | + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 46 | + List<SysDeptDO> list = sysDeptService.listDepts(reqVO); | ||
| 47 | + // 排序后,返回个诶前端 | ||
| 48 | + list.sort(Comparator.comparing(SysDeptDO::getSort)); | ||
| 49 | + return success(SysDeptConvert.INSTANCE.convertList02(list)); | ||
| 50 | + } | ||
| 13 | 51 | ||
| 14 | } | 52 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleBaseVO.java
| @@ -27,7 +27,7 @@ public class SysRoleBaseVO { | @@ -27,7 +27,7 @@ public class SysRoleBaseVO { | ||
| 27 | @NotBlank(message = "显示顺序不能为空") | 27 | @NotBlank(message = "显示顺序不能为空") |
| 28 | private String sort; | 28 | private String sort; |
| 29 | 29 | ||
| 30 | - @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 RoleTypeEnum 枚举") | 30 | + @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 SysRoleTypeEnum 枚举") |
| 31 | private Integer type; | 31 | private Integer type; |
| 32 | 32 | ||
| 33 | @ApiModelProperty(value = "备注", example = "我是一个角色") | 33 | @ApiModelProperty(value = "备注", example = "我是一个角色") |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java
| @@ -25,7 +25,7 @@ public class SysRoleRespVO extends SysRoleBaseVO { | @@ -25,7 +25,7 @@ public class SysRoleRespVO extends SysRoleBaseVO { | ||
| 25 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") | 25 | @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") |
| 26 | private Integer status; | 26 | private Integer status; |
| 27 | 27 | ||
| 28 | - @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "参见 RoleTypeEnum 枚举类") | 28 | + @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "参见 SysRoleTypeEnum 枚举类") |
| 29 | private Integer type; | 29 | private Integer type; |
| 30 | 30 | ||
| 31 | @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") | 31 | @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleUpdateStatusReqVO.java
| @@ -14,9 +14,9 @@ public class SysRoleUpdateStatusReqVO { | @@ -14,9 +14,9 @@ public class SysRoleUpdateStatusReqVO { | ||
| 14 | @NotNull(message = "角色编号不能为空") | 14 | @NotNull(message = "角色编号不能为空") |
| 15 | private Long id; | 15 | private Long id; |
| 16 | 16 | ||
| 17 | - @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") | 17 | + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举") |
| 18 | @NotNull(message = "状态不能为空") | 18 | @NotNull(message = "状态不能为空") |
| 19 | -// @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") | 19 | +// @InEnum(value = SysCommonStatusEnum.class, message = "修改状态必须是 {value}") |
| 20 | private Integer status; | 20 | private Integer status; |
| 21 | 21 | ||
| 22 | } | 22 | } |
src/main/java/cn/iocoder/dashboard/modules/system/convert/dept/SysDeptConvert.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.convert.dept; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptRespVO; | ||
| 4 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptSimpleRespVO; | ||
| 5 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | ||
| 6 | +import org.mapstruct.Mapper; | ||
| 7 | +import org.mapstruct.factory.Mappers; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Mapper | ||
| 12 | +public interface SysDeptConvert { | ||
| 13 | + | ||
| 14 | + SysDeptConvert INSTANCE = Mappers.getMapper(SysDeptConvert.class); | ||
| 15 | + | ||
| 16 | + List<SysDeptRespVO> convertList(List<SysDeptDO> list); | ||
| 17 | + | ||
| 18 | + List<SysDeptSimpleRespVO> convertList02(List<SysDeptDO> list); | ||
| 19 | + | ||
| 20 | +} |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dept/SysDeptMapper.java
| 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept; | 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | ||
| 4 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO; | ||
| 3 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | 5 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; |
| 6 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 7 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | ||
| @@ -10,7 +13,12 @@ import java.util.List; | @@ -10,7 +13,12 @@ import java.util.List; | ||
| 10 | public interface SysDeptMapper extends BaseMapper<SysDeptDO> { | 13 | public interface SysDeptMapper extends BaseMapper<SysDeptDO> { |
| 11 | 14 | ||
| 12 | default List<SysDeptDO> selectList() { | 15 | default List<SysDeptDO> selectList() { |
| 13 | - return selectList(null); | 16 | + return selectList(new QueryWrapper<>()); |
| 17 | + } | ||
| 18 | + | ||
| 19 | + default List<SysDeptDO> selectList(SysDeptListReqVO reqVO) { | ||
| 20 | + return selectList(new QueryWrapperX<SysDeptDO>().likeIfPresent("name", reqVO.getName()) | ||
| 21 | + .eqIfPresent("status", reqVO.getStatus())); | ||
| 14 | } | 22 | } |
| 15 | 23 | ||
| 16 | } | 24 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java
| 1 | package cn.iocoder.dashboard.modules.system.service.dept; | 1 | package cn.iocoder.dashboard.modules.system.service.dept; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO; | ||
| 3 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | 4 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; |
| 4 | 5 | ||
| 5 | import java.util.List; | 6 | import java.util.List; |
| @@ -14,8 +15,16 @@ public interface SysDeptService { | @@ -14,8 +15,16 @@ public interface SysDeptService { | ||
| 14 | /** | 15 | /** |
| 15 | * 获得所有部门列表 | 16 | * 获得所有部门列表 |
| 16 | * | 17 | * |
| 17 | - * @return 菜单列表 | 18 | + * @return 部门列表 |
| 18 | */ | 19 | */ |
| 19 | List<SysDeptDO> listDepts(); | 20 | List<SysDeptDO> listDepts(); |
| 20 | 21 | ||
| 22 | + /** | ||
| 23 | + * 筛选部门列表 | ||
| 24 | + * | ||
| 25 | + * @param reqVO 筛选条件请求 VO | ||
| 26 | + * @return 部门列表 | ||
| 27 | + */ | ||
| 28 | + List<SysDeptDO> listDepts(SysDeptListReqVO reqVO); | ||
| 29 | + | ||
| 21 | } | 30 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java
| 1 | package cn.iocoder.dashboard.modules.system.service.dept.impl; | 1 | package cn.iocoder.dashboard.modules.system.service.dept.impl; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO; | ||
| 3 | import cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept.SysDeptMapper; | 4 | import cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept.SysDeptMapper; |
| 4 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | 5 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; |
| 5 | import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService; | 6 | import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService; |
| @@ -24,4 +25,9 @@ public class SysDeptServiceImpl implements SysDeptService { | @@ -24,4 +25,9 @@ public class SysDeptServiceImpl implements SysDeptService { | ||
| 24 | return deptMapper.selectList(); | 25 | return deptMapper.selectList(); |
| 25 | } | 26 | } |
| 26 | 27 | ||
| 28 | + @Override | ||
| 29 | + public List<SysDeptDO> listDepts(SysDeptListReqVO reqVO) { | ||
| 30 | + return deptMapper.selectList(reqVO); | ||
| 31 | + } | ||
| 32 | + | ||
| 27 | } | 33 | } |