新增:新增系统管理/部门管理/查询列表功能,并将所有描述字段名从 notes 调整为 description,将部分前端方法名前缀从 query 调整为 get,以及去除部分冗余代码

This commit is contained in:
2023-01-23 19:00:47 +08:00
parent 6bd6d1eb39
commit bdf8eeb1b4
40 changed files with 820 additions and 42 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.webapi.controller.system;
import java.util.List;
import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.charles7c.cnadmin.common.model.vo.R;
import top.charles7c.cnadmin.system.model.query.DeptQuery;
import top.charles7c.cnadmin.system.model.vo.DeptVO;
import top.charles7c.cnadmin.system.service.DeptService;
/**
* 部门管理 API
*
* @author Charles7c
* @since 2023/1/22 17:50
*/
@Tag(name = "部门管理 API")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/system/dept", produces = MediaType.APPLICATION_JSON_VALUE)
public class DeptController {
private final DeptService deptService;
@Operation(summary = "查询部门列表")
@GetMapping
public R<List<DeptVO>> list(@Validated DeptQuery query) {
List<DeptVO> list = deptService.list(query);
return R.ok(list);
}
}

View File

@@ -1,6 +1,16 @@
-- liquibase formatted sql
-- changeset Charles7c:1
-- 初始化默认用户admin/123456test/123456
-- 初始化默认部门
INSERT IGNORE INTO `sys_dept` VALUES (1, 'Xxx科技有限公司', 0, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (2, '天津总部', 1, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (3, '研发部', 2, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (4, 'UI部', 2, 2, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (5, '测试部', 2, 3, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (6, '运维部', 2, 4, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (7, '研发一组', 3, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (8, '研发二组', 3, 2, NULL, 2, 1, NOW(), 1, NOW());
-- 初始化默认用户admin/admin123test/123456
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '18888888888', 'charles7c@126.com', NULL, NULL, 1, NOW(), 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 0, NULL, NULL, NULL, NULL, 2, NOW(), 1, NOW(), 1, NOW());

View File

@@ -1,6 +1,23 @@
-- liquibase formatted sql
-- changeset Charles7c:1
CREATE TABLE IF NOT EXISTS `sys_dept` (
`dept_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '部门ID',
`dept_name` varchar(255) NOT NULL COMMENT '部门名称',
`parent_id` bigint(20) unsigned DEFAULT 0 COMMENT '上级部门ID',
`dept_sort` int(11) unsigned DEFAULT 999 COMMENT '部门排序',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用',
`create_user` bigint(20) unsigned NOT NULL COMMENT '创建人',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_user` bigint(20) unsigned NOT NULL COMMENT '修改人',
`update_time` datetime NOT NULL COMMENT '修改时间',
PRIMARY KEY (`dept_id`) USING BTREE,
INDEX `idx_parent_id`(`parent_id`) USING BTREE,
INDEX `idx_create_user`(`create_user`) USING BTREE,
INDEX `idx_update_user`(`update_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部门表';
CREATE TABLE IF NOT EXISTS `sys_user` (
`user_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '用户ID',
`username` varchar(255) NOT NULL COMMENT '用户名',
@@ -10,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
`phone` varchar(255) DEFAULT NULL COMMENT '手机号码',
`email` varchar(255) DEFAULT NULL COMMENT '邮箱',
`avatar` varchar(255) DEFAULT NULL COMMENT '头像地址',
`notes` varchar(512) DEFAULT NULL COMMENT '备注',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用',
`pwd_reset_time` datetime DEFAULT NULL COMMENT '最后一次修改密码的时间',
`create_user` bigint(20) unsigned NOT NULL COMMENT '创建人',
@@ -20,8 +37,8 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
PRIMARY KEY (`user_id`) USING BTREE,
UNIQUE INDEX `uk_username`(`username`) USING BTREE,
UNIQUE INDEX `uk_email`(`email`) USING BTREE,
INDEX `idx_createUser`(`create_user`) USING BTREE,
INDEX `idx_updateUser`(`update_user`) USING BTREE
INDEX `idx_create_user`(`create_user`) USING BTREE,
INDEX `idx_update_user`(`update_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
CREATE TABLE IF NOT EXISTS `sys_log` (