重构:🔥 基于阿里巴巴 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:
Charles7c 2023-03-06 00:09:11 +08:00
parent 4cd4ad1f82
commit 405c821e2a
61 changed files with 560 additions and 651 deletions

View File

@ -23,6 +23,7 @@ import lombok.Data;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
/**
* 实体类基类
@ -35,6 +36,12 @@ public class BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId
private Long id;
/**
* 创建人
*/

View File

@ -18,10 +18,14 @@ package top.charles7c.cnadmin.common.base;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.groups.Default;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Request 基类
*
@ -33,6 +37,14 @@ public class BaseRequest implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Schema(description = "ID")
@Null(message = "新增时ID 必须为空", groups = Add.class)
@NotNull(message = "修改时ID 不能为空", groups = Update.class)
private Long id;
/**
* 分组校验-创建
*/

View File

@ -37,6 +37,13 @@ public class BaseVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Schema(description = "ID")
@ExcelProperty(value = "ID")
private Long id;
/**
* 创建人
*/

View File

@ -36,9 +36,9 @@ public class LoginUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
* ID
*/
private Long userId;
private Long id;
/**
* 用户名

View File

@ -64,7 +64,7 @@ public class LoginHelper {
loginUser.setLoginTime(logContext != null ? logContext.getCreateTime() : LocalDateTime.now());
// 登录保存用户信息
StpUtil.login(loginUser.getUserId());
StpUtil.login(loginUser.getId());
loginUser.setToken(StpUtil.getTokenValue());
SaHolder.getStorage().set(CacheConsts.LOGIN_USER_CACHE_KEY, loginUser);
StpUtil.getTokenSession().set(CacheConsts.LOGIN_USER_CACHE_KEY, loginUser);
@ -105,7 +105,7 @@ public class LoginHelper {
* @return /
*/
public static Long getUserId() {
return ExceptionUtils.exToNull(() -> getLoginUser().getUserId());
return ExceptionUtils.exToNull(() -> getLoginUser().getId());
}
/**

View File

@ -39,10 +39,10 @@ public class LogDO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 日志 ID
* ID
*/
@TableId
private Long logId;
private Long id;
/**
* 日志描述
@ -95,7 +95,7 @@ public class LogDO implements Serializable {
private Long elapsedTime;
/**
* 操作状态1成功 2失败
* 操作状态1成功2失败
*/
private LogStatusEnum status;

View File

@ -43,9 +43,9 @@ public class LoginLogQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 登录状态1成功 2失败
* 登录状态1成功2失败
*/
@Schema(description = "登录状态1成功 2失败)")
@Schema(description = "登录状态1成功2失败)")
@Query
private Integer status;

View File

@ -42,13 +42,6 @@ public class OperationLogQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 操作人
*/
@Schema(description = "操作人")
@Query(property = "createUser")
private Long uid;
/**
* 操作内容
*/
@ -57,9 +50,9 @@ public class OperationLogQuery implements Serializable {
private String description;
/**
* 操作状态1成功 2失败
* 操作状态1成功2失败
*/
@Schema(description = "操作状态1成功 2失败)")
@Schema(description = "操作状态1成功2失败)")
@Query
private Integer status;
@ -70,4 +63,11 @@ public class OperationLogQuery implements Serializable {
@Query(type = Query.Type.BETWEEN)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private List<Date> createTime;
/**
* 操作人
*/
@Schema(description = "操作人")
@Query(property = "createUser")
private Long uid;
}

View File

@ -36,6 +36,12 @@ public class LogVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Schema(description = "ID")
private Long id;
/**
* 创建人
*/

View File

@ -35,21 +35,15 @@ public class LoginLogVO extends LogVO {
private static final long serialVersionUID = 1L;
/**
* 日志 ID
* 登录行为
*/
@Schema(description = "日志 ID")
private Long logId;
/**
* 日志描述
*/
@Schema(description = "日志描述")
@Schema(description = "登录行为")
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 LogStatusEnum status;
/**

View File

@ -34,12 +34,6 @@ public class OperationLogVO extends LogVO {
private static final long serialVersionUID = 1L;
/**
* 日志 ID
*/
@Schema(description = "日志 ID")
private Long logId;
/**
* 操作内容
*/
@ -55,7 +49,7 @@ public class OperationLogVO extends LogVO {
/**
* 操作状态1成功 2失败
*/
@Schema(description = "操作状态1成功 2失败)", type = "Integer", allowableValues = {"1", "2"})
@Schema(description = "操作状态1成功2失败)", type = "Integer", allowableValues = {"1", "2"})
private LogStatusEnum status;
/**

View File

@ -33,22 +33,10 @@ public class SystemLogDetailVO extends LogVO {
private static final long serialVersionUID = 1L;
/**
* 日志 ID
* 状态码
*/
@Schema(description = "日志 ID")
private Long logId;
/**
* 日志描述
*/
@Schema(description = "日志描述")
private String description;
/**
* 请求URL
*/
@Schema(description = "请求URL")
private String requestUrl;
@Schema(description = "状态码")
private Integer statusCode;
/**
* 请求方式
@ -56,6 +44,12 @@ public class SystemLogDetailVO extends LogVO {
@Schema(description = "请求方式")
private String requestMethod;
/**
* 请求 URL
*/
@Schema(description = "请求 URL")
private String requestUrl;
/**
* 请求头
*/
@ -68,12 +62,6 @@ public class SystemLogDetailVO extends LogVO {
@Schema(description = "请求体")
private String requestBody;
/**
* 状态码
*/
@Schema(description = "状态码")
private Integer statusCode;
/**
* 响应头
*/
@ -86,12 +74,6 @@ public class SystemLogDetailVO extends LogVO {
@Schema(description = "响应体")
private String responseBody;
/**
* 请求耗时ms
*/
@Schema(description = "请求耗时ms")
private Long elapsedTime;
/**
* 客户端IP
*/
@ -109,4 +91,10 @@ public class SystemLogDetailVO extends LogVO {
*/
@Schema(description = "浏览器")
private String browser;
/**
* 请求耗时ms
*/
@Schema(description = "请求耗时ms")
private Long elapsedTime;
}

View File

@ -32,18 +32,6 @@ public class SystemLogVO extends LogVO {
private static final long serialVersionUID = 1L;
/**
* 日志 ID
*/
@Schema(description = "日志 ID")
private Long logId;
/**
* 日志描述
*/
@Schema(description = "日志描述")
private String description;
/**
* 状态码
*/
@ -57,17 +45,11 @@ public class SystemLogVO extends LogVO {
private String requestMethod;
/**
* 请求URL
* 请求 URL
*/
@Schema(description = "请求URL")
@Schema(description = "请求 URL")
private String requestUrl;
/**
* 请求耗时ms
*/
@Schema(description = "请求耗时ms")
private Long elapsedTime;
/**
* 客户端IP
*/
@ -86,6 +68,12 @@ public class SystemLogVO extends LogVO {
@Schema(description = "浏览器")
private String browser;
/**
* 请求耗时ms
*/
@Schema(description = "请求耗时ms")
private Long elapsedTime;
/**
* 错误信息
*/

View File

@ -44,9 +44,9 @@ public class LoginRequest implements Serializable {
private String username;
/**
* 密码加密
* 密码加密
*/
@Schema(description = "密码(加密")
@Schema(description = "密码(加密")
@NotBlank(message = "密码不能为空")
private String password;

View File

@ -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未知12
*/
@Schema(description = "性别0未知 1男 2女)", type = "Integer", allowableValues = {"0", "1", "2"})
@Schema(description = "性别0未知12女)", 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;
/**

View File

@ -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);

View File

@ -54,6 +54,6 @@ public class PermissionServiceImpl implements PermissionService {
@Override
public Set<String> listRoleCodeByUserId(Long userId) {
return roleService.listRoleCodeByUserId(userId);
return roleService.listCodeByUserId(userId);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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未知12
*/
private GenderEnum gender;
@ -86,7 +79,7 @@ public class UserDO extends BaseDO {
private String description;
/**
* 状态1启用 2禁用
* 状态1启用2禁用
*/
private DisEnableStatusEnum status;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
/**
* 描述

View File

@ -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禁用

View File

@ -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;
}

View File

@ -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未知12
*/
@Schema(description = "性别0未知12", 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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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未知12
*/
@Schema(description = "性别0未知 1男 2女)")
@Schema(description = "性别0未知12女)")
@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;

View File

@ -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未知12
*/
@Schema(description = "性别0未知 1男 2女)")
@Schema(description = "性别0未知12女)")
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;

View File

@ -59,5 +59,5 @@ public interface RoleService extends BaseService<RoleVO, RoleDetailVO, RoleQuery
* 用户 ID
* @return 角色编码集合
*/
Set<String> listRoleCodeByUserId(Long userId);
Set<String> listCodeByUserId(Long userId);
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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>

View File

@ -4,7 +4,7 @@ import qs from 'query-string';
const BASE_URL = '/monitor/log';
export interface LogRecord {
logId?: string;
id?: string;
clientIp: string;
location: string;
browser: string;

View File

@ -4,11 +4,11 @@ import qs from 'query-string';
const BASE_URL = '/system/dept';
export interface DeptRecord {
deptId?: string;
deptName: string;
id?: string;
name: string;
parentId?: string;
description?: string;
deptSort: number;
sort: number;
status?: number;
createUserString?: string;
createTime?: string;
@ -19,7 +19,7 @@ export interface DeptRecord {
}
export interface DeptParam {
deptName?: string;
name?: string;
status?: number;
}

View File

@ -4,10 +4,10 @@ import qs from 'query-string';
const BASE_URL = '/system/menu';
export interface MenuRecord {
menuId?: string;
menuName: string;
id?: string;
title: string;
parentId?: string;
menuType: number;
type: number;
path?: string;
name?: string;
component?: string;
@ -16,7 +16,7 @@ export interface MenuRecord {
isCache: boolean;
isHidden: boolean;
permission?: string;
menuSort: number;
sort: number;
status?: number;
createUserString?: string;
createTime?: string;
@ -27,7 +27,7 @@ export interface MenuRecord {
}
export interface MenuParam {
menuName?: string;
name?: string;
status?: number;
}

View File

@ -4,10 +4,10 @@ import qs from 'query-string';
const BASE_URL = '/system/role';
export interface RoleRecord {
roleId?: string;
roleName: string;
roleCode?: string;
roleSort?: number;
id?: string;
name: string;
code?: string;
sort?: number;
description?: string;
menuIds?: Array<string>;
dataScope: number;
@ -21,7 +21,7 @@ export interface RoleRecord {
}
export interface RoleParam {
roleName?: string;
name?: string;
status?: number;
page?: number;
size?: number;

View File

@ -4,7 +4,7 @@ import qs from 'query-string';
const BASE_URL = '/system/user';
export interface UserRecord {
userId?: string;
id?: string;
username: string;
nickname: string;
gender: number;

View File

@ -13,7 +13,7 @@ import useAppStore from '../app';
const useLoginStore = defineStore('user', {
state: (): UserState => ({
userId: '',
id: '',
username: '',
nickname: '',
gender: 0,

View File

@ -1,5 +1,5 @@
export interface UserState {
userId: string;
id: string;
username: string;
nickname: string;
gender: number;

View File

@ -36,7 +36,7 @@
<!-- 列表区域 -->
<a-table
ref="tableRef"
row-key="logId"
row-key="id"
:loading="loading"
:pagination="{
showTotal: true,
@ -113,12 +113,14 @@
*/
const getList = (params: LoginLogParam = { ...queryParams.value }) => {
loading.value = true;
listLoginLog(params).then((res) => {
loginLogList.value = res.data.list;
total.value = res.data.total;
}).finally(() => {
loading.value = false;
});
listLoginLog(params)
.then((res) => {
loginLogList.value = res.data.list;
total.value = res.data.total;
})
.finally(() => {
loading.value = false;
});
};
getList();

View File

@ -45,7 +45,7 @@
<!-- 列表区域 -->
<a-table
ref="tableRef"
row-key="logId"
row-key="id"
:loading="loading"
:pagination="{
showTotal: true,

View File

@ -27,7 +27,7 @@
<!-- 列表区域 -->
<a-table
ref="tableRef"
row-key="logId"
row-key="id"
:loading="loading"
:pagination="{
showTotal: true,
@ -74,7 +74,7 @@
<a-table-column title="创建时间" data-index="createTime" />
<a-table-column title="操作" align="center">
<template #cell="{ record }">
<a-button type="text" size="small" title="查看详情" @click="toDetail(record.logId)">
<a-button type="text" size="small" title="查看详情" @click="toDetail(record.id)">
<template #icon><icon-eye /></template>详情
</a-button>
<a-button v-if="record.exceptionDetail" type="text" size="small" title="查看异常详情" @click="toExceptionDetail(record)">
@ -285,12 +285,14 @@
*/
const getList = (params: SystemLogParam = { ...queryParams.value }) => {
loading.value = true;
listSystemLog(params).then((res) => {
systemLogList.value = res.data.list;
total.value = res.data.total;
}).finally(() => {
loading.value = false;
});
listSystemLog(params)
.then((res) => {
systemLogList.value = res.data.list;
total.value = res.data.total;
})
.finally(() => {
loading.value = false;
});
};
getList();
@ -302,11 +304,13 @@
const toDetail = async (id: string) => {
visible.value = true;
loading.value = true;
getSystemLog(id).then((res) => {
systemLog.value = res.data;
}).finally(() => {
loading.value = false;
});
getSystemLog(id)
.then((res) => {
systemLog.value = res.data;
})
.finally(() => {
loading.value = false;
});
};
/**
@ -314,7 +318,7 @@
*/
const handleCancel = () => {
visible.value = false;
}
};
/**
* 查看异常详情
@ -332,7 +336,7 @@
const handleExceptionDetailCancel = () => {
exceptionDetail.value = '';
exceptionDetailVisible.value = false;
}
};
/**
* 查询

View File

@ -7,9 +7,9 @@
<!-- 搜索栏 -->
<div v-if="showQuery" class="header-query">
<a-form ref="queryRef" :model="queryParams" layout="inline">
<a-form-item field="deptName" hide-label>
<a-form-item field="name" hide-label>
<a-input
v-model="queryParams.deptName"
v-model="queryParams.name"
placeholder="输入部门名称搜索"
allow-clear
style="width: 150px"
@ -102,7 +102,7 @@
:pagination="false"
:default-expand-all-rows="true"
:hide-expand-button-on-empty="true"
row-key="deptId"
row-key="id"
:bordered="false"
:stripe="true"
:loading="loading"
@ -111,17 +111,17 @@
@selection-change="handleSelectionChange"
>
<template #columns>
<a-table-column title="部门名称" data-index="deptName">
<a-table-column title="部门名称">
<template #cell="{ record }">
<a-link @click="toDetail(record.deptId)">{{
record.deptName
<a-link @click="toDetail(record.id)">{{
record.name
}}</a-link>
</template>
</a-table-column>
<a-table-column
title="部门排序"
align="center"
data-index="deptSort"
data-index="sort"
/>
<a-table-column title="状态" align="center" data-index="status">
<template #cell="{ record }">
@ -144,14 +144,14 @@
type="text"
size="small"
title="修改"
@click="toUpdate(record.deptId)"
@click="toUpdate(record.id)"
>
<template #icon><icon-edit /></template>修改
</a-button>
<a-popconfirm
content="确定要删除当前选中的数据吗?如果存在下级部门则一并删除,此操作不能撤销!"
type="warning"
@ok="handleDelete([record.deptId])"
@ok="handleDelete([record.id])"
>
<a-button
v-permission="['system:dept:delete']"
@ -189,12 +189,12 @@
:fallback-option="false"
/>
</a-form-item>
<a-form-item label="部门名称" field="deptName">
<a-input v-model="form.deptName" placeholder="请输入部门名称" />
<a-form-item label="部门名称" field="name">
<a-input v-model="form.name" placeholder="请输入部门名称" />
</a-form-item>
<a-form-item label="部门排序" field="deptSort">
<a-form-item label="部门排序" field="sort">
<a-input-number
v-model="form.deptSort"
v-model="form.sort"
placeholder="请输入部门排序"
:min="1"
mode="button"
@ -229,7 +229,7 @@
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ dept.deptName }}</span>
<span v-else>{{ dept.name }}</span>
</a-descriptions-item>
<a-descriptions-item label="上级部门">
<a-skeleton v-if="detailLoading" :animation="true">
@ -250,7 +250,7 @@
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ dept.deptSort }}</span>
<span v-else>{{ dept.sort }}</span>
</a-descriptions-item>
<a-descriptions-item label="创建人">
<a-skeleton v-if="detailLoading" :animation="true">
@ -308,8 +308,8 @@
const deptList = ref<DeptRecord[]>([]);
const dept = ref<DeptRecord>({
deptName: '',
deptSort: 0,
name: '',
sort: 0,
description: '',
status: 1,
createUserString: '',
@ -333,16 +333,16 @@
const data = reactive({
//
queryParams: {
deptName: undefined,
name: undefined,
status: undefined,
sort: ['parentId,asc', 'deptSort,asc', 'createTime,desc'],
sort: ['parentId,asc', 'sort,asc', 'createTime,desc'],
},
//
form: {} as DeptRecord,
//
rules: {
deptName: [{ required: true, message: '请输入部门名称' }],
deptSort: [{ required: true, message: '请输入部门排序' }],
name: [{ required: true, message: '请输入部门名称' }],
sort: [{ required: true, message: '请输入部门排序' }],
},
});
const { queryParams, form, rules } = toRefs(data);
@ -402,11 +402,11 @@
*/
const reset = () => {
form.value = {
deptId: undefined,
deptName: '',
id: undefined,
name: '',
parentId: undefined,
description: '',
deptSort: 999,
sort: 999,
status: 1,
};
proxy.$refs.formRef?.resetFields();
@ -426,7 +426,7 @@
const handleOk = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
if (form.value.deptId !== undefined) {
if (form.value.id !== undefined) {
updateDept(form.value).then((res) => {
handleCancel();
getList();
@ -507,8 +507,8 @@
if (rowKeys.find((key: any) => key === rowKey)) {
if (record.children) {
record.children.forEach((r) => {
proxy.$refs.tableRef.select(r.deptId);
rowKeys.push(r.deptId);
proxy.$refs.tableRef.select(r.id);
rowKeys.push(r.id);
if (r.children) {
handleSelect(rowKeys, rowKey, r);
}
@ -516,8 +516,8 @@
}
} else if (record.children) {
record.children.forEach((r) => {
rowKeys.splice(rowKeys.findIndex((key: number | undefined) => key === r.deptId), 1);
proxy.$refs.tableRef.select(r.deptId, false);
rowKeys.splice(rowKeys.findIndex((key: number | undefined) => key === r.id), 1);
proxy.$refs.tableRef.select(r.id, false);
if (r.children) {
handleSelect(rowKeys, rowKey, r);
}

View File

@ -7,10 +7,10 @@
<!-- 搜索栏 -->
<div v-if="showQuery" class="header-query">
<a-form ref="queryRef" :model="queryParams" layout="inline">
<a-form-item field="menuName" hide-label>
<a-form-item field="title" hide-label>
<a-input
v-model="queryParams.menuName"
placeholder="输入菜单名称搜索"
v-model="queryParams.title"
placeholder="输入菜单标题搜索"
allow-clear
style="width: 150px"
@press-enter="handleQuery"
@ -105,7 +105,7 @@
:pagination="false"
:default-expand-all-rows="true"
:hide-expand-button-on-empty="true"
row-key="menuId"
row-key="id"
:bordered="false"
:stripe="true"
:loading="loading"
@ -114,13 +114,13 @@
@selection-change="handleSelectionChange"
>
<template #columns>
<a-table-column title="菜单名称" data-index="menuName" />
<a-table-column title="菜单标题" data-index="title" />
<a-table-column title="图标" align="center">
<template #cell="{ record }">
<svg-icon :icon-class="record.icon ? record.icon : ''" />
</template>
</a-table-column>
<a-table-column title="排序" align="center" data-index="menuSort" />
<a-table-column title="排序" align="center" data-index="sort" />
<a-table-column title="权限标识" data-index="permission" />
<a-table-column title="组件路径" data-index="component" />
<a-table-column title="状态" align="center">
@ -160,14 +160,14 @@
type="text"
size="small"
title="修改"
@click="toUpdate(record.menuId)"
@click="toUpdate(record.id)"
>
<template #icon><icon-edit /></template>修改
</a-button>
<a-popconfirm
content="确定要删除当前选中的数据吗?如果存在下级菜单则一并删除,此操作不能撤销!"
type="warning"
@ok="handleDelete([record.menuId])"
@ok="handleDelete([record.id])"
>
<a-button
v-permission="['system:menu:delete']"
@ -202,14 +202,14 @@
:label-col-style="{ width: '85px' }"
size="large"
>
<a-form-item label="菜单类型" field="menuType" lab>
<a-radio-group v-model="form.menuType" type="button">
<a-form-item label="菜单类型" field="type" lab>
<a-radio-group v-model="form.type" type="button">
<a-radio :value="1" style="width: 57px">目录</a-radio>
<a-radio :value="2" style="width: 57px">菜单</a-radio>
<a-radio :value="3" style="width: 57px">按钮</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item v-if="form.menuType !== 3" label="菜单图标" field="icon">
<a-form-item v-if="form.type !== 3" label="菜单图标" field="icon">
<a-popover
v-model:popup-visible="showChooseIcon"
position="bottom"
@ -236,16 +236,16 @@
</template>
</a-popover>
</a-form-item>
<a-form-item label="菜单名称" field="menuName">
<a-form-item label="菜单标题" field="title">
<a-input
v-model="form.menuName"
placeholder="请输入菜单名称"
v-model="form.title"
placeholder="请输入菜单标题"
style="width: 182px"
/>
</a-form-item>
<a-form-item label="菜单排序" field="menuSort">
<a-form-item label="菜单排序" field="sort">
<a-input-number
v-model="form.menuSort"
v-model="form.sort"
placeholder="请输入菜单排序"
:min="1"
mode="button"
@ -253,7 +253,7 @@
/>
</a-form-item>
<a-form-item
v-if="form.menuType !== 1"
v-if="form.type !== 1"
label="权限标识"
field="permission"
>
@ -263,7 +263,7 @@
style="width: 182px"
/>
</a-form-item>
<a-form-item v-if="form.menuType !== 3" label="路由地址" field="path">
<a-form-item v-if="form.type !== 3" label="路由地址" field="path">
<a-input
v-model="form.path"
placeholder="请输入路由地址"
@ -271,7 +271,7 @@
/>
</a-form-item>
<a-form-item
v-if="!form.isExternal && form.menuType === 2"
v-if="!form.isExternal && form.type === 2"
label="组件名称"
field="name"
>
@ -282,7 +282,7 @@
/>
</a-form-item>
<a-form-item
v-if="!form.isExternal && form.menuType === 2"
v-if="!form.isExternal && form.type === 2"
label="组件路径"
field="component"
>
@ -294,7 +294,7 @@
</a-form-item>
<br />
<a-form-item
v-if="form.menuType !== 3"
v-if="form.type !== 3"
label="是否外链"
field="isExternal"
>
@ -304,7 +304,7 @@
</a-radio-group>
</a-form-item>
<a-form-item
v-if="form.menuType === 2"
v-if="form.type === 2"
label="是否缓存"
field="isCache"
>
@ -314,7 +314,7 @@
</a-radio-group>
</a-form-item>
<a-form-item
v-if="form.menuType !== 3"
v-if="form.type !== 3"
label="是否隐藏"
field="isHidden"
>
@ -375,20 +375,20 @@
const data = reactive({
//
queryParams: {
menuName: undefined,
title: undefined,
status: undefined,
sort: ['parentId,asc', 'menuSort,asc', 'createTime,desc'],
sort: ['parentId,asc', 'sort,asc', 'createTime,desc'],
},
//
form: {} as MenuRecord,
//
rules: {
menuName: [{ required: true, message: '请输入菜单名称' }],
title: [{ required: true, message: '请输入菜单标题' }],
path: [{ required: true, message: '请输入路由地址' }],
name: [{ required: true, message: '请输入组件名称' }],
component: [{ required: true, message: '请输入组件路径' }],
permission: [{ required: true, message: '请输入权限标识' }],
menuSort: [{ required: true, message: '请输入菜单排序' }],
sort: [{ required: true, message: '请输入菜单排序' }],
},
});
const { queryParams, form, rules } = toRefs(data);
@ -445,10 +445,10 @@
*/
const reset = () => {
form.value = {
menuId: undefined,
menuName: '',
id: undefined,
title: '',
parentId: undefined,
menuType: 1,
type: 1,
path: undefined,
name: undefined,
component: undefined,
@ -457,7 +457,7 @@
isCache: false,
isHidden: false,
permission: undefined,
menuSort: 999,
sort: 999,
status: 1,
};
proxy.$refs.formRef?.resetFields();
@ -477,7 +477,7 @@
const handleOk = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
if (form.value.menuId !== undefined) {
if (form.value.id !== undefined) {
updateMenu(form.value).then((res) => {
handleCancel();
getList();
@ -533,8 +533,8 @@
if (rowKeys.find((key: any) => key === rowKey)) {
if (record.children) {
record.children.forEach((r) => {
proxy.$refs.tableRef.select(r.menuId);
rowKeys.push(r.menuId);
proxy.$refs.tableRef.select(r.id);
rowKeys.push(r.id);
if (r.children) {
handleSelect(rowKeys, rowKey, r);
}
@ -543,10 +543,10 @@
} else if (record.children) {
record.children.forEach((r) => {
rowKeys.splice(
rowKeys.findIndex((key: number | undefined) => key === r.menuId),
rowKeys.findIndex((key: number | undefined) => key === r.id),
1
);
proxy.$refs.tableRef.select(r.menuId, false);
proxy.$refs.tableRef.select(r.id, false);
if (r.children) {
handleSelect(rowKeys, rowKey, r);
}

View File

@ -7,9 +7,9 @@
<!-- 搜索栏 -->
<div v-if="showQuery" class="header-query">
<a-form ref="queryRef" :model="queryParams" layout="inline">
<a-form-item field="roleName" hide-label>
<a-form-item field="name" hide-label>
<a-input
v-model="queryParams.roleName"
v-model="queryParams.name"
placeholder="输入角色名称搜索"
allow-clear
style="width: 150px"
@ -105,7 +105,7 @@
total: total,
current: queryParams.page,
}"
row-key="roleId"
row-key="id"
:bordered="false"
:stripe="true"
:loading="loading"
@ -115,15 +115,15 @@
@selection-change="handleSelectionChange"
>
<template #columns>
<a-table-column title="ID" data-index="roleId" />
<a-table-column title="角色名称" data-index="roleName">
<a-table-column title="ID" data-index="id" />
<a-table-column title="角色名称" data-index="name">
<template #cell="{ record }">
<a-link @click="toDetail(record.roleId)">{{
record.roleName
<a-link @click="toDetail(record.id)">{{
record.name
}}</a-link>
</template>
</a-table-column>
<a-table-column title="角色编码" data-index="roleCode" />
<a-table-column title="角色编码" data-index="code" />
<a-table-column title="数据权限">
<template #cell="{ record }">
<span v-if="record.dataScope === 1">全部数据权限</span>
@ -136,7 +136,7 @@
<a-table-column
title="角色排序"
align="center"
data-index="roleSort"
data-index="sort"
/>
<a-table-column title="状态" align="center" data-index="status">
<template #cell="{ record }">
@ -160,14 +160,14 @@
size="small"
title="修改"
:disabled="record.disabled"
@click="toUpdate(record.roleId)"
@click="toUpdate(record.id)"
>
<template #icon><icon-edit /></template>修改
</a-button>
<a-popconfirm
content="确定要删除当前选中的数据吗?"
type="warning"
@ok="handleDelete([record.roleId])"
@ok="handleDelete([record.id])"
>
<a-button
v-permission="['system:role:delete']"
@ -198,15 +198,15 @@
<a-form ref="formRef" :model="form" :rules="rules" size="large">
<fieldset>
<legend>基础信息</legend>
<a-form-item label="角色名称" field="roleName">
<a-input v-model="form.roleName" placeholder="请输入角色名称" />
<a-form-item label="角色名称" field="name">
<a-input v-model="form.name" placeholder="请输入角色名称" />
</a-form-item>
<a-form-item label="角色编码" field="roleCode">
<a-input v-model="form.roleCode" placeholder="请输入角色编码" />
<a-form-item label="角色编码" field="code">
<a-input v-model="form.code" placeholder="请输入角色编码" />
</a-form-item>
<a-form-item label="角色排序" field="roleSort">
<a-form-item label="角色排序" field="sort">
<a-input-number
v-model="form.roleSort"
v-model="form.sort"
placeholder="请输入角色排序"
:min="1"
mode="button"
@ -294,13 +294,13 @@
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.roleName }}</span>
<span v-else>{{ role.name }}</span>
</a-descriptions-item>
<a-descriptions-item label="角色编码">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.roleCode }}</span>
<span v-else>{{ role.code }}</span>
</a-descriptions-item>
<a-descriptions-item label="状态">
<a-skeleton v-if="detailLoading" :animation="true">
@ -406,8 +406,8 @@
const roleList = ref<RoleRecord[]>([]);
const role = ref<RoleRecord>({
roleName: '',
roleCode: '',
name: '',
code: '',
status: 1,
dataScope: 1,
createUserString: '',
@ -443,7 +443,7 @@
const data = reactive({
//
queryParams: {
roleName: undefined,
name: undefined,
status: undefined,
page: 1,
size: 10,
@ -453,9 +453,9 @@
form: {} as RoleRecord,
//
rules: {
roleName: [{ required: true, message: '请输入角色名称' }],
name: [{ required: true, message: '请输入角色名称' }],
dataScope: [{ required: true, message: '请选择数据权限' }],
roleSort: [{ required: true, message: '请输入角色排序' }],
sort: [{ required: true, message: '请输入角色排序' }],
},
});
const { queryParams, form, rules } = toRefs(data);
@ -552,12 +552,12 @@
proxy.$refs.menuRef?.expandAll(menuExpandAll.value);
proxy.$refs.deptRef?.expandAll(deptExpandAll.value);
form.value = {
roleId: undefined,
roleName: '',
roleCode: undefined,
id: undefined,
name: '',
code: undefined,
dataScope: 4,
description: '',
roleSort: 999,
sort: 999,
status: 1,
menuIds: [],
deptIds: [],
@ -618,7 +618,7 @@
const handleOk = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
if (form.value.roleId !== undefined) {
if (form.value.id !== undefined) {
form.value.menuIds = getMenuAllCheckedKeys();
form.value.deptIds = getDeptAllCheckedKeys();
updateRole(form.value).then((res) => {

View File

@ -3,14 +3,14 @@
<!-- 列表区域 -->
<a-table
ref="tableRef"
row-key="logId"
row-key="id"
:loading="loading"
:pagination="{
showTotal: true,
showPageSize: true,
total: total,
current: queryParams.page,
}"
showTotal: true,
showPageSize: true,
total: total,
current: queryParams.page,
}"
:data="operationLogList"
:bordered="false"
:stripe="true"
@ -70,7 +70,7 @@
const data = reactive({
//
queryParams: {
uid: loginStore.userId,
uid: loginStore.id,
page: 1,
size: 10,
sort: ['createTime,desc'],
@ -85,12 +85,14 @@
*/
const getList = (params: OperationLogParam = { ...queryParams.value }) => {
loading.value = true;
listOperationLog(params).then((res) => {
operationLogList.value = res.data.list;
total.value = res.data.total;
}).finally(() => {
loading.value = false;
});
listOperationLog(params)
.then((res) => {
operationLogList.value = res.data.list;
total.value = res.data.total;
})
.finally(() => {
loading.value = false;
});
};
getList();

View File

@ -51,10 +51,10 @@
<div v-else>{{ $t('userCenter.panel.unknown') }}</div>
</a-descriptions-item>
<a-descriptions-item :label="$t('userCenter.panel.label.phone')">{{
loginStore.phone
loginStore.phone || '暂无'
}}</a-descriptions-item>
<a-descriptions-item :label="$t('userCenter.panel.label.email')">{{
loginStore.email
loginStore.email || '暂无'
}}</a-descriptions-item>
<a-descriptions-item :label="$t('userCenter.panel.label.deptName')">{{
loginStore.deptName

View File

@ -125,7 +125,7 @@
total: total,
current: queryParams.page,
}"
row-key="userId"
row-key="id"
:bordered="false"
:stripe="true"
:loading="loading"
@ -138,10 +138,10 @@
@selection-change="handleSelectionChange"
>
<template #columns>
<a-table-column title="ID" data-index="userId" />
<a-table-column title="ID" data-index="id" />
<a-table-column title="用户名">
<template #cell="{ record }">
<a-link @click="toDetail(record.userId)">{{
<a-link @click="toDetail(record.id)">{{
record.username
}}</a-link>
</template>
@ -197,14 +197,14 @@
type="text"
size="small"
title="修改"
@click="toUpdate(record.userId)"
@click="toUpdate(record.id)"
>
<template #icon><icon-edit /></template>
</a-button>
<a-popconfirm
content="确定要删除当前选中的数据吗?"
type="warning"
@ok="handleDelete([record.userId])"
@ok="handleDelete([record.id])"
>
<a-button
v-permission="['system:user:delete']"
@ -219,7 +219,7 @@
<a-popconfirm
content="确定要重置当前用户的密码吗?"
type="warning"
@ok="handleResetPassword(record.userId)"
@ok="handleResetPassword(record.id)"
>
<a-button
v-permission="['system:user:password:reset']"
@ -235,7 +235,7 @@
type="text"
size="small"
title="分配角色"
@click="toUpdateRole(record.userId)"
@click="toUpdateRole(record.id)"
>
<template #icon><svg-icon icon-class="reference" /></template>
</a-button>
@ -492,8 +492,8 @@
username: '',
nickname: '',
gender: 1,
email: undefined,
phone: undefined,
email: undefined,
status: 1,
pwdResetTime: '',
createUserString: '',
@ -552,7 +552,7 @@
* @param name 名称
*/
const getDeptTree = (name: string) => {
listDeptTree({ deptName: name }).then((res) => {
listDeptTree({ name }).then((res) => {
deptTree.value = res.data;
setTimeout(() => {
proxy.$refs.deptTreeRef.expandAll();
@ -656,7 +656,7 @@
*/
const reset = () => {
form.value = {
userId: undefined,
id: undefined,
username: '',
nickname: '',
gender: 1,
@ -686,7 +686,7 @@
const handleOk = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
if (form.value.userId !== undefined) {
if (form.value.id !== undefined) {
updateUser(form.value).then((res) => {
handleCancel();
getList();
@ -708,8 +708,8 @@
*/
const handleUpdateRole = () => {
proxy.$refs.userRoleFormRef.validate((valid: any) => {
if (!valid && form.value.userId !== undefined) {
updateUserRole({ roleIds: form.value.roleIds }, form.value.userId).then(
if (!valid && form.value.id !== undefined) {
updateUserRole({ roleIds: form.value.roleIds }, form.value.id).then(
(res) => {
handleCancel();
getList();

View File

@ -74,7 +74,7 @@ public class UserCenterController {
@PatchMapping("/basic/info")
public R updateBasicInfo(@Validated @RequestBody UpdateBasicInfoRequest updateBasicInfoRequest) {
UserRequest userRequest = new UserRequest();
userRequest.setUserId(LoginHelper.getUserId());
userRequest.setId(LoginHelper.getUserId());
BeanUtil.copyProperties(updateBasicInfoRequest, userRequest);
userService.update(userRequest);
return R.ok("修改成功");

View File

@ -46,11 +46,11 @@ INSERT IGNORE INTO `sys_dept` VALUES (8, '研发二组', 3, '系统初始部门'
-- 初始化默认角色
INSERT IGNORE INTO `sys_role` VALUES (1, '超级管理员', 'admin', 1, '系统初始角色', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_role` VALUES (2, '测试人员', 'test', 5, '系统初始角色', 2, 2, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_role` VALUES (2, '测试人员', 'test', 5, '系统初始角色', 2, 1, 1, NOW(), 1, NOW());
-- 初始化默认用户admin/admin123test/123456
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, 'charles7c@126.com', '18888888888', NULL, '系统初始用户', 1, NOW(), 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 2, NULL, NULL, NULL, '系统初始用户', 2, NOW(), 2, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 2, NULL, NULL, NULL, '系统初始用户', 2, NOW(), 5, 1, NOW(), 1, NOW());
-- 初始化默认角色和菜单关联数据
INSERT IGNORE INTO `sys_role_menu` VALUES (2, 1000);

View File

@ -1,11 +1,11 @@
-- liquibase formatted sql
-- changeset Charles7c:1
CREATE TABLE IF NOT EXISTS `sys_menu` (
`menu_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '菜单ID',
`menu_name` varchar(255) NOT NULL COMMENT '菜单名称',
CREATE TABLE IF NOT EXISTS `sys_menu` (
`id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL COMMENT '菜单标题',
`parent_id` bigint(20) unsigned DEFAULT 0 COMMENT '上级菜单ID',
`menu_type` tinyint(1) unsigned DEFAULT 1 COMMENT '菜单类型1目录 2菜单 3按钮)',
`type` tinyint(1) unsigned DEFAULT 1 COMMENT '菜单类型1目录2菜单3按钮)',
`path` varchar(512) DEFAULT NULL COMMENT '路由地址',
`name` varchar(255) DEFAULT NULL COMMENT '组件名称',
`component` varchar(255) DEFAULT NULL COMMENT '组件路径',
@ -14,82 +14,82 @@ CREATE TABLE IF NOT EXISTS `sys_menu` (
`is_cache` bit(1) DEFAULT b'0' COMMENT '是否缓存',
`is_hidden` bit(1) DEFAULT b'0' COMMENT '是否隐藏',
`permission` varchar(255) DEFAULT NULL COMMENT '权限标识',
`menu_sort` int(11) unsigned DEFAULT 999 COMMENT '菜单排序',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用)',
`sort` int(11) unsigned DEFAULT 999 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 (`menu_id`) USING BTREE,
PRIMARY KEY (`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_dept` (
`dept_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '部门ID',
`dept_name` varchar(255) NOT NULL COMMENT '部门名称',
CREATE TABLE IF NOT EXISTS `sys_dept` (
`id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) NOT NULL COMMENT '部门名称',
`parent_id` bigint(20) unsigned DEFAULT 0 COMMENT '上级部门ID',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`dept_sort` int(11) unsigned DEFAULT 999 COMMENT '部门排序',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用)',
`sort` int(11) unsigned DEFAULT 999 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,
PRIMARY KEY (`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_role` (
`role_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '角色ID',
`role_name` varchar(255) NOT NULL COMMENT '角色名称',
`role_code` varchar(255) DEFAULT NULL COMMENT '角色编码',
`data_scope` tinyint(1) DEFAULT 4 COMMENT '数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定义数据权限)',
CREATE TABLE IF NOT EXISTS `sys_role` (
`id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) NOT NULL COMMENT '角色名称',
`code` varchar(255) NOT NULL COMMENT '角色编码',
`data_scope` tinyint(1) DEFAULT 4 COMMENT '数据权限1全部数据权限2本部门及以下数据权限3本部门数据权限4仅本人数据权限5自定义数据权限)',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`role_sort` int(11) unsigned DEFAULT 999 COMMENT '角色排序',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用)',
`sort` int(11) unsigned DEFAULT 999 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 (`role_id`) USING BTREE,
PRIMARY KEY (`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_role_menu` (
CREATE TABLE IF NOT EXISTS `sys_role_menu` (
`role_id` bigint(20) unsigned NOT NULL COMMENT '角色ID',
`menu_id` bigint(20) unsigned NOT NULL COMMENT '菜单ID',
PRIMARY KEY (`role_id`,`menu_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和菜单关联表';
CREATE TABLE IF NOT EXISTS `sys_role_dept` (
CREATE TABLE IF NOT EXISTS `sys_role_dept` (
`role_id` bigint(20) unsigned NOT NULL COMMENT '角色ID',
`dept_id` bigint(20) unsigned NOT NULL COMMENT '部门ID',
PRIMARY KEY (`role_id`,`dept_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和部门关联表';
CREATE TABLE IF NOT EXISTS `sys_user` (
`user_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '用户ID',
CREATE TABLE IF NOT EXISTS `sys_user` (
`id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'ID',
`username` varchar(255) NOT NULL COMMENT '用户名',
`nickname` varchar(255) DEFAULT NULL COMMENT '昵称',
`password` varchar(255) DEFAULT NULL COMMENT '密码',
`gender` tinyint(1) unsigned DEFAULT 0 COMMENT '性别0未知 1男 2女)',
`gender` tinyint(1) unsigned DEFAULT 0 COMMENT '性别0未知12女)',
`email` varchar(255) DEFAULT NULL COMMENT '邮箱',
`phone` varchar(255) DEFAULT NULL COMMENT '手机号码',
`avatar` varchar(255) DEFAULT NULL COMMENT '头像地址',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用)',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用2禁用)',
`pwd_reset_time` datetime DEFAULT NULL COMMENT '最后一次修改密码时间',
`dept_id` bigint(20) unsigned DEFAULT NULL COMMENT '部门ID',
`dept_id` bigint(20) unsigned NOT NULL COMMENT '部门ID',
`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 (`user_id`) USING BTREE,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uk_username`(`username`) USING BTREE,
UNIQUE INDEX `uk_email`(`email`) USING BTREE,
INDEX `idx_dept_id`(`dept_id`) USING BTREE,
@ -97,14 +97,14 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
INDEX `idx_update_user`(`update_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
CREATE TABLE IF NOT EXISTS `sys_user_role` (
CREATE TABLE IF NOT EXISTS `sys_user_role` (
`user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
`role_id` bigint(20) unsigned NOT NULL COMMENT '角色ID',
PRIMARY KEY (`user_id`,`role_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和角色关联表';
CREATE TABLE IF NOT EXISTS `sys_log` (
`log_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '日志ID',
`id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'ID',
`description` varchar(255) NOT NULL COMMENT '日志描述',
`module` varchar(255) NOT NULL COMMENT '所属模块',
`request_url` varchar(512) NOT NULL COMMENT '请求URL',
@ -115,7 +115,7 @@ CREATE TABLE IF NOT EXISTS `sys_log` (
`response_headers` text DEFAULT NULL COMMENT '响应头',
`response_body` mediumtext DEFAULT NULL COMMENT '响应体',
`elapsed_time` bigint(20) unsigned NOT NULL COMMENT '请求耗时ms',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '操作状态1成功 2失败)',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '操作状态1成功2失败)',
`client_ip` varchar(255) DEFAULT NULL COMMENT '客户端IP',
`location` varchar(512) DEFAULT NULL COMMENT 'IP归属地',
`browser` varchar(255) DEFAULT NULL COMMENT '浏览器',
@ -123,6 +123,6 @@ CREATE TABLE IF NOT EXISTS `sys_log` (
`exception_detail` mediumtext DEFAULT NULL COMMENT '异常详情',
`create_user` bigint(20) unsigned DEFAULT NULL COMMENT '创建人',
`create_time` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`log_id`) USING BTREE,
INDEX `idx_createUser`(`create_user`) USING BTREE
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_create_user`(`create_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统日志表';