review code.
This commit is contained in:
@@ -9,7 +9,9 @@ package com.orion.ops.framework.common.constant;
|
||||
*/
|
||||
public interface ErrorMessage {
|
||||
|
||||
String PARAM_MISSING = "{} 不能为空";
|
||||
String MISSING = "{} 不能为空";
|
||||
|
||||
String PARAM_MISSING = "参数不能为空";
|
||||
|
||||
String ID_MISSING = "id 不能为空";
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.orion.ops.framework.common.utils;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.spring.SpringHolder;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/7/18 11:23
|
||||
*/
|
||||
public class Valid extends com.orion.lang.utils.Valid {
|
||||
|
||||
private static final Validator VALIDATOR = SpringHolder.getBean(Validator.class);
|
||||
|
||||
/**
|
||||
* 验证枚举
|
||||
*
|
||||
* @param of of method
|
||||
* @param obj obj
|
||||
* @param <T> param
|
||||
* @param <E> enum
|
||||
* @return enum
|
||||
*/
|
||||
public static <T, E extends Enum<?>> E valid(Function<T, E> of, T obj) {
|
||||
return notNull(of.apply(obj), ErrorMessage.INVALID_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证对象
|
||||
*
|
||||
* @param obj obj
|
||||
* @param groups groups
|
||||
* @param <T> T
|
||||
* @return obj
|
||||
*/
|
||||
public static <T> T valid(T obj, Class<?>... groups) {
|
||||
notNull(obj, ErrorMessage.PARAM_MISSING);
|
||||
// 验证对象
|
||||
Set<ConstraintViolation<T>> set = VALIDATOR.validate(obj, groups);
|
||||
if (!set.isEmpty()) {
|
||||
throw new ConstraintViolationException(set);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package ${package.ServiceImpl};
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
#foreach($pkg in ${customFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
|
||||
@@ -62,13 +62,12 @@ public class RedisUtils {
|
||||
* 获取并且设置 json
|
||||
*
|
||||
* @param define define
|
||||
* @param type type
|
||||
* @param processor processor
|
||||
* @param params params
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(CacheKeyDefine define, Class<T> type, Consumer<T> processor, Object... params) {
|
||||
processSetJson(define.format(params), define, type, processor);
|
||||
public static <T> void processSetJson(CacheKeyDefine define, Consumer<T> processor, Object... params) {
|
||||
processSetJson(define.format(params), define, processor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,17 +75,17 @@ public class RedisUtils {
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param type type
|
||||
* @param processor processor
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(String key, CacheKeyDefine define, Class<T> type, Consumer<T> processor) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> void processSetJson(String key, CacheKeyDefine define, Consumer<T> processor) {
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
// 转换
|
||||
T cache = JSON.parseObject(value, type);
|
||||
T cache = (T) JSON.parseObject(value, define.getType());
|
||||
// 执行处理逻辑
|
||||
processor.accept(cache);
|
||||
// 重新设置
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.orion.lang.exception.argument.InvalidArgumentException;
|
||||
import com.orion.lang.exception.argument.RpcWrapperException;
|
||||
import com.orion.lang.utils.Exceptions;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -67,7 +68,7 @@ public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = MissingServletRequestParameterException.class)
|
||||
public HttpWrapper<?> missingServletRequestParameterExceptionHandler(MissingServletRequestParameterException ex) {
|
||||
String message = Strings.format(ErrorMessage.PARAM_MISSING, ex.getParameterName());
|
||||
String message = Strings.format(ErrorMessage.MISSING, ex.getParameterName());
|
||||
log.error("missingServletRequestParameterExceptionHandler {}", message);
|
||||
return ErrorCode.BAD_REQUEST.wrapper().msg(message);
|
||||
}
|
||||
@@ -75,15 +76,15 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(value = BindException.class)
|
||||
public HttpWrapper<?> paramBindExceptionHandler(BindException ex) {
|
||||
FieldError error = Objects.requireNonNull(ex.getFieldError());
|
||||
String message = error.getField() + " " + error.getDefaultMessage();
|
||||
String message = error.getField() + Const.SPACE + error.getDefaultMessage();
|
||||
log.error("paramBindExceptionHandler {}", message);
|
||||
return ErrorCode.BAD_REQUEST.wrapper().msg(message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ConstraintViolationException.class)
|
||||
public HttpWrapper<?> constraintViolationExceptionHandler(ConstraintViolationException ex) {
|
||||
ConstraintViolation<?> constraintViolation = ex.getConstraintViolations().iterator().next();
|
||||
String message = Objects.requireNonNull(constraintViolation).getMessage();
|
||||
ConstraintViolation<?> violation = Objects.requireNonNull(ex.getConstraintViolations().iterator().next());
|
||||
String message = violation.getPropertyPath().toString() + Const.SPACE + violation.getMessage();
|
||||
log.error("constraintViolationExceptionHandler {}", message);
|
||||
return ErrorCode.BAD_REQUEST.wrapper().msg(message);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.*;
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-16 01:19
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -34,12 +34,15 @@ public class SystemMenuDTO implements Serializable {
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -68,11 +68,10 @@ public class SystemRoleController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "通过 id 批量查询角色")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@Operation(summary = "查询所有角色")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-role:query')")
|
||||
public List<SystemRoleVO> getSystemRoleList(@RequestParam("idList") List<Long> idList) {
|
||||
return systemRoleService.getSystemRoleList(idList);
|
||||
public List<SystemRoleVO> getSystemRoleList() {
|
||||
return systemRoleService.getSystemRoleList();
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
|
||||
@@ -94,11 +94,10 @@ public class SystemUserController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "通过 id 批量查询用户")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@Operation(summary = "查询所有用户")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query')")
|
||||
public List<SystemUserVO> getSystemUserList(@RequestParam("idList") List<Long> idList) {
|
||||
return systemUserService.getSystemUserList(idList);
|
||||
public List<SystemUserVO> getSystemUserList() {
|
||||
return systemUserService.getSystemUserList();
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orion.ops.module.infra.define;
|
||||
|
||||
import com.orion.lang.define.cache.CacheKeyBuilder;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.module.infra.entity.dto.LoginTokenDTO;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -13,12 +16,30 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public interface UserCacheKeyDefine {
|
||||
|
||||
CacheKeyDefine USER_INFO = new CacheKeyDefine("user:info:{}", "用户信息 ${id}");
|
||||
CacheKeyDefine USER_INFO = new CacheKeyBuilder()
|
||||
.key("user:info:{}")
|
||||
.desc("用户信息 ${id}")
|
||||
.type(LoginUser.class)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine LOGIN_FAILED_COUNT = new CacheKeyDefine("user:failed:{}", "用户登陆失败次数 ${username}", 3, TimeUnit.DAYS);
|
||||
CacheKeyDefine LOGIN_FAILED_COUNT = new CacheKeyBuilder()
|
||||
.key("user:failed:{}")
|
||||
.desc("用户登陆失败次数 ${username}")
|
||||
.timeout(3, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine LOGIN_TOKEN = new CacheKeyDefine("user:token:{}:{}", "用户登陆 token ${id} ${time}", 24, TimeUnit.HOURS);
|
||||
CacheKeyDefine LOGIN_TOKEN = new CacheKeyBuilder()
|
||||
.key("user:token:{}:{}")
|
||||
.desc("用户登陆 token ${id} ${time}")
|
||||
.type(LoginTokenDTO.class)
|
||||
.timeout(24, TimeUnit.HOURS)
|
||||
.build();
|
||||
|
||||
CacheKeyDefine LOGIN_REFRESH = new CacheKeyDefine("user:refresh:{}:{}", "用户刷新 token ${id} ${time}", 28, TimeUnit.HOURS);
|
||||
CacheKeyDefine LOGIN_REFRESH = new CacheKeyBuilder()
|
||||
.key("user:refresh:{}:{}")
|
||||
.desc("用户刷新 token ${id} ${time}")
|
||||
.type(LoginTokenDTO.class)
|
||||
.timeout(28, TimeUnit.HOURS)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 菜单 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-16 01:19
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -42,7 +41,7 @@ public class SystemMenuDO extends BaseDO {
|
||||
@TableField("permission")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
|
||||
@@ -50,6 +49,10 @@ public class SystemMenuDO extends BaseDO {
|
||||
@TableField("sort")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
@TableField("visible")
|
||||
private Integer visible;
|
||||
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SystemMenuCacheDTO {
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.orion.ops.module.infra.entity.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 菜单 创建请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "SystemMenuCreateRequest", description = "菜单 创建请求对象")
|
||||
public class SystemMenuCreateRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单缓存 0不缓存 1缓存")
|
||||
private Integer cache;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "路由地址")
|
||||
private String path;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "组件名称")
|
||||
private String componentName;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "组件地址")
|
||||
private String component;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.orion.ops.module.infra.entity.request;
|
||||
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 菜单 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SystemMenuQueryRequest", description = "菜单 查询请求对象")
|
||||
public class SystemMenuQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "菜单缓存 0不缓存 1缓存")
|
||||
private Integer cache;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "路由地址")
|
||||
private String path;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "组件名称")
|
||||
private String componentName;
|
||||
|
||||
@Size(max = 128)
|
||||
@Schema(description = "组件地址")
|
||||
private String component;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.orion.ops.module.infra.entity.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 菜单 更新请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "SystemMenuUpdateRequest", description = "菜单 更新请求对象")
|
||||
public class SystemMenuUpdateRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单缓存 0不缓存 1缓存")
|
||||
private Integer cache;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "路由地址")
|
||||
private String path;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "组件名称")
|
||||
private String componentName;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "组件地址")
|
||||
private String component;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.orion.ops.module.infra.entity.request.menu;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 菜单 创建请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "SystemMenuCreateRequest", description = "菜单 创建请求对象")
|
||||
public class SystemMenuCreateParentRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "父id")
|
||||
private Long parentId;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单名称")
|
||||
private String name;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单缓存 0不缓存 1缓存")
|
||||
private Integer cache;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "路由地址")
|
||||
private String path;
|
||||
|
||||
@Size(max = 64)
|
||||
@NotBlank
|
||||
@Schema(description = "组件名称")
|
||||
private String componentName;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotBlank
|
||||
@Schema(description = "组件地址")
|
||||
private String component;
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-17 11:39
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -40,13 +40,17 @@ public class SystemMenuCreateRequest implements Serializable {
|
||||
private String permission;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@@ -11,7 +11,7 @@ import javax.validation.constraints.Size;
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-17 11:39
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -35,12 +35,15 @@ public class SystemMenuQueryRequest extends PageRequest {
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-17 11:39
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -44,13 +44,17 @@ public class SystemMenuUpdateRequest implements Serializable {
|
||||
private String permission;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.orion.ops.module.infra.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 菜单 视图响应对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-7-16 01:19
|
||||
* @since 2023-7-18 10:18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@@ -34,12 +37,15 @@ public class SystemMenuVO implements Serializable {
|
||||
@Schema(description = "菜单权限")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "菜单类型 1目录 2菜单 3功能")
|
||||
@Schema(description = "菜单类型 1父菜单 2子菜单 3功能")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否可见 0不可见 1可见")
|
||||
private Integer visible;
|
||||
|
||||
@Schema(description = "菜单状态 0停用 1启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orion.ops.module.infra.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/7/18 10:01
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MenuTypeEnum {
|
||||
|
||||
/**
|
||||
* 父菜单
|
||||
*/
|
||||
PARENT(1),
|
||||
|
||||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
ITEM(2),
|
||||
|
||||
/**
|
||||
* 功能
|
||||
*/
|
||||
FUNCTION(3),
|
||||
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
|
||||
public static MenuTypeEnum of(Integer type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
for (MenuTypeEnum value : values()) {
|
||||
if (value.type.equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.orion.ops.module.infra.service;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuCreateParentRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuUpdateRequest;
|
||||
@@ -25,6 +26,14 @@ public interface SystemMenuService {
|
||||
*/
|
||||
Long createSystemMenu(SystemMenuCreateRequest request);
|
||||
|
||||
/**
|
||||
* 创建菜单 父菜单
|
||||
*
|
||||
* @param request request
|
||||
* @return id
|
||||
*/
|
||||
Long createParentMenu(SystemMenuCreateParentRequest request);
|
||||
|
||||
/**
|
||||
* 通过 id 更新菜单
|
||||
*
|
||||
|
||||
@@ -51,12 +51,11 @@ public interface SystemRoleService {
|
||||
SystemRoleVO getSystemRole(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 批量查询角色
|
||||
* 查询所有角色
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
*/
|
||||
List<SystemRoleVO> getSystemRoleList(List<Long> idList);
|
||||
List<SystemRoleVO> getSystemRoleList();
|
||||
|
||||
/**
|
||||
* 分页查询角色
|
||||
|
||||
@@ -48,12 +48,11 @@ public interface SystemUserService {
|
||||
SystemUserVO getSystemUser(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 批量查询用户
|
||||
* 查询所有用户
|
||||
*
|
||||
* @param idList idList
|
||||
* @return rows
|
||||
*/
|
||||
List<SystemUserVO> getSystemUserList(List<Long> idList);
|
||||
List<SystemUserVO> getSystemUserList();
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.constant.StandardHttpHeader;
|
||||
import com.orion.lang.define.wrapper.Pair;
|
||||
import com.orion.lang.utils.Exceptions;
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.crypto.Signatures;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
@@ -15,6 +14,7 @@ import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.CryptoUtils;
|
||||
import com.orion.ops.framework.common.utils.IpUtils;
|
||||
import com.orion.ops.framework.common.utils.Kits;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.module.infra.convert.SystemUserConvert;
|
||||
import com.orion.ops.module.infra.dao.SystemUserDAO;
|
||||
|
||||
@@ -3,12 +3,13 @@ package com.orion.ops.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.infra.convert.SystemMenuConvert;
|
||||
import com.orion.ops.module.infra.dao.SystemMenuDAO;
|
||||
import com.orion.ops.module.infra.entity.domain.SystemMenuDO;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuCreateParentRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuUpdateRequest;
|
||||
@@ -47,6 +48,12 @@ public class SystemMenuServiceImpl implements SystemMenuService {
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createParentMenu(SystemMenuCreateParentRequest request) {
|
||||
System.out.println(Valid.valid(request));
|
||||
return 1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateSystemMenu(SystemMenuUpdateRequest request) {
|
||||
// 查询
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.orion.ops.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.infra.convert.SystemRoleConvert;
|
||||
import com.orion.ops.module.infra.dao.SystemRoleDAO;
|
||||
import com.orion.ops.module.infra.dao.SystemRoleMenuDAO;
|
||||
@@ -98,7 +98,7 @@ public class SystemRoleServiceImpl implements SystemRoleService {
|
||||
// 转换
|
||||
SystemRoleDO updateRecord = SystemRoleConvert.MAPPER.to(request);
|
||||
Integer status = updateRecord.getStatus();
|
||||
Valid.notNull(RoleStatusEnum.of(status), ErrorMessage.INVALID_PARAM);
|
||||
Valid.valid(RoleStatusEnum::of, status);
|
||||
// 更新
|
||||
int effect = systemRoleDAO.updateById(updateRecord);
|
||||
log.info("SystemRoleService-updateRoleStatus effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
@@ -118,9 +118,9 @@ public class SystemRoleServiceImpl implements SystemRoleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemRoleVO> getSystemRoleList(List<Long> idList) {
|
||||
public List<SystemRoleVO> getSystemRoleList() {
|
||||
// 查询
|
||||
List<SystemRoleDO> records = systemRoleDAO.selectBatchIds(idList);
|
||||
List<SystemRoleDO> records = systemRoleDAO.selectList(null);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.module.infra.dao.SystemRoleDAO;
|
||||
import com.orion.ops.module.infra.dao.SystemUserDAO;
|
||||
@@ -52,7 +52,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
// 删除用户关联
|
||||
Integer effect = systemUserRoleDAO.deleteByUserId(userId);
|
||||
// 更新缓存中的角色
|
||||
RedisUtils.processSetJson(UserCacheKeyDefine.USER_INFO, LoginUser.class, s -> {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setRoles(null);
|
||||
}, userId);
|
||||
return effect;
|
||||
@@ -92,7 +92,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
}).collect(Collectors.toList());
|
||||
systemUserRoleDAO.insertBatch(addUserRoles);
|
||||
// 更新缓存中的角色
|
||||
RedisUtils.processSetJson(UserCacheKeyDefine.USER_INFO, LoginUser.class, s -> {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setRoles(new ArrayList<>(roleCodeList));
|
||||
}, userId);
|
||||
return effect;
|
||||
@@ -102,7 +102,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
@Override
|
||||
public void asyncDeleteUserCacheRole(String roleCode, List<Long> userIdList) {
|
||||
for (Long userId : userIdList) {
|
||||
RedisUtils.processSetJson(UserCacheKeyDefine.USER_INFO, LoginUser.class, s -> {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
List<String> roles = s.getRoles();
|
||||
if (Lists.isEmpty(roles)) {
|
||||
return;
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.orion.ops.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Valid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.crypto.Signatures;
|
||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.infra.convert.SystemUserConvert;
|
||||
@@ -79,7 +79,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
int effect = systemUserDAO.updateById(updateRecord);
|
||||
log.info("SystemUserService-updateSystemUser effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
// 更新缓存中的花名
|
||||
RedisUtils.processSetJson(UserCacheKeyDefine.USER_INFO, LoginUser.class, s -> {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setNickname(request.getNickname());
|
||||
}, id);
|
||||
return effect;
|
||||
@@ -92,8 +92,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
throw ErrorCode.UNSUPPOETED.exception();
|
||||
}
|
||||
// 检查状态
|
||||
UserStatusEnum status = UserStatusEnum.of(request.getStatus());
|
||||
Valid.notNull(status, ErrorMessage.INVALID_PARAM);
|
||||
UserStatusEnum status = Valid.valid(UserStatusEnum::of, request.getStatus());
|
||||
if (!status.equals(UserStatusEnum.DISABLED) && !status.equals(UserStatusEnum.ENABLED)) {
|
||||
throw ErrorCode.BAD_REQUEST.exception();
|
||||
}
|
||||
@@ -110,7 +109,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
redisTemplate.delete(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(record.getUsername()));
|
||||
}
|
||||
// 更新缓存中的status
|
||||
RedisUtils.processSetJson(UserCacheKeyDefine.USER_INFO, LoginUser.class, s -> {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setStatus(request.getStatus());
|
||||
}, id);
|
||||
return effect;
|
||||
@@ -126,9 +125,9 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemUserVO> getSystemUserList(List<Long> idList) {
|
||||
public List<SystemUserVO> getSystemUserList() {
|
||||
// 查询
|
||||
List<SystemUserDO> records = systemUserDAO.selectBatchIds(idList);
|
||||
List<SystemUserDO> records = systemUserDAO.selectList(null);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<result column="permission" property="permission"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="visible" property="visible"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="cache" property="cache"/>
|
||||
<result column="icon" property="icon"/>
|
||||
@@ -25,7 +26,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
create_time, update_time, creator, updater, deleted, id, parent_id, name, permission, type, sort, status, cache, icon, path, component_name, component
|
||||
create_time, update_time, creator, updater, deleted, id, parent_id, name, permission, type, sort, visible, status, cache, icon, path, component_name, component
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user