修复一些bug
This commit is contained in:
parent
707131492f
commit
e8ad8df7af
26
db/mysql.sql
26
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());
|
||||
|
|
|
@ -45,7 +45,7 @@ public class FastExceptionHandler {
|
|||
@ExceptionHandler(Exception.class)
|
||||
public Result<String> handleException(Exception ex){
|
||||
|
||||
return Result.error(ex.getMessage());
|
||||
return Result.error(ErrorCode.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<SysMenuVO>> list(Integer type){
|
||||
List<SysMenuVO> list = sysMenuService.getMenuList(type);
|
||||
|
||||
|
@ -65,8 +67,15 @@ public class SysMenuController {
|
|||
@PreAuthorize("hasAuthority('sys:menu:info')")
|
||||
public Result<SysMenuVO> 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);
|
||||
|
|
|
@ -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<SysOrgVO> 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
|
||||
|
|
|
@ -39,6 +39,7 @@ public class SysUserController {
|
|||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@PreAuthorize("hasAuthority('sys:user:page')")
|
||||
public Result<PageResult<SysUserVO>> page(@Valid SysUserQuery query){
|
||||
PageResult<SysUserVO> page = sysUserService.page(query);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SysUserEntity extends BaseEntity {
|
|||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别 0:男 1:女
|
||||
* 性别 0:男 1:女 2:未知
|
||||
*/
|
||||
private Integer gender;
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
@Override
|
||||
public PageResult<SysDictTypeVO> page(SysDictTypeQuery query) {
|
||||
IPage<SysDictTypeEntity> 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<SysDictTypeDao, SysD
|
|||
dict.setDictType(type.getDictType());
|
||||
|
||||
for (SysDictDataEntity data : dataList){
|
||||
dict.getDataList().add(new SysDictVO.DictData(data.getDictLabel(), data.getDictValue()));
|
||||
if(type.getId().equals(data.getDictTypeId())){
|
||||
dict.getDataList().add(new SysDictVO.DictData(data.getDictLabel(), data.getDictValue()));
|
||||
}
|
||||
}
|
||||
|
||||
dictList.add(dict);
|
||||
|
|
|
@ -53,6 +53,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
private Map<String, Object> getParams(SysUserQuery query){
|
||||
Map<String, Object> 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<SysUserDao, SysUserEntit
|
|||
|
||||
// 保存用户角色关系
|
||||
sysUserRoleService.saveOrUpdate(entity.getId(), vo.getRoleIdList());
|
||||
|
||||
// 更新用户岗位关系
|
||||
sysUserPostService.saveOrUpdate(entity.getId(), vo.getPostIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,6 +111,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
|
||||
// 更新用户角色关系
|
||||
sysUserRoleService.saveOrUpdate(entity.getId(), vo.getRoleIdList());
|
||||
|
||||
// 更新用户岗位关系
|
||||
sysUserPostService.saveOrUpdate(entity.getId(), vo.getPostIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,8 +36,8 @@ public class SysUserPostVO implements Serializable {
|
|||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "性别 0:男 1:女", required = true)
|
||||
@Range(min = 0, max = 1, message = "性别不正确")
|
||||
@Schema(description = "性别 0:男 1:女 2:未知", required = true)
|
||||
@Range(min = 0, max = 2, message = "性别不正确")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "邮箱")
|
||||
|
|
|
@ -23,7 +23,4 @@ public class SysUserQuery extends Query {
|
|||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "机构ID")
|
||||
private Long orgId;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
<mapper namespace="net.maku.system.dao.SysMenuDao">
|
||||
|
||||
<select id="getMenuList" resultType="net.maku.system.entity.SysMenuEntity">
|
||||
select * from sys_menu
|
||||
<where>
|
||||
<if test="type != null">
|
||||
type = #{type}
|
||||
</if>
|
||||
</where>
|
||||
select * from sys_menu where deleted = 0
|
||||
<if test="type != null">
|
||||
and type = #{type}
|
||||
</if>
|
||||
order by sort asc
|
||||
</select>
|
||||
|
||||
|
@ -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
|
||||
<if test="type != null">
|
||||
and t3.type = #{type}
|
||||
</if>
|
||||
|
@ -27,11 +25,11 @@
|
|||
<select id="getUserAuthorityList" resultType="string">
|
||||
select t3.authority 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} order by t3.sort asc
|
||||
where t1.user_id = #{userId} and t3.deleted = 0 order by t3.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getAuthorityList" resultType="string">
|
||||
select authority from sys_menu
|
||||
select authority from sys_menu where deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,12 +4,12 @@
|
|||
<mapper namespace="net.maku.system.dao.SysOrgDao">
|
||||
|
||||
<select id="getList" resultType="net.maku.system.entity.SysOrgEntity">
|
||||
select t1.*,(select t2.name from sys_org t2 where t2.id = t1.pid) parentName from sys_org t1
|
||||
select t1.*, (select t2.name from sys_org t2 where t2.id = t1.pid) parentName from sys_org t1 where t1.deleted = 0
|
||||
order by t1.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getIdAndPidList" resultType="net.maku.system.entity.SysOrgEntity">
|
||||
select t1.id, t1.pid from sys_org t1
|
||||
select t1.id, t1.pid from sys_org t1 where t1.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<select id="getDataScopeByUserId" resultType="integer">
|
||||
select min(t1.data_scope) from sys_role t1, sys_user_role t2
|
||||
where t1.id = t2.role_id and t2.user_id = #{userId}
|
||||
where t1.id = t2.role_id and t2.user_id = #{userId} and t1.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,12 +4,12 @@
|
|||
<mapper namespace="net.maku.system.dao.SysRoleDataScopeDao">
|
||||
|
||||
<select id="getOrgIdList" resultType="long">
|
||||
select org_id from sys_role_data_scope where role_id = #{roleId}
|
||||
select org_id from sys_role_data_scope where role_id = #{roleId} and deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getDataScopeList" resultType="long">
|
||||
select t2.org_id from sys_user_role t1, sys_role_data_scope t2
|
||||
where t1.user_id = #{userId} and t1.role_id = t2.role_id
|
||||
where t1.user_id = #{userId} and t1.role_id = t2.role_id and t1.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,7 +4,7 @@
|
|||
<mapper namespace="net.maku.system.dao.SysRoleMenuDao">
|
||||
|
||||
<select id="getMenuIdList" resultType="long">
|
||||
select menu_id from sys_role_menu where role_id = #{roleId}
|
||||
select menu_id from sys_role_menu where role_id = #{roleId} and deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -5,24 +5,24 @@
|
|||
|
||||
<select id="getList" resultType="net.maku.system.entity.SysUserEntity">
|
||||
select t1.*, (select t2.name from sys_org t2 where t2.id = t1.org_id) orgName
|
||||
from sys_user t1 where t1.super_admin = 0
|
||||
from sys_user t1 where t1.super_admin = 0 and t1.deleted = 0
|
||||
<if test="username != null and username.trim() != ''">
|
||||
and t1.username like #{username}
|
||||
and t1.username = #{username}
|
||||
</if>
|
||||
<if test="mobile != null and mobile.trim() != ''">
|
||||
and t1.mobile like #{mobile}
|
||||
and t1.mobile = #{mobile}
|
||||
</if>
|
||||
<if test="orgId != null and orgId.trim() != ''">
|
||||
and t1.org_id = #{orgId}
|
||||
</if>
|
||||
<if test="gender != null and gender.trim() != ''">
|
||||
<if test="gender != null">
|
||||
and t1.gender = #{gender}
|
||||
</if>
|
||||
<if test="dataScope != null">
|
||||
${dataScope}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="net.maku.system.entity.SysUserEntity">
|
||||
select t1.*, (select t2.name from sys_org t2 where t2.id = t1.org_id) orgName from sys_user t1
|
||||
where t1.id = #{id}
|
||||
where t1.id = #{id} and t1.deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,7 +4,7 @@
|
|||
<mapper namespace="net.maku.system.dao.SysUserPostDao">
|
||||
|
||||
<select id="getPostIdList" resultType="long">
|
||||
select post_id from sys_user_post where user_id = #{userId}
|
||||
select post_id from sys_user_post where user_id = #{userId} and deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,7 +4,7 @@
|
|||
<mapper namespace="net.maku.system.dao.SysUserRoleDao">
|
||||
|
||||
<select id="getRoleIdList" resultType="long">
|
||||
select role_id from sys_user_role where user_id = #{userId}
|
||||
select role_id from sys_user_role where user_id = #{userId} and deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user