diff --git a/db/mysql.sql b/db/mysql.sql index 90dee9c..d66dd4e 100644 --- a/db/mysql.sql +++ b/db/mysql.sql @@ -5,7 +5,7 @@ CREATE TABLE sys_user password varchar(100) COMMENT '密码', real_name varchar(50) COMMENT '姓名', avatar varchar(200) COMMENT '头像', - gender tinyint COMMENT '性别 0:男 1:女', + gender tinyint COMMENT '性别 0:男 1:女 2:未知', email varchar(100) COMMENT '邮箱', mobile varchar(20) COMMENT '手机号', org_id bigint COMMENT '机构ID', @@ -18,7 +18,7 @@ CREATE TABLE sys_user updater bigint COMMENT '更新者', update_time datetime COMMENT '更新时间', primary key (id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARSET = utf8mb4 COMMENT ='用户管理'; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='用户管理'; CREATE TABLE sys_org ( @@ -34,7 +34,7 @@ CREATE TABLE sys_org update_time datetime COMMENT '更新时间', primary key (id), key idx_pid (pid) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARSET = utf8mb4 COMMENT ='机构管理'; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='机构管理'; create table sys_role ( @@ -51,7 +51,7 @@ create table sys_role update_time datetime COMMENT '更新时间', primary key (id), key idx_org_id (org_id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色管理'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色管理'; create table sys_user_role ( @@ -67,7 +67,7 @@ create table sys_user_role primary key (id), key idx_role_id (role_id), key idx_user_id (user_id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='用户角色关系'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='用户角色关系'; CREATE TABLE sys_post ( @@ -83,7 +83,7 @@ CREATE TABLE sys_post updater bigint COMMENT '更新者', update_time datetime COMMENT '更新时间', primary key (id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='岗位管理'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='岗位管理'; CREATE TABLE sys_user_post ( @@ -99,7 +99,7 @@ CREATE TABLE sys_user_post primary key (id), key idx_user_id (user_id), key idx_post_id (post_id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='用户岗位关系'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='用户岗位关系'; create table sys_menu ( @@ -120,7 +120,7 @@ create table sys_menu update_time datetime COMMENT '更新时间', primary key (id), key idx_pid (pid) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='菜单管理'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='菜单管理'; create table sys_role_menu ( @@ -136,7 +136,7 @@ create table sys_role_menu primary key (id), key idx_role_id (role_id), key idx_menu_id (menu_id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色菜单关系'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色菜单关系'; create table sys_role_data_scope ( @@ -151,7 +151,7 @@ create table sys_role_data_scope update_time datetime COMMENT '更新时间', primary key (id), key idx_role_id (role_id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色数据权限'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='角色数据权限'; CREATE TABLE sys_oauth_client ( id bigint NOT NULL AUTO_INCREMENT COMMENT 'id', @@ -189,7 +189,7 @@ create table sys_dict_type updater bigint COMMENT '更新者', update_time datetime COMMENT '更新时间', primary key (id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='字典类型'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='字典类型'; create table sys_dict_data ( @@ -206,8 +206,8 @@ create table sys_dict_data updater bigint COMMENT '更新者', update_time datetime COMMENT '更新时间', primary key (id) -) ENGINE = InnoDB AUTO_INCREMENT = 10000 DEFAULT CHARACTER SET utf8mb4 COMMENT ='字典数据'; +) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT ='字典数据'; INSERT INTO sys_user (id, username, password, real_name, gender, email, mobile, status, org_id, super_admin, version, deleted, creator, create_time, updater, update_time) VALUES (10000, 'admin', '{bcrypt}$2a$10$mW/yJPHjyueQ1g26WNBz0uxVPa0GQdJO1fFZmqdkqgMTGnyszlXxu', 'admin', 0, 'babamu@126.com', '13612345678', 1, null, 1, 0, 0, 10000, now(), 10000, now()); -INSERT INTO sys_oauth_client (id, client_id, client_secret, resource_ids, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove, version, deleted, creator, create_time, updater, update_time) VALUES (10000, 'web', '123456', '', 'all', '["authorization_code","password","implicit","client_credentials","refresh_token"]', 'https://gitee.com/makunet', NULL, 43200, 604800, NULL, 'true', 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_oauth_client (id, client_id, client_secret, resource_ids, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove, version, deleted, creator, create_time, updater, update_time) VALUES (1, 'web', '123456', '', 'all', '["authorization_code","password","implicit","client_credentials","refresh_token"]', 'https://gitee.com/makunet', NULL, 43200, 604800, NULL, 'true', 0, 0, 10000, now(), 10000, now()); diff --git a/fast-boot-framework/src/main/java/net/maku/framework/common/exception/FastExceptionHandler.java b/fast-boot-framework/src/main/java/net/maku/framework/common/exception/FastExceptionHandler.java index 584529b..dc08639 100644 --- a/fast-boot-framework/src/main/java/net/maku/framework/common/exception/FastExceptionHandler.java +++ b/fast-boot-framework/src/main/java/net/maku/framework/common/exception/FastExceptionHandler.java @@ -45,7 +45,7 @@ public class FastExceptionHandler { @ExceptionHandler(Exception.class) public Result handleException(Exception ex){ - return Result.error(ex.getMessage()); + return Result.error(ErrorCode.INTERNAL_SERVER_ERROR); } } \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/controller/SysMenuController.java b/fast-boot-system/src/main/java/net/maku/system/controller/SysMenuController.java index 91d7a47..ba389d5 100644 --- a/fast-boot-system/src/main/java/net/maku/system/controller/SysMenuController.java +++ b/fast-boot-system/src/main/java/net/maku/system/controller/SysMenuController.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; +import net.maku.framework.common.constant.Constant; import net.maku.framework.common.utils.Result; import net.maku.framework.security.user.SecurityUser; import net.maku.framework.security.user.UserDetail; @@ -54,6 +55,7 @@ public class SysMenuController { @GetMapping("list") @Operation(summary = "菜单列表") @Parameter(name = "type", description = "菜单类型 0:菜单 1:按钮 2:接口 null:全部") + @PreAuthorize("hasAuthority('sys:menu:list')") public Result> list(Integer type){ List list = sysMenuService.getMenuList(type); @@ -65,8 +67,15 @@ public class SysMenuController { @PreAuthorize("hasAuthority('sys:menu:info')") public Result get(@PathVariable("id") Long id){ SysMenuEntity entity = sysMenuService.getById(id); + SysMenuVO vo = SysMenuConvert.INSTANCE.convert(entity); - return Result.ok(SysMenuConvert.INSTANCE.convert(entity)); + // 获取上级菜单名称 + if(!Constant.ROOT.equals(entity.getPid())){ + SysMenuEntity parentEntity = sysMenuService.getById(entity.getPid()); + vo.setParentName(parentEntity.getName()); + } + + return Result.ok(vo); } @PostMapping @@ -94,7 +103,7 @@ public class SysMenuController { // 判断是否有子菜单或按钮 Long count = sysMenuService.getSubMenuCount(id); if(count > 0){ - return Result.error("存在子菜单"); + return Result.error("请先删除子菜单"); } sysMenuService.delete(id); diff --git a/fast-boot-system/src/main/java/net/maku/system/controller/SysOrgController.java b/fast-boot-system/src/main/java/net/maku/system/controller/SysOrgController.java index 6f4cac3..db37fdd 100644 --- a/fast-boot-system/src/main/java/net/maku/system/controller/SysOrgController.java +++ b/fast-boot-system/src/main/java/net/maku/system/controller/SysOrgController.java @@ -3,6 +3,7 @@ package net.maku.system.controller; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; +import net.maku.framework.common.constant.Constant; import net.maku.framework.common.utils.Result; import net.maku.system.convert.SysOrgConvert; import net.maku.system.entity.SysOrgEntity; @@ -42,8 +43,15 @@ public class SysOrgController { @PreAuthorize("hasAuthority('sys:org:info')") public Result get(@PathVariable("id") Long id){ SysOrgEntity entity = sysOrgService.getById(id); + SysOrgVO vo =SysOrgConvert.INSTANCE.convert(entity); - return Result.ok(SysOrgConvert.INSTANCE.convert(entity)); + // 获取上级机构名称 + if(!Constant.ROOT.equals(entity.getPid())){ + SysOrgEntity parentEntity = sysOrgService.getById(entity.getPid()); + vo.setParentName(parentEntity.getName()); + } + + return Result.ok(vo); } @PostMapping diff --git a/fast-boot-system/src/main/java/net/maku/system/controller/SysUserController.java b/fast-boot-system/src/main/java/net/maku/system/controller/SysUserController.java index 9d66232..db1cfc3 100644 --- a/fast-boot-system/src/main/java/net/maku/system/controller/SysUserController.java +++ b/fast-boot-system/src/main/java/net/maku/system/controller/SysUserController.java @@ -39,6 +39,7 @@ public class SysUserController { @GetMapping("page") @Operation(summary = "分页") + @PreAuthorize("hasAuthority('sys:user:page')") public Result> page(@Valid SysUserQuery query){ PageResult page = sysUserService.page(query); diff --git a/fast-boot-system/src/main/java/net/maku/system/entity/SysUserEntity.java b/fast-boot-system/src/main/java/net/maku/system/entity/SysUserEntity.java index 0766da0..0799f17 100644 --- a/fast-boot-system/src/main/java/net/maku/system/entity/SysUserEntity.java +++ b/fast-boot-system/src/main/java/net/maku/system/entity/SysUserEntity.java @@ -28,7 +28,7 @@ public class SysUserEntity extends BaseEntity { */ private String avatar; /** - * 性别 0:男 1:女 + * 性别 0:男 1:女 2:未知 */ private Integer gender; /** diff --git a/fast-boot-system/src/main/java/net/maku/system/service/impl/SysDictTypeServiceImpl.java b/fast-boot-system/src/main/java/net/maku/system/service/impl/SysDictTypeServiceImpl.java index ff575b4..b122c45 100644 --- a/fast-boot-system/src/main/java/net/maku/system/service/impl/SysDictTypeServiceImpl.java +++ b/fast-boot-system/src/main/java/net/maku/system/service/impl/SysDictTypeServiceImpl.java @@ -37,7 +37,6 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl page(SysDictTypeQuery query) { IPage page = baseMapper.selectPage(getPage(query), getWrapper(query)); - return new PageResult<>(SysDictTypeConvert.INSTANCE.convertList(page.getRecords()), page.getTotal()); } @@ -88,7 +87,9 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl getParams(SysUserQuery query){ Map params = new HashMap<>(); params.put("username", query.getUsername()); + params.put("mobile", query.getMobile()); + params.put("gender", query.getGender()); // 数据权限 params.put(Constant.DATA_SCOPE, getDataScope("t1")); @@ -83,6 +85,9 @@ public class SysUserServiceImpl extends BaseServiceImpl @@ -17,7 +15,7 @@ select t3.* from sys_user_role t1 left join sys_role_menu t2 on t1.role_id = t2.role_id left join sys_menu t3 on t2.menu_id = t3.id - where t1.user_id = #{userId} + where t1.user_id = #{userId} and t3.deleted = 0 and t3.type = #{type} @@ -27,11 +25,11 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysOrgDao.xml b/fast-boot-system/src/main/resources/mapper/SysOrgDao.xml index a7f60c9..f621e25 100644 --- a/fast-boot-system/src/main/resources/mapper/SysOrgDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysOrgDao.xml @@ -4,12 +4,12 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysRoleDao.xml b/fast-boot-system/src/main/resources/mapper/SysRoleDao.xml index 75077f8..91d8a8a 100644 --- a/fast-boot-system/src/main/resources/mapper/SysRoleDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysRoleDao.xml @@ -5,7 +5,7 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysRoleDataScopeDao.xml b/fast-boot-system/src/main/resources/mapper/SysRoleDataScopeDao.xml index 22051b2..8ffbcb4 100644 --- a/fast-boot-system/src/main/resources/mapper/SysRoleDataScopeDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysRoleDataScopeDao.xml @@ -4,12 +4,12 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysRoleMenuDao.xml b/fast-boot-system/src/main/resources/mapper/SysRoleMenuDao.xml index dc672cd..f8035dc 100644 --- a/fast-boot-system/src/main/resources/mapper/SysRoleMenuDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysRoleMenuDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysUserDao.xml b/fast-boot-system/src/main/resources/mapper/SysUserDao.xml index 04fc5b4..eb1bb37 100644 --- a/fast-boot-system/src/main/resources/mapper/SysUserDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysUserDao.xml @@ -5,24 +5,24 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysUserPostDao.xml b/fast-boot-system/src/main/resources/mapper/SysUserPostDao.xml index 67da7db..b9099ba 100644 --- a/fast-boot-system/src/main/resources/mapper/SysUserPostDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysUserPostDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysUserRoleDao.xml b/fast-boot-system/src/main/resources/mapper/SysUserRoleDao.xml index 817fafe..b39cf6d 100644 --- a/fast-boot-system/src/main/resources/mapper/SysUserRoleDao.xml +++ b/fast-boot-system/src/main/resources/mapper/SysUserRoleDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file