refactor: 优化认证及客户端相关代码

This commit is contained in:
2024-12-27 20:29:36 +08:00
parent c870014730
commit 438615f87c
27 changed files with 160 additions and 226 deletions

View File

@@ -30,6 +30,7 @@ import java.util.List;
* 客户端实体
*
* @author KAI
* @author Charles7c
* @since 2024/12/03 16:04
*/
@Data
@@ -66,17 +67,17 @@ public class ClientDO extends BaseDO {
private String clientType;
/**
* Token最低活跃频率-1不限制)
* Token 最低活跃频率(单位:秒,-1不限制,永不冻结
*/
private Integer activeTimeout;
private Long activeTimeout;
/**
* Token有效期默认30天单位:秒)
* Token 有效期(单位:秒-1永不过期
*/
private Integer timeout;
private Long timeout;
/**
* 状态1启用2禁用
* 状态
*/
private DisEnableStatusEnum status;
}

View File

@@ -30,6 +30,7 @@ import java.util.List;
* 客户端查询条件
*
* @author KAI
* @author Charles7c
* @since 2024/12/03 16:04
*/
@Data
@@ -40,28 +41,28 @@ public class ClientQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户端Key
* 客户端 Key
*/
@Schema(description = "客户端Key")
@Schema(description = "客户端 Key", example = "PC")
private String clientKey;
/**
* 客户端秘钥
*/
@Schema(description = "客户端秘钥")
@Schema(description = "客户端秘钥", example = "dd77ab1e353a027e0d60ce3b151e8642")
private String clientSecret;
/**
* 认证类型
*/
@Schema(description = "认证类型")
@Schema(description = "认证类型", example = "ACCOUNT")
@Query(type = QueryType.IN)
private List<String> authType;
/**
* 客户端类型
*/
@Schema(description = "客户端类型")
@Schema(description = "客户端类型", example = "PC")
private String clientType;
/**

View File

@@ -18,7 +18,7 @@ package top.continew.admin.system.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.continew.admin.common.enums.DisEnableStatusEnum;
@@ -31,6 +31,7 @@ import java.util.List;
* 创建或修改客户端参数
*
* @author KAI
* @author Charles7c
* @since 2024/12/03 16:04
*/
@Data
@@ -41,15 +42,9 @@ public class ClientReq extends BaseReq {
private static final long serialVersionUID = 1L;
/**
* 客户端ID
* 客户端 Key
*/
@Schema(description = "客户端ID")
private String clientId;
/**
* 客户端Key
*/
@Schema(description = "客户端Key")
@Schema(description = "客户端 Key", example = "PC")
@NotBlank(message = "客户端Key不能为空")
@Length(max = 32, message = "客户端Key长度不能超过 {max} 个字符")
private String clientKey;
@@ -57,7 +52,7 @@ public class ClientReq extends BaseReq {
/**
* 客户端秘钥
*/
@Schema(description = "客户端秘钥")
@Schema(description = "客户端秘钥", example = "dd77ab1e353a027e0d60ce3b151e8642")
@NotBlank(message = "客户端秘钥不能为空")
@Length(max = 255, message = "客户端秘钥长度不能超过 {max} 个字符")
private String clientSecret;
@@ -65,33 +60,39 @@ public class ClientReq extends BaseReq {
/**
* 认证类型
*/
@Schema(description = "认证类型")
@NotNull(message = "认证类型不能为空")
@Schema(description = "认证类型", example = "ACCOUNT")
@NotEmpty(message = "认证类型不能为空")
private List<String> authType;
/**
* 客户端类型
*/
@Schema(description = "客户端类型")
@Schema(description = "客户端类型", example = "PC")
@NotBlank(message = "客户端类型不能为空")
@Length(max = 32, message = "客户端类型长度不能超过 {max} 个字符")
private String clientType;
/**
* Token最低活跃频率-1不限制)
* Token 最低活跃频率(单位:秒,-1不限制,永不冻结
*/
@Schema(description = "Token最低活跃频率-1不限制")
private Integer activeTimeout;
@Schema(description = "Token 最低活跃频率(单位:秒,-1不限制,永不冻结)", example = "1800")
private Long activeTimeout;
/**
* Token有效期默认30天单位:秒)
* Token 有效期(单位:秒-1永不过期
*/
@Schema(description = "Token有效期默认30天单位")
private Integer timeout;
@Schema(description = "Token 有效期(单位:秒,-1永不过期", example = "86400")
private Long timeout;
/**
* 状态
*/
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
/**
* 客户端 ID
*/
@Schema(hidden = true)
private String clientId;
}

View File

@@ -19,7 +19,6 @@ package top.continew.admin.system.model.req.user;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

View File

@@ -16,13 +16,10 @@
package top.continew.admin.system.model.resp;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
import top.continew.starter.file.excel.converter.ExcelBaseEnumConverter;
import java.io.Serial;
import java.util.List;
@@ -34,7 +31,6 @@ import java.util.List;
* @since 2024/12/03 16:04
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "客户端详情信息")
public class ClientDetailResp extends BaseDetailResp {
@@ -45,55 +41,47 @@ public class ClientDetailResp extends BaseDetailResp {
* 客户端ID
*/
@Schema(description = "客户端ID")
@ExcelProperty(value = "客户端ID", order = 2)
private String clientId;
/**
* 客户端Key
*/
@Schema(description = "客户端Key")
@ExcelProperty(value = "客户端Key", order = 3)
private String clientKey;
/**
* 客户端秘钥
*/
@Schema(description = "客户端秘钥")
@ExcelProperty(value = "客户端秘钥", order = 4)
private String clientSecret;
/**
* 登录类型
*/
@Schema(description = "登录类型")
@ExcelProperty(value = "登录类型", order = 5)
private List<String> authType;
/**
* 客户端类型
*/
@Schema(description = "客户端类型")
@ExcelProperty(value = "客户端类型", order = 6)
private String clientType;
/**
* Token最低活跃频率-1为不限制
*/
@Schema(description = "Token最低活跃频率-1为不限制")
@ExcelProperty(value = "Token最低活跃频率-1为不限制", order = 7)
private Integer activeTimeout;
/**
* Token有效期默认30天单位
*/
@Schema(description = "Token有效期默认30天单位")
@ExcelProperty(value = "Token有效期默认30天单位", order = 8)
private Integer timeout;
/**
* 状态
*/
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 9)
private DisEnableStatusEnum status;
}

View File

@@ -28,6 +28,7 @@ import java.util.List;
* 客户端信息
*
* @author KAI
* @author Charles7c
* @since 2024/12/03 16:04
*/
@Data
@@ -38,50 +39,50 @@ public class ClientResp extends BaseResp {
private static final long serialVersionUID = 1L;
/**
* 客户端ID
* 客户端 ID
*/
@Schema(description = "客户端ID")
@Schema(description = "客户端 ID", example = "ef51c9a3e9046c4f2ea45142c8a8344a")
private String clientId;
/**
* 客户端Key
* 客户端 Key
*/
@Schema(description = "客户端Key")
@Schema(description = "客户端 Key", example = "PC")
private String clientKey;
/**
* 客户端秘钥
*/
@Schema(description = "客户端秘钥")
@Schema(description = "客户端秘钥", example = "dd77ab1e353a027e0d60ce3b151e8642")
private String clientSecret;
/**
* 认证类型
*/
@Schema(description = "认证类型")
@Schema(description = "认证类型", example = "ACCOUNT")
private List<String> authType;
/**
* 客户端类型
*/
@Schema(description = "客户端类型")
@Schema(description = "客户端类型", example = "PC")
private String clientType;
/**
* Token最低活跃频率-1不限制)
* Token 最低活跃频率(单位:秒,-1不限制,永不冻结
*/
@Schema(description = "Token最低活跃频率-1不限制")
@Schema(description = "Token 最低活跃频率(单位:秒,-1不限制,永不冻结)", example = "1800")
private Integer activeTimeout;
/**
* Token有效期默认30天单位:秒)
* Token 有效期(单位:秒-1永不过期
*/
@Schema(description = "Token有效期默认30天单位")
@Schema(description = "Token 有效期(单位:秒,-1永不过期", example = "86400")
private Integer timeout;
/**
* 状态1启用2禁用
* 状态
*/
@Schema(description = "状态")
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
}

View File

@@ -124,14 +124,6 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ
*/
void updateEmail(String newEmail, String oldPassword, Long id);
/**
* 新增
*
* @param user 用户信息
* @return ID
*/
Long add(UserDO user);
/**
* 根据用户名查询
*

View File

@@ -439,13 +439,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
baseMapper.lambdaUpdate().set(UserDO::getEmail, newEmail).eq(UserDO::getId, id).update();
}
@Override
public Long add(UserDO user) {
user.setStatus(DisEnableStatusEnum.ENABLE);
baseMapper.insert(user);
return user.getId();
}
@Override
public UserDO getByUsername(String username) {
return baseMapper.selectByUsername(username);