From 405c821e2a811d142543267e3da48900eda2ff44 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Mon, 6 Mar 2023 00:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=9A:fire:=20=E5=9F=BA?= =?UTF-8?q?=E4=BA=8E=E9=98=BF=E9=87=8C=E5=B7=B4=E5=B7=B4=20Java=20?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=89=8B=E5=86=8C(=E9=BB=84=E5=B1=B1?= =?UTF-8?q?=E7=89=88)=E9=87=8D=E6=9E=84=E5=90=84=E8=A1=A8=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E7=BB=93=E6=9E=84=EF=BC=88=E7=AE=80=E5=8C=96=E5=88=97?= =?UTF-8?q?=E5=90=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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; --- .../charles7c/cnadmin/common/base/BaseDO.java | 7 ++ .../cnadmin/common/base/BaseRequest.java | 12 ++ .../charles7c/cnadmin/common/base/BaseVO.java | 7 ++ .../cnadmin/common/model/dto/LoginUser.java | 4 +- .../common/util/helper/LoginHelper.java | 4 +- .../cnadmin/monitor/model/entity/LogDO.java | 6 +- .../monitor/model/query/LoginLogQuery.java | 4 +- .../model/query/OperationLogQuery.java | 18 +-- .../cnadmin/monitor/model/vo/LogVO.java | 6 + .../cnadmin/monitor/model/vo/LoginLogVO.java | 14 +-- .../monitor/model/vo/OperationLogVO.java | 8 +- .../monitor/model/vo/SystemLogDetailVO.java | 42 +++---- .../cnadmin/monitor/model/vo/SystemLogVO.java | 28 ++--- .../auth/model/request/LoginRequest.java | 4 +- .../cnadmin/auth/model/vo/UserInfoVO.java | 14 +-- .../auth/service/impl/LoginServiceImpl.java | 4 +- .../service/impl/PermissionServiceImpl.java | 2 +- .../cnadmin/system/model/entity/DeptDO.java | 13 +-- .../cnadmin/system/model/entity/MenuDO.java | 19 +-- .../cnadmin/system/model/entity/RoleDO.java | 17 +-- .../cnadmin/system/model/entity/UserDO.java | 11 +- .../cnadmin/system/model/query/DeptQuery.java | 6 +- .../cnadmin/system/model/query/MenuQuery.java | 10 +- .../cnadmin/system/model/query/RoleQuery.java | 8 +- .../cnadmin/system/model/query/UserQuery.java | 4 +- .../system/model/request/DeptRequest.java | 13 +-- .../system/model/request/MenuRequest.java | 69 +++++------ .../system/model/request/RoleRequest.java | 23 ++-- .../system/model/request/UserRequest.java | 50 ++++---- .../cnadmin/system/model/vo/DeptDetailVO.java | 32 +++-- .../cnadmin/system/model/vo/DeptVO.java | 34 +++--- .../cnadmin/system/model/vo/MenuVO.java | 109 ++++++++++-------- .../cnadmin/system/model/vo/RoleDetailVO.java | 21 ++-- .../cnadmin/system/model/vo/RoleVO.java | 22 ++-- .../cnadmin/system/model/vo/UserDetailVO.java | 15 +-- .../cnadmin/system/model/vo/UserVO.java | 28 ++--- .../cnadmin/system/service/RoleService.java | 2 +- .../system/service/impl/DeptServiceImpl.java | 18 +-- .../system/service/impl/MenuServiceImpl.java | 16 +-- .../system/service/impl/RoleServiceImpl.java | 45 ++++---- .../system/service/impl/UserServiceImpl.java | 20 ++-- .../src/main/resources/mapper/MenuMapper.xml | 14 +-- continew-admin-ui/src/api/monitor/log.ts | 2 +- continew-admin-ui/src/api/system/dept.ts | 8 +- continew-admin-ui/src/api/system/menu.ts | 10 +- continew-admin-ui/src/api/system/role.ts | 10 +- continew-admin-ui/src/api/system/user.ts | 2 +- .../src/store/modules/login/index.ts | 2 +- .../src/store/modules/login/types.ts | 2 +- .../src/views/monitor/log/login/index.vue | 16 +-- .../src/views/monitor/log/operation/index.vue | 2 +- .../src/views/monitor/log/system/index.vue | 34 +++--- .../src/views/system/dept/index.vue | 58 +++++----- .../src/views/system/menu/index.vue | 72 ++++++------ .../src/views/system/role/index.vue | 58 +++++----- .../user/center/components/operation-log.vue | 28 ++--- .../user/center/components/user-panel.vue | 4 +- .../src/views/system/user/index.vue | 26 ++--- .../system/UserCenterController.java | 2 +- .../changelog/v0.0.1/continew-admin_data.sql | 4 +- .../changelog/v0.0.1/continew-admin_table.sql | 68 +++++------ 61 files changed, 560 insertions(+), 651 deletions(-) diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseDO.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseDO.java index 07d85ca8..9412e666 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseDO.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseDO.java @@ -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; + /** * 创建人 */ diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseRequest.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseRequest.java index 86575396..687bfc7d 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseRequest.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseRequest.java @@ -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; + /** * 分组校验-创建 */ diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseVO.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseVO.java index 29bd1d0c..ca61963e 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseVO.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseVO.java @@ -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; + /** * 创建人 */ diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java index fad70902..0492c682 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/dto/LoginUser.java @@ -36,9 +36,9 @@ public class LoginUser implements Serializable { private static final long serialVersionUID = 1L; /** - * 用户ID + * ID */ - private Long userId; + private Long id; /** * 用户名 diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java index 812eac59..049b3b8a 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java @@ -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()); } /** diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/entity/LogDO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/entity/LogDO.java index ce97f2da..14506c5c 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/entity/LogDO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/entity/LogDO.java @@ -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; diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/LoginLogQuery.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/LoginLogQuery.java index 97768453..76963b05 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/LoginLogQuery.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/LoginLogQuery.java @@ -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; diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/OperationLogQuery.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/OperationLogQuery.java index a1e8b211..76b61ffd 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/OperationLogQuery.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/query/OperationLogQuery.java @@ -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 createTime; + + /** + * 操作人 + */ + @Schema(description = "操作人") + @Query(property = "createUser") + private Long uid; } diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LogVO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LogVO.java index c009a72e..9301c229 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LogVO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LogVO.java @@ -36,6 +36,12 @@ public class LogVO implements Serializable { private static final long serialVersionUID = 1L; + /** + * ID + */ + @Schema(description = "ID") + private Long id; + /** * 创建人 */ diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LoginLogVO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LoginLogVO.java index 8f1fac6d..f388e67b 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LoginLogVO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/LoginLogVO.java @@ -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; /** diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/OperationLogVO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/OperationLogVO.java index 798758cd..81ce96cf 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/OperationLogVO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/OperationLogVO.java @@ -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; /** diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogDetailVO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogDetailVO.java index 7531eb21..f99e893f 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogDetailVO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogDetailVO.java @@ -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; } diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogVO.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogVO.java index 57206113..3017dedd 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogVO.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/model/vo/SystemLogVO.java @@ -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; + /** * 错误信息 */ diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/request/LoginRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/request/LoginRequest.java index e8093a22..4c0fc380 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/request/LoginRequest.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/request/LoginRequest.java @@ -44,9 +44,9 @@ public class LoginRequest implements Serializable { private String username; /** - * 密码(加密后) + * 密码(加密) */ - @Schema(description = "密码(加密后)") + @Schema(description = "密码(加密)") @NotBlank(message = "密码不能为空") private String password; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java index 936455f5..bc0f5c5f 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/model/vo/UserInfoVO.java @@ -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; /** diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java index 638b5bfc..fa9a61cf 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/LoginServiceImpl.java @@ -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); diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/PermissionServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/PermissionServiceImpl.java index fcca8583..3007f0ba 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/PermissionServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/service/impl/PermissionServiceImpl.java @@ -54,6 +54,6 @@ public class PermissionServiceImpl implements PermissionService { @Override public Set listRoleCodeByUserId(Long userId) { - return roleService.listRoleCodeByUserId(userId); + return roleService.listCodeByUserId(userId); } } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DeptDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DeptDO.java index 84e7a97b..3e7e1a95 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DeptDO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DeptDO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/MenuDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/MenuDO.java index b3699190..2b941263 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/MenuDO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/MenuDO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/RoleDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/RoleDO.java index 42237425..5cbb201c 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/RoleDO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/RoleDO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java index 85f17711..81c5a87a 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/UserDO.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DeptQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DeptQuery.java index dd11106e..3e9d175b 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DeptQuery.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DeptQuery.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/MenuQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/MenuQuery.java index e47dfb2b..dee81cf0 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/MenuQuery.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/MenuQuery.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/RoleQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/RoleQuery.java index 2a7af807..24aa35b9 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/RoleQuery.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/RoleQuery.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/UserQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/UserQuery.java index 97636158..af428bdb 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/UserQuery.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/UserQuery.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DeptRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DeptRequest.java index 8482908d..b22555a3 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DeptRequest.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DeptRequest.java @@ -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; /** * 描述 diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/MenuRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/MenuRequest.java index a1a17cd0..86704d72 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/MenuRequest.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/MenuRequest.java @@ -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禁用) diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/RoleRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/RoleRequest.java index 95189565..624238d4 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/RoleRequest.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/RoleRequest.java @@ -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 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 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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/UserRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/UserRequest.java index e6c41db3..0511b59b 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/UserRequest.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/UserRequest.java @@ -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 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 roleIds; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java index 8a16c8b4..6227bc24 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptDetailVO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptVO.java index f7855d83..bcb6d55e 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DeptVO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/MenuVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/MenuVO.java index c40a87b0..693d94c8 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/MenuVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/MenuVO.java @@ -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; } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleDetailVO.java index fe69c4e9..7daf089d 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleDetailVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleDetailVO.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleVO.java index c696128f..cb9fa08f 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/RoleVO.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserDetailVO.java index 88713d71..71d5a35b 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserDetailVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserDetailVO.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java index 64b800df..adfeb2c0 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java @@ -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; diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/RoleService.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/RoleService.java index 269c6041..814d7bfb 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/RoleService.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/RoleService.java @@ -59,5 +59,5 @@ public interface RoleService extends BaseService listRoleCodeByUserId(Long userId); + Set listCodeByUserId(Long userId); } diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java index b68db2b9..86214f62 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java @@ -57,9 +57,9 @@ public class DeptServiceImpl extends BaseServiceImpl 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 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 this.get(detailVO.getParentId()).getDeptName())); + detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getName())); } } @@ -107,7 +107,7 @@ public class DeptServiceImpl extends BaseServiceImpl 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 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 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 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 list = menuService.list(null, null); - List menuIds = list.stream().map(MenuVO::getMenuId).collect(Collectors.toList()); + List 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(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 listNameByIds(List ids) { - List roleList = baseMapper.lambdaQuery().select(RoleDO::getRoleName).in(RoleDO::getRoleId, ids).list(); - return roleList.stream().map(RoleDO::getRoleName).collect(Collectors.toList()); + List roleList = baseMapper.lambdaQuery().select(RoleDO::getName).in(RoleDO::getId, ids).list(); + return roleList.stream().map(RoleDO::getName).collect(Collectors.toList()); } @Override - public Set listRoleCodeByUserId(Long userId) { + public Set listCodeByUserId(Long userId) { List roleIds = userRoleService.listRoleIdByUserId(userId); - List roleList = - baseMapper.lambdaQuery().select(RoleDO::getRoleCode).in(RoleDO::getRoleId, roleIds).list(); - return roleList.stream().map(RoleDO::getRoleCode).collect(Collectors.toSet()); + List 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 isExists, String.format("新增失败,'%s'已存在", username)); // 新增信息 @@ -83,7 +83,7 @@ public class UserServiceImpl extends BaseServiceImpl 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 deptService.get(detailVO.getDeptId()).getDeptName())); - List roleIdList = userRoleService.listRoleIdByUserId(detailVO.getUserId()); + detailVO.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(detailVO.getDeptId()).getName())); + List 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 diff --git a/continew-admin-ui/src/api/monitor/log.ts b/continew-admin-ui/src/api/monitor/log.ts index feff06a7..db123833 100644 --- a/continew-admin-ui/src/api/monitor/log.ts +++ b/continew-admin-ui/src/api/monitor/log.ts @@ -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; diff --git a/continew-admin-ui/src/api/system/dept.ts b/continew-admin-ui/src/api/system/dept.ts index eb209c94..3979afd2 100644 --- a/continew-admin-ui/src/api/system/dept.ts +++ b/continew-admin-ui/src/api/system/dept.ts @@ -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; } diff --git a/continew-admin-ui/src/api/system/menu.ts b/continew-admin-ui/src/api/system/menu.ts index 7a8b30ad..ffca539c 100644 --- a/continew-admin-ui/src/api/system/menu.ts +++ b/continew-admin-ui/src/api/system/menu.ts @@ -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; } diff --git a/continew-admin-ui/src/api/system/role.ts b/continew-admin-ui/src/api/system/role.ts index c206fc16..9807f34a 100644 --- a/continew-admin-ui/src/api/system/role.ts +++ b/continew-admin-ui/src/api/system/role.ts @@ -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; dataScope: number; @@ -21,7 +21,7 @@ export interface RoleRecord { } export interface RoleParam { - roleName?: string; + name?: string; status?: number; page?: number; size?: number; diff --git a/continew-admin-ui/src/api/system/user.ts b/continew-admin-ui/src/api/system/user.ts index a85174aa..385a89da 100644 --- a/continew-admin-ui/src/api/system/user.ts +++ b/continew-admin-ui/src/api/system/user.ts @@ -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; diff --git a/continew-admin-ui/src/store/modules/login/index.ts b/continew-admin-ui/src/store/modules/login/index.ts index 5ea60b8e..bdbf81dc 100644 --- a/continew-admin-ui/src/store/modules/login/index.ts +++ b/continew-admin-ui/src/store/modules/login/index.ts @@ -13,7 +13,7 @@ import useAppStore from '../app'; const useLoginStore = defineStore('user', { state: (): UserState => ({ - userId: '', + id: '', username: '', nickname: '', gender: 0, diff --git a/continew-admin-ui/src/store/modules/login/types.ts b/continew-admin-ui/src/store/modules/login/types.ts index ace7c33b..63a6627e 100644 --- a/continew-admin-ui/src/store/modules/login/types.ts +++ b/continew-admin-ui/src/store/modules/login/types.ts @@ -1,5 +1,5 @@ export interface UserState { - userId: string; + id: string; username: string; nickname: string; gender: number; diff --git a/continew-admin-ui/src/views/monitor/log/login/index.vue b/continew-admin-ui/src/views/monitor/log/login/index.vue index 5afb21f4..bad79736 100644 --- a/continew-admin-ui/src/views/monitor/log/login/index.vue +++ b/continew-admin-ui/src/views/monitor/log/login/index.vue @@ -36,7 +36,7 @@