mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-26 06:57:08 +08:00
重构:🔥 基于阿里巴巴 Java 开发手册(黄山版)重构各表基本结构(简化列名)
1.MySQL数据库>建表规约>第9条: 【强制】表必备三字段:id,create_time,update_time。 说明:其中 id 必为主键,类型为 bigint unsigned、单表时自增、步长为 1。create_time,update_time 的类型均为datetime 类型,如果要记录时区信息,那么类型设置为 timestamp。 个人理解:简化列名的目的是为了后续能抽取更多公共能力 2.MySQL数据库>SQL语句>第10条: 【推荐】SQL 语句中表的别名前加 as,并且以 t1、t2、t3、...的顺序依次命名。 说明: 1)别名可以是表的简称,或者是依照表在 SQL 语句中出现的顺序,以 t1、t2、t3 的方式命名。 2)别名前加 as 使别名更容易识别。 正例:select t1.name from first_table as t1 , second_table as t2 where t1.id = t2.id;
This commit is contained in:
@@ -44,9 +44,9 @@ public class LoginRequest implements Serializable {
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码(加密后)
|
||||
* 密码(加密)
|
||||
*/
|
||||
@Schema(description = "密码(加密后)")
|
||||
@Schema(description = "密码(加密)")
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ public class UserInfoVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
* ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
@@ -64,9 +64,9 @@ public class UserInfoVO implements Serializable {
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 性别(0未知 1男 2女)
|
||||
* 性别(0:未知,1:男,2:女)
|
||||
*/
|
||||
@Schema(description = "性别(0未知 1男 2女)", type = "Integer", allowableValues = {"0", "1", "2"})
|
||||
@Schema(description = "性别(0:未知,1:男,2:女)", type = "Integer", allowableValues = {"0", "1", "2"})
|
||||
private GenderEnum gender;
|
||||
|
||||
/**
|
||||
@@ -112,9 +112,9 @@ public class UserInfoVO implements Serializable {
|
||||
private LocalDate registrationDate;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门ID")
|
||||
@Schema(description = "部门 ID")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,13 +53,13 @@ public class LoginServiceImpl implements LoginService {
|
||||
public String login(String username, String password) {
|
||||
UserDO userDO = userService.getByUsername(username);
|
||||
CheckUtils.throwIfNull(userDO, "用户名或密码错误");
|
||||
Long userId = userDO.getUserId();
|
||||
Long userId = userDO.getId();
|
||||
CheckUtils.throwIfNotEqual(SecureUtils.md5Salt(password, userId.toString()), userDO.getPassword(), "用户名或密码错误");
|
||||
CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, userDO.getStatus(), "此账号已被禁用,如有疑问,请联系管理员");
|
||||
|
||||
// 登录
|
||||
LoginUser loginUser = BeanUtil.copyProperties(userDO, LoginUser.class);
|
||||
loginUser.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(loginUser.getDeptId()).getDeptName()));
|
||||
loginUser.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(loginUser.getDeptId()).getName()));
|
||||
loginUser.setPermissions(permissionService.listPermissionByUserId(userId));
|
||||
loginUser.setRoles(permissionService.listRoleCodeByUserId(userId));
|
||||
LoginHelper.login(loginUser);
|
||||
|
||||
@@ -54,6 +54,6 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
|
||||
@Override
|
||||
public Set<String> listRoleCodeByUserId(Long userId) {
|
||||
return roleService.listRoleCodeByUserId(userId);
|
||||
return roleService.listCodeByUserId(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.cnadmin.system.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
@@ -36,16 +35,10 @@ public class DeptDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@TableId
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 上级部门 ID
|
||||
@@ -60,10 +53,10 @@ public class DeptDO extends BaseDO {
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
private Integer deptSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
private DisEnableStatusEnum status;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.cnadmin.system.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
@@ -38,15 +37,9 @@ public class MenuDO extends BaseDO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单 ID
|
||||
* 菜单标题
|
||||
*/
|
||||
@TableId
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String menuName;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 上级菜单 ID
|
||||
@@ -54,9 +47,9 @@ public class MenuDO extends BaseDO {
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 菜单类型(1目录 2菜单 3按钮)
|
||||
* 菜单类型(1:目录,2:菜单,3:按钮)
|
||||
*/
|
||||
private MenuTypeEnum menuType;
|
||||
private MenuTypeEnum type;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
@@ -101,10 +94,10 @@ public class MenuDO extends BaseDO {
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
private Integer menuSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
private DisEnableStatusEnum status;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.cnadmin.system.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
@@ -37,24 +36,18 @@ public class RoleDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色 ID
|
||||
*/
|
||||
@TableId
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)
|
||||
* 数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)
|
||||
*/
|
||||
private DataScopeEnum dataScope;
|
||||
|
||||
@@ -66,10 +59,10 @@ public class RoleDO extends BaseDO {
|
||||
/**
|
||||
* 角色排序
|
||||
*/
|
||||
private Integer roleSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
private DisEnableStatusEnum status;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
@@ -39,12 +38,6 @@ public class UserDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
@TableId
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@@ -61,7 +54,7 @@ public class UserDO extends BaseDO {
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 性别(0未知 1男 2女)
|
||||
* 性别(0:未知,1:男,2:女)
|
||||
*/
|
||||
private GenderEnum gender;
|
||||
|
||||
@@ -86,7 +79,7 @@ public class UserDO extends BaseDO {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ public class DeptQuery implements Serializable {
|
||||
*/
|
||||
@Schema(description = "部门名称")
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String deptName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -40,16 +40,16 @@ public class MenuQuery implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
* 菜单标题
|
||||
*/
|
||||
@Schema(description = "菜单名称")
|
||||
@Schema(description = "菜单标题")
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String menuName;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ public class RoleQuery implements Serializable {
|
||||
* 角色名称
|
||||
*/
|
||||
@Schema(description = "角色名称")
|
||||
@Query(blurry = "roleName,roleCode")
|
||||
private String roleName;
|
||||
@Query(blurry = "name,code")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ public class UserQuery implements Serializable {
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.cnadmin.system.model.request;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Null;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -41,14 +40,6 @@ public class DeptRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门 ID")
|
||||
@Null(message = "新增时,ID 必须为空", groups = Add.class)
|
||||
@NotNull(message = "修改时,ID 不能为空", groups = Update.class)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 上级部门 ID
|
||||
*/
|
||||
@@ -60,14 +51,14 @@ public class DeptRequest extends BaseRequest {
|
||||
*/
|
||||
@Schema(description = "部门名称")
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
private String deptName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
@Schema(description = "部门排序")
|
||||
@NotNull(message = "部门排序不能为空")
|
||||
private Integer deptSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.cnadmin.system.model.request;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Null;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -40,33 +39,38 @@ public class MenuRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单 ID
|
||||
*/
|
||||
@Schema(description = "菜单 ID")
|
||||
@Null(message = "新增时,ID 必须为空", groups = Add.class)
|
||||
@NotNull(message = "修改时,ID 不能为空", groups = Update.class)
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 上级菜单 ID
|
||||
*/
|
||||
@Schema(description = "上级菜单 ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@Schema(description = "菜单名称")
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 菜单类型(1目录 2菜单 3按钮)
|
||||
*/
|
||||
@Schema(description = "菜单类型(1目录 2菜单 3按钮)", type = "Integer", allowableValues = {"1", "2", "3"})
|
||||
@NotNull(message = "菜单类型非法")
|
||||
private MenuTypeEnum menuType;
|
||||
private MenuTypeEnum type;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 菜单标题
|
||||
*/
|
||||
@Schema(description = "菜单标题")
|
||||
@NotBlank(message = "菜单标题不能为空")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
@Schema(description = "菜单排序")
|
||||
@NotNull(message = "菜单排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
@Schema(description = "权限标识")
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
@@ -86,12 +90,6 @@ public class MenuRequest extends BaseRequest {
|
||||
@Schema(description = "组件路径")
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 是否外链
|
||||
*/
|
||||
@@ -111,17 +109,10 @@ public class MenuRequest extends BaseRequest {
|
||||
private Boolean isHidden;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
* 上级菜单 ID
|
||||
*/
|
||||
@Schema(description = "权限标识")
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
@Schema(description = "菜单排序")
|
||||
@NotNull(message = "菜单排序不能为空")
|
||||
private Integer menuSort;
|
||||
@Schema(description = "上级菜单 ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Null;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -44,33 +43,25 @@ public class RoleRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色 ID
|
||||
*/
|
||||
@Schema(description = "角色 ID")
|
||||
@Null(message = "新增时,ID 必须为空", groups = Add.class)
|
||||
@NotNull(message = "修改时,ID 不能为空", groups = Update.class)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Schema(description = "角色名称")
|
||||
@NotBlank(message = "角色名称不能为空")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
@Schema(description = "角色编码")
|
||||
private String roleCode;
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 角色排序
|
||||
*/
|
||||
@Schema(description = "角色排序")
|
||||
@NotNull(message = "角色排序不能为空")
|
||||
private Integer roleSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
@@ -86,9 +77,9 @@ public class RoleRequest extends BaseRequest {
|
||||
private List<Long> menuIds;
|
||||
|
||||
/**
|
||||
* 数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)
|
||||
* 数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)
|
||||
*/
|
||||
@Schema(description = "数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)", type = "Integer",
|
||||
@Schema(description = "数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)", type = "Integer",
|
||||
allowableValues = {"1", "2", "3", "4", "5"})
|
||||
private DataScopeEnum dataScope;
|
||||
|
||||
@@ -99,8 +90,8 @@ public class RoleRequest extends BaseRequest {
|
||||
private List<Long> deptIds;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)", type = "Integer", allowableValues = {"1", "2"})
|
||||
@Schema(description = "状态(1:启用,2:禁用)", type = "Integer", allowableValues = {"1", "2"})
|
||||
private DisEnableStatusEnum status;
|
||||
}
|
||||
|
||||
@@ -44,14 +44,6 @@ public class UserRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
@Schema(description = "角色 ID")
|
||||
@Null(message = "新增时,ID 必须为空", groups = Add.class)
|
||||
@NotNull(message = "修改时,ID 不能为空", groups = Update.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@@ -66,13 +58,6 @@ public class UserRequest extends BaseRequest {
|
||||
@Length(max = 32, message = "昵称长度不能超过 {max} 个字符")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 性别(0未知 1男 2女)
|
||||
*/
|
||||
@Schema(description = "性别(0未知 1男 2女)", type = "Integer", allowableValues = {"0", "1", "2"})
|
||||
@NotNull(message = "性别非法")
|
||||
private GenderEnum gender;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@@ -87,6 +72,25 @@ public class UserRequest extends BaseRequest {
|
||||
@Pattern(regexp = RegexPool.MOBILE, message = "手机号码格式错误")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 性别(0:未知,1:男,2:女)
|
||||
*/
|
||||
@Schema(description = "性别(0:未知,1:男,2:女)", type = "Integer", allowableValues = {"0", "1", "2"})
|
||||
@NotNull(message = "性别非法")
|
||||
private GenderEnum gender;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Schema(description = "所属部门")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 所属角色
|
||||
*/
|
||||
@Schema(description = "所属角色")
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@@ -95,20 +99,8 @@ public class UserRequest extends BaseRequest {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)", type = "Integer", allowableValues = {"1", "2"})
|
||||
@Schema(description = "状态(1:启用,2:禁用)", type = "Integer", allowableValues = {"1", "2"})
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "所属部门")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 角色 ID 列表
|
||||
*/
|
||||
@Schema(description = "所属角色")
|
||||
private List<Long> roleIds;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,12 @@ public class DeptDetailVO extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门 ID")
|
||||
@ExcelProperty(value = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Schema(description = "部门名称")
|
||||
@ExcelProperty(value = "部门名称")
|
||||
private String deptName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 上级部门 ID
|
||||
@@ -62,29 +55,30 @@ public class DeptDetailVO extends BaseDetailVO {
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
* 上级部门
|
||||
*/
|
||||
@Schema(description = "描述")
|
||||
@ExcelProperty(value = "描述")
|
||||
private String description;
|
||||
@Schema(description = "上级部门")
|
||||
@TableField(exist = false)
|
||||
@ExcelProperty(value = "上级部门")
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
@Schema(description = "部门排序")
|
||||
private Integer deptSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 上级部门
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "上级部门")
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
@Schema(description = "描述")
|
||||
@ExcelProperty(value = "描述")
|
||||
private String description;
|
||||
}
|
||||
|
||||
@@ -33,23 +33,17 @@ import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TreeField(value = "deptId", nameKey = "deptName", weightKey = "deptSort")
|
||||
@TreeField(value = "id", nameKey = "name")
|
||||
@Schema(description = "部门信息")
|
||||
public class DeptVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门 ID")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Schema(description = "部门名称")
|
||||
private String deptName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 上级部门 ID
|
||||
@@ -57,21 +51,21 @@ public class DeptVO extends BaseVO {
|
||||
@Schema(description = "上级部门 ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
@Schema(description = "部门排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
@Schema(description = "部门排序")
|
||||
private Integer deptSort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
private DisEnableStatusEnum status;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,12 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.charles7c.cnadmin.common.annotation.TreeField;
|
||||
import top.charles7c.cnadmin.common.base.BaseVO;
|
||||
import top.charles7c.cnadmin.common.config.easyexcel.ExcelBaseEnumConverter;
|
||||
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
||||
|
||||
@@ -34,93 +38,100 @@ import top.charles7c.cnadmin.common.enums.MenuTypeEnum;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TreeField(value = "menuId", nameKey = "menuName", weightKey = "menuSort")
|
||||
@TreeField(value = "id")
|
||||
@ExcelIgnoreUnannotated
|
||||
@Schema(description = "菜单信息")
|
||||
public class MenuVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单 ID
|
||||
* 菜单标题
|
||||
*/
|
||||
@Schema(description = "菜单 ID")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@Schema(description = "菜单名称")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 上级菜单 ID
|
||||
*/
|
||||
@Schema(description = "上级菜单 ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 菜单类型(1目录 2菜单 3按钮)
|
||||
*/
|
||||
@Schema(description = "菜单类型(1目录 2菜单 3按钮)")
|
||||
private MenuTypeEnum menuType;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
@Schema(description = "路由地址")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
@Schema(description = "组件名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
@Schema(description = "组件路径")
|
||||
private String component;
|
||||
@Schema(description = "菜单标题")
|
||||
@ExcelProperty(value = "菜单标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@Schema(description = "菜单图标")
|
||||
@ExcelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
@Schema(description = "菜单排序")
|
||||
@ExcelProperty(value = "菜单排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
@Schema(description = "权限标识")
|
||||
@ExcelProperty(value = "权限标识")
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
@Schema(description = "组件路径")
|
||||
@ExcelProperty(value = "组件路径")
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 是否外链
|
||||
*/
|
||||
@Schema(description = "是否外链")
|
||||
@ExcelProperty(value = "是否外链")
|
||||
private Boolean isExternal;
|
||||
|
||||
/**
|
||||
* 是否缓存
|
||||
*/
|
||||
@Schema(description = "是否缓存")
|
||||
@ExcelProperty(value = "是否缓存")
|
||||
private Boolean isCache;
|
||||
|
||||
/**
|
||||
* 是否隐藏
|
||||
*/
|
||||
@Schema(description = "是否隐藏")
|
||||
@ExcelProperty(value = "是否隐藏")
|
||||
private Boolean isHidden;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
* 路由地址
|
||||
*/
|
||||
@Schema(description = "权限标识")
|
||||
private String permission;
|
||||
@Schema(description = "路由地址")
|
||||
@ExcelProperty(value = "路由地址")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
* 组件名称
|
||||
*/
|
||||
@Schema(description = "菜单排序")
|
||||
private Integer menuSort;
|
||||
@Schema(description = "组件名称")
|
||||
@ExcelProperty(value = "组件名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 菜单类型(1:目录,2:菜单,3:按钮)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
private DisEnableStatusEnum status;
|
||||
@Schema(description = "菜单类型(1:目录,2:菜单,3:按钮)")
|
||||
@ExcelProperty(value = "菜单类型", converter = ExcelBaseEnumConverter.class)
|
||||
private MenuTypeEnum type;
|
||||
|
||||
/**
|
||||
* 上级菜单 ID
|
||||
*/
|
||||
@Schema(description = "上级菜单 ID")
|
||||
private Long parentId;
|
||||
}
|
||||
|
||||
@@ -43,31 +43,24 @@ public class RoleDetailVO extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色 ID
|
||||
*/
|
||||
@Schema(description = "角色 ID")
|
||||
@ExcelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Schema(description = "角色名称")
|
||||
@ExcelProperty(value = "角色名称")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
@Schema(description = "角色编码")
|
||||
@ExcelProperty(value = "角色编码")
|
||||
private String roleCode;
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)
|
||||
* 数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)
|
||||
*/
|
||||
@Schema(description = "数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)")
|
||||
@Schema(description = "数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)")
|
||||
@ExcelProperty(value = "数据权限", converter = ExcelBaseEnumConverter.class)
|
||||
private DataScopeEnum dataScope;
|
||||
|
||||
@@ -76,12 +69,12 @@ public class RoleDetailVO extends BaseDetailVO {
|
||||
*/
|
||||
@Schema(description = "角色排序")
|
||||
@ExcelProperty(value = "角色排序")
|
||||
private Integer roleSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
|
||||
@@ -41,40 +41,34 @@ public class RoleVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色 ID
|
||||
*/
|
||||
@Schema(description = "角色 ID")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Schema(description = "角色名称")
|
||||
private String roleName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
@Schema(description = "角色编码")
|
||||
private String roleCode;
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)
|
||||
* 数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)
|
||||
*/
|
||||
@Schema(description = "数据权限(1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)")
|
||||
@Schema(description = "数据权限(1:全部数据权限,2:本部门及以下数据权限,3:本部门数据权限,4:仅本人数据权限,5:自定义数据权限)")
|
||||
private DataScopeEnum dataScope;
|
||||
|
||||
/**
|
||||
* 角色排序
|
||||
*/
|
||||
@Schema(description = "角色排序")
|
||||
private Integer roleSort;
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
@@ -90,7 +84,7 @@ public class RoleVO extends BaseVO {
|
||||
private Boolean disabled;
|
||||
|
||||
public Boolean getDisabled() {
|
||||
if (SysConsts.SUPER_ADMIN.equals(roleCode)) {
|
||||
if (SysConsts.SUPER_ADMIN.equals(code)) {
|
||||
return true;
|
||||
}
|
||||
return disabled;
|
||||
|
||||
@@ -44,13 +44,6 @@ public class UserDetailVO extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
@Schema(description = "用户 ID")
|
||||
@ExcelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@@ -66,9 +59,9 @@ public class UserDetailVO extends BaseDetailVO {
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 性别(0未知 1男 2女)
|
||||
* 性别(0:未知,1:男,2:女)
|
||||
*/
|
||||
@Schema(description = "性别(0未知 1男 2女)")
|
||||
@Schema(description = "性别(0:未知,1:男,2:女)")
|
||||
@ExcelProperty(value = "性别", converter = ExcelBaseEnumConverter.class)
|
||||
private GenderEnum gender;
|
||||
|
||||
@@ -94,9 +87,9 @@ public class UserDetailVO extends BaseDetailVO {
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@ public class UserVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
@Schema(description = "用户 ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@@ -64,11 +58,17 @@ public class UserVO extends BaseVO {
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 性别(0未知 1男 2女)
|
||||
* 性别(0:未知,1:男,2:女)
|
||||
*/
|
||||
@Schema(description = "性别(0未知 1男 2女)")
|
||||
@Schema(description = "性别(0:未知,1:男,2:女)")
|
||||
private GenderEnum gender;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
@Schema(description = "头像地址")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@@ -82,15 +82,9 @@ public class UserVO extends BaseVO {
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
* 状态(1:启用,2:禁用)
|
||||
*/
|
||||
@Schema(description = "头像地址")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 状态(1启用 2禁用)
|
||||
*/
|
||||
@Schema(description = "状态(1启用 2禁用)")
|
||||
@Schema(description = "状态(1:启用,2:禁用)")
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
@@ -106,7 +100,7 @@ public class UserVO extends BaseVO {
|
||||
private Boolean disabled;
|
||||
|
||||
public Boolean getDisabled() {
|
||||
if (Objects.equals(userId, LoginHelper.getUserId())) {
|
||||
if (Objects.equals(this.getId(), LoginHelper.getUserId())) {
|
||||
return true;
|
||||
}
|
||||
return disabled;
|
||||
|
||||
@@ -59,5 +59,5 @@ public interface RoleService extends BaseService<RoleVO, RoleDetailVO, RoleQuery
|
||||
* 用户 ID
|
||||
* @return 角色编码集合
|
||||
*/
|
||||
Set<String> listRoleCodeByUserId(Long userId);
|
||||
Set<String> listCodeByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(DeptRequest request) {
|
||||
String deptName = request.getDeptName();
|
||||
boolean isExists = this.checkNameExists(deptName, request.getParentId(), request.getDeptId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", deptName));
|
||||
String name = request.getName();
|
||||
boolean isExists = this.checkNameExists(name, request.getParentId(), request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", name));
|
||||
|
||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
return super.add(request);
|
||||
@@ -68,9 +68,9 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeptRequest request) {
|
||||
String deptName = request.getDeptName();
|
||||
boolean isExists = this.checkNameExists(deptName, request.getParentId(), request.getDeptId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", deptName));
|
||||
String name = request.getName();
|
||||
boolean isExists = this.checkNameExists(name, request.getParentId(), request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", name));
|
||||
|
||||
super.update(request);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
||||
if (Objects.equals(SysConsts.SUPER_PARENT_ID, detailVO.getParentId())) {
|
||||
return;
|
||||
}
|
||||
detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getDeptName()));
|
||||
detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(DeptDO::getDeptName, name).eq(DeptDO::getParentId, parentId)
|
||||
.ne(id != null, DeptDO::getDeptId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(DeptDO::getName, name).eq(DeptDO::getParentId, parentId)
|
||||
.ne(id != null, DeptDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(MenuRequest request) {
|
||||
String menuName = request.getMenuName();
|
||||
boolean isExists = this.checkNameExists(menuName, request.getParentId(), request.getMenuId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", menuName));
|
||||
String title = request.getTitle();
|
||||
boolean isExists = this.checkNameExists(title, request.getParentId(), request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", title));
|
||||
|
||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
return super.add(request);
|
||||
@@ -58,9 +58,9 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(MenuRequest request) {
|
||||
String menuName = request.getMenuName();
|
||||
boolean isExists = this.checkNameExists(menuName, request.getParentId(), request.getMenuId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", menuName));
|
||||
String title = request.getTitle();
|
||||
boolean isExists = this.checkNameExists(title, request.getParentId(), request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", title));
|
||||
|
||||
super.update(request);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(MenuDO::getMenuName, name).eq(MenuDO::getParentId, parentId)
|
||||
.ne(id != null, MenuDO::getMenuId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(MenuDO::getTitle, name).eq(MenuDO::getParentId, parentId)
|
||||
.ne(id != null, MenuDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,10 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(RoleRequest request) {
|
||||
String roleName = request.getRoleName();
|
||||
CheckUtils.throwIf(() -> this.checkNameExists(roleName, request.getRoleId()),
|
||||
String.format("新增失败,'%s'已存在", roleName));
|
||||
String roleCode = request.getRoleCode();
|
||||
CheckUtils.throwIf(() -> this.checkCodeExists(roleCode, request.getRoleId()),
|
||||
String.format("新增失败,'%s'已存在", roleCode));
|
||||
String name = request.getName();
|
||||
CheckUtils.throwIf(() -> this.checkNameExists(name, request.getId()), String.format("新增失败,'%s'已存在", name));
|
||||
String code = request.getCode();
|
||||
CheckUtils.throwIf(() -> this.checkCodeExists(code, request.getId()), String.format("新增失败,'%s'已存在", code));
|
||||
|
||||
// 新增信息
|
||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
@@ -81,16 +79,14 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(RoleRequest request) {
|
||||
String roleName = request.getRoleName();
|
||||
CheckUtils.throwIf(() -> this.checkNameExists(roleName, request.getRoleId()),
|
||||
String.format("修改失败,'%s'已存在", roleName));
|
||||
String roleCode = request.getRoleCode();
|
||||
CheckUtils.throwIf(() -> this.checkCodeExists(roleCode, request.getRoleId()),
|
||||
String.format("修改失败,'%s'已存在", roleCode));
|
||||
String name = request.getName();
|
||||
CheckUtils.throwIf(() -> this.checkNameExists(name, request.getId()), String.format("修改失败,'%s'已存在", name));
|
||||
String code = request.getCode();
|
||||
CheckUtils.throwIf(() -> this.checkCodeExists(code, request.getId()), String.format("修改失败,'%s'已存在", code));
|
||||
|
||||
// 更新信息
|
||||
super.update(request);
|
||||
Long roleId = request.getRoleId();
|
||||
Long roleId = request.getId();
|
||||
// 保存角色和菜单关联
|
||||
roleMenuService.save(request.getMenuIds(), roleId);
|
||||
// 保存角色和部门关联
|
||||
@@ -109,10 +105,10 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
super.fillDetail(detailObj);
|
||||
if (detailObj instanceof RoleDetailVO) {
|
||||
RoleDetailVO detailVO = (RoleDetailVO)detailObj;
|
||||
Long roleId = detailVO.getRoleId();
|
||||
if (SysConsts.SUPER_ADMIN.equals(detailVO.getRoleCode())) {
|
||||
Long roleId = detailVO.getId();
|
||||
if (SysConsts.SUPER_ADMIN.equals(detailVO.getCode())) {
|
||||
List<MenuVO> list = menuService.list(null, null);
|
||||
List<Long> menuIds = list.stream().map(MenuVO::getMenuId).collect(Collectors.toList());
|
||||
List<Long> menuIds = list.stream().map(MenuVO::getId).collect(Collectors.toList());
|
||||
detailVO.setMenuIds(menuIds);
|
||||
} else {
|
||||
detailVO.setMenuIds(roleMenuService.listMenuIdByRoleIds(CollUtil.newArrayList(roleId)));
|
||||
@@ -126,21 +122,20 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return list.stream().map(r -> new LabelValueVO<>(r.getRoleName(), r.getRoleId())).collect(Collectors.toList());
|
||||
return list.stream().map(r -> new LabelValueVO<>(r.getName(), r.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listNameByIds(List<Long> ids) {
|
||||
List<RoleDO> roleList = baseMapper.lambdaQuery().select(RoleDO::getRoleName).in(RoleDO::getRoleId, ids).list();
|
||||
return roleList.stream().map(RoleDO::getRoleName).collect(Collectors.toList());
|
||||
List<RoleDO> roleList = baseMapper.lambdaQuery().select(RoleDO::getName).in(RoleDO::getId, ids).list();
|
||||
return roleList.stream().map(RoleDO::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> listRoleCodeByUserId(Long userId) {
|
||||
public Set<String> listCodeByUserId(Long userId) {
|
||||
List<Long> roleIds = userRoleService.listRoleIdByUserId(userId);
|
||||
List<RoleDO> roleList =
|
||||
baseMapper.lambdaQuery().select(RoleDO::getRoleCode).in(RoleDO::getRoleId, roleIds).list();
|
||||
return roleList.stream().map(RoleDO::getRoleCode).collect(Collectors.toSet());
|
||||
List<RoleDO> roleList = baseMapper.lambdaQuery().select(RoleDO::getCode).in(RoleDO::getId, roleIds).list();
|
||||
return roleList.stream().map(RoleDO::getCode).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +148,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getRoleName, name).ne(id != null, RoleDO::getRoleId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getName, name).ne(id != null, RoleDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,6 +161,6 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkCodeExists(String code, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getRoleCode, code).ne(id != null, RoleDO::getRoleId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getCode, code).ne(id != null, RoleDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UserRequest request) {
|
||||
String username = request.getUsername();
|
||||
boolean isExists = this.checkNameExists(username, request.getUserId());
|
||||
boolean isExists = this.checkNameExists(username, request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", username));
|
||||
|
||||
// 新增信息
|
||||
@@ -83,7 +83,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
Long userId = super.add(request);
|
||||
baseMapper.lambdaUpdate()
|
||||
.set(UserDO::getPassword, SecureUtils.md5Salt(SysConsts.DEFAULT_PASSWORD, userId.toString()))
|
||||
.set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getUserId, userId).update();
|
||||
.set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getId, userId).update();
|
||||
// 保存用户和角色关联
|
||||
userRoleService.save(request.getRoleIds(), userId);
|
||||
return userId;
|
||||
@@ -93,12 +93,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(UserRequest request) {
|
||||
String username = request.getUsername();
|
||||
boolean isExists = this.checkNameExists(username, request.getUserId());
|
||||
boolean isExists = this.checkNameExists(username, request.getId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", username));
|
||||
|
||||
// 更新信息
|
||||
super.update(request);
|
||||
Long userId = request.getUserId();
|
||||
Long userId = request.getId();
|
||||
// 保存用户和角色关联
|
||||
userRoleService.save(request.getRoleIds(), userId);
|
||||
}
|
||||
@@ -108,8 +108,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
super.fillDetail(detailObj);
|
||||
if (detailObj instanceof UserDetailVO) {
|
||||
UserDetailVO detailVO = (UserDetailVO)detailObj;
|
||||
detailVO.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(detailVO.getDeptId()).getDeptName()));
|
||||
List<Long> roleIdList = userRoleService.listRoleIdByUserId(detailVO.getUserId());
|
||||
detailVO.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(detailVO.getDeptId()).getName()));
|
||||
List<Long> roleIdList = userRoleService.listRoleIdByUserId(detailVO.getId());
|
||||
detailVO.setRoleIds(roleIdList);
|
||||
detailVO.setRoleNames(String.join(StringConsts.CHINESE_COMMA, roleService.listNameByIds(roleIdList)));
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
|
||||
// 更新用户头像
|
||||
String newAvatar = newAvatarFile.getName();
|
||||
baseMapper.lambdaUpdate().set(UserDO::getAvatar, newAvatar).eq(UserDO::getUserId, id).update();
|
||||
baseMapper.lambdaUpdate().set(UserDO::getAvatar, newAvatar).eq(UserDO::getId, id).update();
|
||||
|
||||
// 删除原头像
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
@@ -159,7 +159,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
// 更新密码和密码重置时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
baseMapper.lambdaUpdate().set(UserDO::getPassword, SecureUtils.md5Salt(newPassword, id.toString()))
|
||||
.set(UserDO::getPwdResetTime, now).eq(UserDO::getUserId, id).update();
|
||||
.set(UserDO::getPwdResetTime, now).eq(UserDO::getId, id).update();
|
||||
|
||||
// 更新登录用户信息
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
@@ -177,7 +177,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
CheckUtils.throwIfEqual(newEmail, userDO.getEmail(), "新邮箱不能与当前邮箱相同");
|
||||
|
||||
// 更新邮箱
|
||||
baseMapper.lambdaUpdate().set(UserDO::getEmail, newEmail).eq(UserDO::getUserId, id).update();
|
||||
baseMapper.lambdaUpdate().set(UserDO::getEmail, newEmail).eq(UserDO::getId, id).update();
|
||||
|
||||
// 更新登录用户信息
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
@@ -225,6 +225,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(id != null, UserDO::getUserId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(id != null, UserDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
<mapper namespace="top.charles7c.cnadmin.system.mapper.MenuMapper">
|
||||
<select id="selectPermissionByUserId" resultType="java.lang.String">
|
||||
SELECT DISTINCT m.`permission`
|
||||
FROM `sys_menu` m
|
||||
LEFT JOIN `sys_role_menu` rm ON rm.`menu_id` = m.`menu_id`
|
||||
LEFT JOIN `sys_role` r ON r.`role_id` = rm.`role_id`
|
||||
LEFT JOIN `sys_user_role` ur ON ur.`role_id` = rm.`role_id`
|
||||
LEFT JOIN `sys_user` u ON u.`user_id` = ur.`user_id`
|
||||
WHERE u.`user_id` = #{userId}
|
||||
AND m.`menu_type` IN (2, 3)
|
||||
FROM `sys_menu` as m
|
||||
LEFT JOIN `sys_role_menu` as rm ON rm.`menu_id` = m.`id`
|
||||
LEFT JOIN `sys_role` as r ON r.`id` = rm.`role_id`
|
||||
LEFT JOIN `sys_user_role` as ur ON ur.`role_id` = r.`id`
|
||||
LEFT JOIN `sys_user` as u ON u.`id` = ur.`user_id`
|
||||
WHERE u.`id` = #{userId}
|
||||
AND m.`type` IN (2, 3)
|
||||
AND m.`status` = 1
|
||||
AND r.`status` = 1
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user