通用模块初始化及代码同步
This commit is contained in:
parent
f99c0d6614
commit
7d8ce703ee
@ -17,6 +17,11 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring框架基本的核心工具 -->
|
<!-- Spring框架基本的核心工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
@ -7,6 +7,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import com.djhk.common.enums.BusinessType;
|
import com.djhk.common.enums.BusinessType;
|
||||||
import com.djhk.common.enums.OperatorType;
|
import com.djhk.common.enums.OperatorType;
|
||||||
|
import com.djhk.common.enums.OriginType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义操作日志记录注解
|
* 自定义操作日志记录注解
|
||||||
@ -48,4 +49,9 @@ public @interface Log
|
|||||||
* 排除指定的请求参数
|
* 排除指定的请求参数
|
||||||
*/
|
*/
|
||||||
public String[] excludeParamNames() default {};
|
public String[] excludeParamNames() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志来源
|
||||||
|
*/
|
||||||
|
public OriginType originType() default OriginType.INNER;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.djhk.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Documented
|
||||||
|
public @interface WebLog {
|
||||||
|
/**
|
||||||
|
* 日志描述信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String description() default "";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.djhk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description minio bucket
|
||||||
|
* @author jiachengshuai
|
||||||
|
* @date 2022/12/19 14:26:31
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class BucketContants
|
||||||
|
{
|
||||||
|
public final static String OTHER = "other";
|
||||||
|
|
||||||
|
public final static String OCR = "ocr";
|
||||||
|
|
||||||
|
public final static String UAV = "uav";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.djhk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限相关通用常量
|
||||||
|
*
|
||||||
|
* @author myk
|
||||||
|
*/
|
||||||
|
public class SecurityConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 用户ID字段
|
||||||
|
*/
|
||||||
|
public static final String DETAILS_USER_ID = "user_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名字段
|
||||||
|
*/
|
||||||
|
public static final String DETAILS_USERNAME = "username";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权信息字段
|
||||||
|
*/
|
||||||
|
public static final String AUTHORIZATION_HEADER = "authorization";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求来源
|
||||||
|
*/
|
||||||
|
public static final String FROM_SOURCE = "from-source";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部请求
|
||||||
|
*/
|
||||||
|
public static final String INNER = "inner";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户标识
|
||||||
|
*/
|
||||||
|
public static final String USER_KEY = "user_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录用户
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_USER = "login_user";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色权限
|
||||||
|
*/
|
||||||
|
public static final String ROLE_PERMISSION = "role_permission";
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.djhk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token的Key常量
|
||||||
|
*
|
||||||
|
* @author myk
|
||||||
|
*/
|
||||||
|
public class TokenConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 令牌自定义标识
|
||||||
|
*/
|
||||||
|
public static final String AUTHENTICATION = "Authorization";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
public static final String PREFIX = "Bearer ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌秘钥
|
||||||
|
*/
|
||||||
|
public final static String SECRET = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package com.djhk.common.core.domain;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应信息主体
|
||||||
|
*
|
||||||
|
* @author myk
|
||||||
|
*/
|
||||||
|
public class ResultVo<T> implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 成功 */
|
||||||
|
public static final int SUCCESS = 200;
|
||||||
|
|
||||||
|
/** 失败 */
|
||||||
|
public static final int FAIL = 500;
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
public static <T> R<T> ok()
|
||||||
|
{
|
||||||
|
return restResult(null, SUCCESS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> ok(T data)
|
||||||
|
{
|
||||||
|
return restResult(data, SUCCESS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> ok(T data, String msg)
|
||||||
|
{
|
||||||
|
return restResult(data, SUCCESS, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> fail()
|
||||||
|
{
|
||||||
|
return restResult(null, FAIL, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> fail(String msg)
|
||||||
|
{
|
||||||
|
return restResult(null, FAIL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> fail(T data)
|
||||||
|
{
|
||||||
|
return restResult(data, FAIL, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> fail(T data, String msg)
|
||||||
|
{
|
||||||
|
return restResult(data, FAIL, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> R<T> fail(int code, String msg)
|
||||||
|
{
|
||||||
|
return restResult(null, code, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> R<T> restResult(T data, int code, String msg)
|
||||||
|
{
|
||||||
|
R<T> apiResult = new R<>();
|
||||||
|
apiResult.setCode(code);
|
||||||
|
apiResult.setData(data);
|
||||||
|
apiResult.setMsg(msg);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData()
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(T data)
|
||||||
|
{
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.djhk.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ip请求限制相关枚举
|
||||||
|
*/
|
||||||
|
public enum AccountBlackLevleEnum {
|
||||||
|
LEVEL_ONE(1,0,2,600L,300L,"账号锁定5分钟,并且10分钟内如果再次锁定,将升级为level2"),
|
||||||
|
LEVEL_TWO(2,1,3,3000L,1500L,"账号锁定15分钟,并且30分钟内如果再次锁定,将升级为level3"),
|
||||||
|
LEVEL_THREE(3,2,null,48 * 60 * 60L,24 * 60 * 60L,"账号锁定1天,并且2天内如果再次锁定,将继续锁定1天"),
|
||||||
|
;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer preLevel;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer nextLevel;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Long levelKeyTimeOut;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Long blackKeyTimeOut;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private AccountBlackLevleEnum(Integer level, Integer preLevel, Integer nextLevel, Long levelKeyTimeOut, Long blackKeyTimeOut, String desc) {
|
||||||
|
this.level = level;
|
||||||
|
this.preLevel = preLevel;
|
||||||
|
this.nextLevel = nextLevel;
|
||||||
|
this.levelKeyTimeOut = levelKeyTimeOut;
|
||||||
|
this.blackKeyTimeOut = blackKeyTimeOut;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccountBlackLevleEnum getByLevel(Integer level) {
|
||||||
|
if (level == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AccountBlackLevleEnum levleEnum : AccountBlackLevleEnum.values()) {
|
||||||
|
if (level.equals(levleEnum.getLevel())) {
|
||||||
|
return levleEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccountBlackLevleEnum getByPreLevel(Integer preLevel) {
|
||||||
|
if (preLevel == null) {
|
||||||
|
return LEVEL_ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AccountBlackLevleEnum levleEnum : AccountBlackLevleEnum.values()) {
|
||||||
|
if (preLevel.equals(levleEnum.getPreLevel())) {
|
||||||
|
return levleEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return LEVEL_THREE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.djhk.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author sean
|
||||||
|
* @version 0.1
|
||||||
|
* @date 2021/11/26
|
||||||
|
*/
|
||||||
|
public enum BizCodeEnum
|
||||||
|
{
|
||||||
|
|
||||||
|
FLIGHT_PLAN("flight_plan","飞行计划上传"),
|
||||||
|
|
||||||
|
OCR_RECOGNITION("ocr_recognition","图形识别"),
|
||||||
|
|
||||||
|
OCR_COMPARISON("ocr_comparison","图片对比"),
|
||||||
|
|
||||||
|
UAV_INFO("uav_info","无人机信息"),
|
||||||
|
|
||||||
|
DEVICE_OFFLINE("device_offline","测试"),
|
||||||
|
|
||||||
|
|
||||||
|
THREED_MODEL("threed_model","三维模型上传");
|
||||||
|
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
BizCodeEnum(String code, String info)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo()
|
||||||
|
{
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.djhk.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ip请求限制相关枚举
|
||||||
|
*/
|
||||||
|
public enum IpBlackLevleEnum {
|
||||||
|
LEVEL_ONE(1,null,2,600L,300L,"IP锁定5分钟,并且10分钟内如果再次锁定,将升级为level2"),
|
||||||
|
LEVEL_TWO(2,1,3,3000L,1500L,"IP锁定15分钟,并且30分钟内如果再次锁定,将升级为level3"),
|
||||||
|
LEVEL_THREE(3,2,null,48 * 60 * 60L,24 * 60 * 60L,"IP锁定1天,并且2天内如果再次锁定,将继续锁定1天"),
|
||||||
|
;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer preLevel;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer nextLevel;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Long levelKeyTimeOut;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Long blackKeyTimeOut;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private IpBlackLevleEnum(Integer level, Integer preLevel, Integer nextLevel, Long levelKeyTimeOut, Long blackKeyTimeOut, String desc) {
|
||||||
|
this.level = level;
|
||||||
|
this.preLevel = preLevel;
|
||||||
|
this.nextLevel = nextLevel;
|
||||||
|
this.levelKeyTimeOut = levelKeyTimeOut;
|
||||||
|
this.blackKeyTimeOut = blackKeyTimeOut;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IpBlackLevleEnum getByLevel(Integer level) {
|
||||||
|
if (level == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IpBlackLevleEnum levleEnum : IpBlackLevleEnum.values()) {
|
||||||
|
if (level.equals(levleEnum.getLevel())) {
|
||||||
|
return levleEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IpBlackLevleEnum getByPreLevel(Integer preLevel) {
|
||||||
|
if (preLevel == null) {
|
||||||
|
return LEVEL_ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IpBlackLevleEnum levleEnum : IpBlackLevleEnum.values()) {
|
||||||
|
if (preLevel.equals(levleEnum.getPreLevel())) {
|
||||||
|
return levleEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return LEVEL_THREE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.djhk.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public enum IpRequestTimeCheckEnum {
|
||||||
|
|
||||||
|
ONE_SECONDS(1,30L,"一秒钟限制30次"),
|
||||||
|
FIVE_SECONDS(15,300L,"五秒钟限制100次"),
|
||||||
|
THIRTY_SECONDS(30,500L,"30秒钟限制500次"),
|
||||||
|
;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Integer seconds;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Long times;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
IpRequestTimeCheckEnum(Integer seconds, Long times, String desc) {
|
||||||
|
this.seconds = seconds;
|
||||||
|
this.times = times;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IpRequestTimeCheckEnum getBySeconds(Integer seconds) {
|
||||||
|
if (seconds == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IpRequestTimeCheckEnum checkEnum : IpRequestTimeCheckEnum.values()) {
|
||||||
|
if (seconds.equals(checkEnum.getSeconds())) {
|
||||||
|
return checkEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkTimes(Integer seconds,Long times) {
|
||||||
|
IpRequestTimeCheckEnum checkEnum = getBySeconds(seconds);
|
||||||
|
if (checkEnum != null) {
|
||||||
|
return checkEnum.getTimes().compareTo(times) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.djhk.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description
|
||||||
|
* @author jiachengshuai
|
||||||
|
* @date 2023/1/16 13:53:45
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public enum OriginType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 内部
|
||||||
|
*/
|
||||||
|
INNER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外部
|
||||||
|
*/
|
||||||
|
OUTER
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.djhk.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码错误异常类
|
||||||
|
*
|
||||||
|
* @author myk
|
||||||
|
*/
|
||||||
|
public class CaptchaException extends RuntimeException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public CaptchaException(String msg)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
125
djhk-common/src/main/java/com/djhk/common/utils/JwtUtils.java
Normal file
125
djhk-common/src/main/java/com/djhk/common/utils/JwtUtils.java
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package com.djhk.common.utils;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.djhk.common.constant.SecurityConstants;
|
||||||
|
import com.djhk.common.constant.TokenConstants;
|
||||||
|
import com.djhk.common.core.text.Convert;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jwt工具类
|
||||||
|
*
|
||||||
|
* @author myk
|
||||||
|
*/
|
||||||
|
public class JwtUtils
|
||||||
|
{
|
||||||
|
public static String secret = TokenConstants.SECRET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数据声明生成令牌
|
||||||
|
*
|
||||||
|
* @param claims 数据声明
|
||||||
|
* @return 令牌
|
||||||
|
*/
|
||||||
|
public static String createToken(Map<String, Object> claims)
|
||||||
|
{
|
||||||
|
String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从令牌中获取数据声明
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @return 数据声明
|
||||||
|
*/
|
||||||
|
public static Claims parseToken(String token)
|
||||||
|
{
|
||||||
|
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据令牌获取用户标识
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public static String getUserKey(String token)
|
||||||
|
{
|
||||||
|
Claims claims = parseToken(token);
|
||||||
|
return getValue(claims, SecurityConstants.USER_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据令牌获取用户标识
|
||||||
|
*
|
||||||
|
* @param claims 身份信息
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public static String getUserKey(Claims claims)
|
||||||
|
{
|
||||||
|
return getValue(claims, SecurityConstants.USER_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据令牌获取用户ID
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public static String getUserId(String token)
|
||||||
|
{
|
||||||
|
Claims claims = parseToken(token);
|
||||||
|
return getValue(claims, SecurityConstants.DETAILS_USER_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份信息获取用户ID
|
||||||
|
*
|
||||||
|
* @param claims 身份信息
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public static String getUserId(Claims claims)
|
||||||
|
{
|
||||||
|
return getValue(claims, SecurityConstants.DETAILS_USER_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据令牌获取用户名
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @return 用户名
|
||||||
|
*/
|
||||||
|
public static String getUserName(String token)
|
||||||
|
{
|
||||||
|
Claims claims = parseToken(token);
|
||||||
|
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份信息获取用户名
|
||||||
|
*
|
||||||
|
* @param claims 身份信息
|
||||||
|
* @return 用户名
|
||||||
|
*/
|
||||||
|
public static String getUserName(Claims claims)
|
||||||
|
{
|
||||||
|
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份信息获取键值
|
||||||
|
*
|
||||||
|
* @param claims 身份信息
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public static String getValue(Claims claims, String key)
|
||||||
|
{
|
||||||
|
return Convert.toStr(claims.get(key), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,171 @@
|
|||||||
|
package com.djhk.common.utils.sign;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import java.security.*;
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA加密解密
|
||||||
|
*
|
||||||
|
* @author gqj
|
||||||
|
**/
|
||||||
|
public class RsaUtils
|
||||||
|
{
|
||||||
|
// Rsa 私钥
|
||||||
|
public static String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDV4NjZNkLLJ6wq\n" +
|
||||||
|
"34mn0527PIXdEZcM8a7RPhQCeJy+/9KBFwMGFwvtBKgSOWqfDJOM4XJM+DCnnqHN\n" +
|
||||||
|
"lB3jkAd029d5c6ShXtEUQ4gmutTCZndnG867EzxEH78yw00MOiopswAaAH3QWdOZ\n" +
|
||||||
|
"tzrnqLCeVFX+tf38mBKgdmL+eVV0XooQM2MOIxe6SaGteY7LZD/Tkv6h71xhzyfG\n" +
|
||||||
|
"A9WcQMgwigZSkqS2xU8qEX3iCJ/2bKxkRpPD2rZY+rSIbcchqb9z6fXLpW/AWk/D\n" +
|
||||||
|
"zYQfRYIyePRafF2yi684WTXwbAEvxTznN8T9yQmZ+aCKOBdxBBeDWB4SiXbkW04W\n" +
|
||||||
|
"xvhC/1e3AgMBAAECggEAERI8XMIO/MYy4M0s4J9sdJh1GtsfkmHsETmCQVw9LqWe\n" +
|
||||||
|
"uL0Mebz3L7jybVn137ISSOlpxSj+QTLROWZ8KEDDx5kQjtojJto5mAN355d8CfRB\n" +
|
||||||
|
"zZIToyz633klOrkJ+lLeMKvf8zNc13eEAz3zzq/RQSH8JzOBjVraCcLJTgSDRKFt\n" +
|
||||||
|
"yTy4keyxbhwafIBlzWNkrzPVt0/1rox4BPVUU11x8/o8e18RJkLg7D/z8YQcXRsT\n" +
|
||||||
|
"lOcpxBW/KNq2ilq3IRY6XMmllnTYdanX2JJcSiiET1SuJxaosN2rLY0DxKQkIOoX\n" +
|
||||||
|
"6nL/6uW8sHz07B6aJAooHAUBFY4OxnvBbWMrUS+iUQKBgQDumUfBpwravV6/wnAz\n" +
|
||||||
|
"SpuZvYTz9hZFR2MFHFetYmCTlYH7RedogXvAa7ZPoW7BBgXEU44PPyMH9vhWPKvu\n" +
|
||||||
|
"TgMUViGzkvSWSN0WymkLGtEmeUjH2+T7uwiyK9igH/9YxXLVDCV3YAOhp7sE+PG4\n" +
|
||||||
|
"bxbwG6vYB8eTLIsH8iYCauyg3wKBgQDlegcYPnZhKd3JXrvrySevTnTEx3cp3vRB\n" +
|
||||||
|
"hbvzVoQvQCR0SZ668bOAZe3wd+ZFQoyOT+ndSBsdASpIg8elpW9k7+CDmVL9Ecdw\n" +
|
||||||
|
"KDeNsXaisUKyslQ/yB8BAI0+q6z5mjjqsS8PtqYne4krsGxiTdD1L1asl0EdZAEF\n" +
|
||||||
|
"iV1wXrTsKQKBgDWyP0jgq/uwVIt5WcDhUIVX9nzk6/wpZap3x2+YzT1Jj1gaUkrd\n" +
|
||||||
|
"oRkb5IqlPQSps1CMsVLTFbIsLZVS0CqwWdcQz0LXlr3fpgoEAYHjRiCPeQapgS35\n" +
|
||||||
|
"2KooXfcjXFcBEKfLtP7Zl9egpOEomVW1gocE4zaaAZsokh12rIEsyRYnAoGAb64G\n" +
|
||||||
|
"u+bSSBFPDgyb2nGoban6LDaDKQ6Hw0eppBDL/g7ybuHRbVvqJyf0N96yY6yyqSP9\n" +
|
||||||
|
"RiMsht4lTOtNg7FS2EXh90nsWJuJe20nND9U5HLuafdeBziG1j8FfqWgZk2HO7kF\n" +
|
||||||
|
"lVkn3flCVc/jv6ftdRYX0aE/IGWmFaK3pdOBq5kCgYAVwVXKOuHJggdYxVED/OXc\n" +
|
||||||
|
"T7xLu0741PjfLzzQEsCP3RvD2TRymA2ixcY7gHrZ7rZ4cn4NcsINI3xVHsbBZ5a9\n" +
|
||||||
|
"mMNkF0+rg0SOKp96NNI85nAUo1vQh7kP2nvDaZdSsDxfhIovkkeUjWPy2oJR7QOh\n" +
|
||||||
|
"Ynm+EHYEwXfPTCqw25jz+A==";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥解密
|
||||||
|
*
|
||||||
|
* @param text 待解密的文本
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPrivateKey(String text) throws Exception
|
||||||
|
{
|
||||||
|
return decryptByPrivateKey(privateKey, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥解密
|
||||||
|
*
|
||||||
|
* @param publicKeyString 公钥
|
||||||
|
* @param text 待解密的信息
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPublicKey(String publicKeyString, String text) throws Exception
|
||||||
|
{
|
||||||
|
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, publicKey);
|
||||||
|
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
||||||
|
return new String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥加密
|
||||||
|
*
|
||||||
|
* @param privateKeyString 私钥
|
||||||
|
* @param text 待加密的信息
|
||||||
|
* @return 加密后的文本
|
||||||
|
*/
|
||||||
|
public static String encryptByPrivateKey(String privateKeyString, String text) throws Exception
|
||||||
|
{
|
||||||
|
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
|
||||||
|
byte[] result = cipher.doFinal(text.getBytes());
|
||||||
|
return Base64.encodeBase64String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥解密
|
||||||
|
*
|
||||||
|
* @param privateKeyString 私钥
|
||||||
|
* @param text 待解密的文本
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPrivateKey(String privateKeyString, String text) throws Exception
|
||||||
|
{
|
||||||
|
PKCS8EncodedKeySpec pkcs8EncodedKeySpec5 = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec5);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
|
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
||||||
|
return new String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥加密
|
||||||
|
*
|
||||||
|
* @param publicKeyString 公钥
|
||||||
|
* @param text 待加密的文本
|
||||||
|
* @return 加密后的文本
|
||||||
|
*/
|
||||||
|
public static String encryptByPublicKey(String publicKeyString, String text) throws Exception
|
||||||
|
{
|
||||||
|
X509EncodedKeySpec x509EncodedKeySpec2 = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec2);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] result = cipher.doFinal(text.getBytes());
|
||||||
|
return Base64.encodeBase64String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建RSA密钥对
|
||||||
|
*
|
||||||
|
* @return 生成后的公私钥信息
|
||||||
|
*/
|
||||||
|
public static RsaKeyPair generateKeyPair() throws NoSuchAlgorithmException
|
||||||
|
{
|
||||||
|
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
keyPairGenerator.initialize(1024);
|
||||||
|
KeyPair keyPair = keyPairGenerator.generateKeyPair();
|
||||||
|
RSAPublicKey rsaPublicKey = (RSAPublicKey) keyPair.getPublic();
|
||||||
|
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||||
|
String publicKeyString = Base64.encodeBase64String(rsaPublicKey.getEncoded());
|
||||||
|
String privateKeyString = Base64.encodeBase64String(rsaPrivateKey.getEncoded());
|
||||||
|
return new RsaKeyPair(publicKeyString, privateKeyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA密钥对对象
|
||||||
|
*/
|
||||||
|
public static class RsaKeyPair
|
||||||
|
{
|
||||||
|
private final String publicKey;
|
||||||
|
private final String privateKey;
|
||||||
|
|
||||||
|
public RsaKeyPair(String publicKey, String privateKey)
|
||||||
|
{
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
this.privateKey = privateKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicKey()
|
||||||
|
{
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrivateKey()
|
||||||
|
{
|
||||||
|
return privateKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
@ -17,6 +17,17 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 用于日志切面中,以 json 格式打印出入参 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot Web容器 -->
|
<!-- SpringBoot Web容器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
package com.djhk.framework.aspectj;
|
||||||
|
|
||||||
|
import com.djhk.common.annotation.WebLog;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Profile({"dev", "test"})
|
||||||
|
public class WebLogAspect {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
|
||||||
|
/** 换行符 */
|
||||||
|
private static final String LINE_SEPARATOR = System.lineSeparator();
|
||||||
|
|
||||||
|
/** 以自定义 @WebLog 注解为切点 */
|
||||||
|
@Pointcut("@annotation(com.djhk.common.log.annotation.WebLog)")
|
||||||
|
public void webLog() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在切点之前织入
|
||||||
|
* @param joinPoint
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
@Before("webLog()")
|
||||||
|
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||||
|
// 开始打印请求日志
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
|
||||||
|
// 获取 @WebLog 注解的描述信息
|
||||||
|
String methodDescription = getAspectLogDescription(joinPoint);
|
||||||
|
|
||||||
|
// 打印请求相关参数
|
||||||
|
logger.info("========================================== Start ==========================================");
|
||||||
|
// 打印请求 url
|
||||||
|
logger.info("URL : {}", request.getRequestURL().toString());
|
||||||
|
// 打印描述信息
|
||||||
|
logger.info("Description : {}", methodDescription);
|
||||||
|
// 打印 Http method
|
||||||
|
logger.info("HTTP Method : {}", request.getMethod());
|
||||||
|
// 打印调用 controller 的全路径以及执行方法
|
||||||
|
logger.info("Class Method : {}.{}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
|
||||||
|
// 打印请求的 IP
|
||||||
|
logger.info("IP : {}", request.getRemoteAddr());
|
||||||
|
// 打印请求入参
|
||||||
|
logger.info("Request Args : {}", new Gson().toJson(joinPoint.getArgs()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在切点之后织入
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
@After("webLog()")
|
||||||
|
public void doAfter() throws Throwable {
|
||||||
|
// 接口结束后换行,方便分割查看
|
||||||
|
logger.info("=========================================== End ===========================================" + LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环绕
|
||||||
|
* @param proceedingJoinPoint
|
||||||
|
* @return
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
@Around("webLog()")
|
||||||
|
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
Object result = proceedingJoinPoint.proceed();
|
||||||
|
// 打印出参
|
||||||
|
logger.info("Response Args : {}", new Gson().toJson(result));
|
||||||
|
// 执行耗时
|
||||||
|
logger.info("Time-Consuming : {} ms", System.currentTimeMillis() - startTime);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取切面注解的描述
|
||||||
|
*
|
||||||
|
* @param joinPoint 切点
|
||||||
|
* @return 描述信息
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String getAspectLogDescription(JoinPoint joinPoint)
|
||||||
|
throws Exception {
|
||||||
|
String targetName = joinPoint.getTarget().getClass().getName();
|
||||||
|
String methodName = joinPoint.getSignature().getName();
|
||||||
|
Object[] arguments = joinPoint.getArgs();
|
||||||
|
Class targetClass = Class.forName(targetName);
|
||||||
|
Method[] methods = targetClass.getMethods();
|
||||||
|
StringBuilder description = new StringBuilder("");
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (method.getName().equals(methodName)) {
|
||||||
|
Class[] clazzs = method.getParameterTypes();
|
||||||
|
if (clazzs.length == arguments.length) {
|
||||||
|
description.append(method.getAnnotation(WebLog.class).description());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return description.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.djhk.framework.config;
|
package com.djhk.framework.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -16,6 +18,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
|
@AutoConfigureBefore(RedisAutoConfiguration.class)
|
||||||
public class RedisConfig extends CachingConfigurerSupport
|
public class RedisConfig extends CachingConfigurerSupport
|
||||||
{
|
{
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
package com.djhk.framework.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author szh
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2023/4/13
|
||||||
|
*/
|
||||||
|
public class RedisConstant {
|
||||||
|
|
||||||
|
public static final String DELIMITER = ":";
|
||||||
|
|
||||||
|
public static final Integer DEVICE_ALIVE_SECOND = 60;
|
||||||
|
|
||||||
|
public static final Integer WEBSOCKET_ALIVE_SECOND = 60 * 60 * 24;
|
||||||
|
|
||||||
|
public static final String USER_SELECTED_PREFIX = "user" + DELIMITER + "organ" + DELIMITER;
|
||||||
|
|
||||||
|
// 规则:SMS_CODE_LOGIXTICS:模板编号:手机号
|
||||||
|
public static final String SMS_CODE_PREFIX = "SMS_CODE_FLIGHT:%s:%s";
|
||||||
|
|
||||||
|
public static final String SMS_CODE_LIMIT = "SMS_CODE_FLIGHT_LIMIT:%s:%s";
|
||||||
|
|
||||||
|
//ip 黑名单
|
||||||
|
public static final String IP_CHECK_BLACK = "IP_CHECK:%s:BLACK";
|
||||||
|
|
||||||
|
public static final String IP_CHECK_BLACK_LEVEL = "IP_CHECK:%s:BLACK_LEVEL";
|
||||||
|
|
||||||
|
//IP 请求次数校验
|
||||||
|
public static final String IP_CHECK_REQUEST_TIMES = "IP_CHECK:%s:REQUEST_TIMES" + DELIMITER + "%s";
|
||||||
|
|
||||||
|
//用户登录账号黑名单
|
||||||
|
public static final String LOGIN_CHECK_ACCOUNT_BLACK = "LOGIN_CHECK_ACCOUNT:%s:BLACK";
|
||||||
|
|
||||||
|
//用户登录IP黑名单
|
||||||
|
public static final String LOGIN_CHECK_IP_BLACK = "LOGIN_CHECK_IP:%s:BLACK";
|
||||||
|
|
||||||
|
public static final String LOGIN_CHECK_IP_ACCOUNT_BLACK = "LOGIN_CHECK_IP_ACCOUNT:%s:%s:BLACK";
|
||||||
|
|
||||||
|
//用户锁定级别
|
||||||
|
public static final String LOGIN_CHECK_ACCOUNT_BLACK_LEVEL = "LOGIN_CHECK_ACCOUNT:%s:BLACK_LEVEL";
|
||||||
|
|
||||||
|
//用户登录错误次数-密码
|
||||||
|
public static final String LOGIN_CHECK_ACCOUNT_WRONG_TIMES_PASSWORD = "LOGIN_CHECK_ACCOUNT:%s:WRONG_TIMES_PASSWORD";
|
||||||
|
|
||||||
|
//用户登录错误次数-短信
|
||||||
|
public static final String LOGIN_CHECK_ACCOUNT_WRONG_TIMES_SMS = "LOGIN_CHECK_ACCOUNT:%s:%s:WRONG_TIMES_MESSAGE";
|
||||||
|
|
||||||
|
//ip登录错误次数
|
||||||
|
public static final String LOGIN_CHECK_IP_WRONG_TIMES = "LOGIN_CHECK_IP:%s:WRONG_TIMES";
|
||||||
|
|
||||||
|
//反制设备
|
||||||
|
public static final String COUNTER_PREFIX = "counter"+ DELIMITER;
|
||||||
|
|
||||||
|
public static String getSmsCodeKey(String phoneNo,String templateCodeIndex) {
|
||||||
|
return String.format(SMS_CODE_PREFIX,templateCodeIndex,phoneNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSmsCodeLimitKey(String phoneNo,String templateCodeIndex) {
|
||||||
|
return String.format(SMS_CODE_LIMIT,templateCodeIndex,phoneNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIpCheckBlackKey(String ip) {
|
||||||
|
return String.format(IP_CHECK_BLACK,ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginCheckIpAccountBlackKey(String ip,String account) {
|
||||||
|
return String.format(LOGIN_CHECK_IP_ACCOUNT_BLACK,ip,account);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIpCheckBlackLevelKey(String ip) {
|
||||||
|
return String.format(IP_CHECK_BLACK_LEVEL,ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIpCheckRequestTimesKey(String ip,int seconds) {
|
||||||
|
return String.format(IP_CHECK_REQUEST_TIMES,ip,seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginCheckIpWrongTimesKey(String ip) {
|
||||||
|
return String.format(LOGIN_CHECK_IP_WRONG_TIMES,ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginCheckAccountWrongTimesSmsKey(String ip,String account) {
|
||||||
|
return String.format(LOGIN_CHECK_ACCOUNT_WRONG_TIMES_SMS,ip,account);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginCheckAccountWrongTimesPasswordKey(String account) {
|
||||||
|
return String.format(LOGIN_CHECK_ACCOUNT_WRONG_TIMES_PASSWORD,account);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginCheckIpBlackKey(String ip) {
|
||||||
|
return String.format(LOGIN_CHECK_IP_BLACK,ip);
|
||||||
|
}
|
||||||
|
public static String getLoginCheckAccountBlackLevelKey(String account) {
|
||||||
|
return String.format(LOGIN_CHECK_ACCOUNT_BLACK_LEVEL,account);
|
||||||
|
}
|
||||||
|
public static String getLoginCheckAccountBlackKey(String account) {
|
||||||
|
return String.format(LOGIN_CHECK_ACCOUNT_BLACK,account);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
1
pom.xml
1
pom.xml
@ -250,7 +250,6 @@
|
|||||||
<module>djhk-quartz</module>
|
<module>djhk-quartz</module>
|
||||||
<module>djhk-generator</module>
|
<module>djhk-generator</module>
|
||||||
<module>djhk-common</module>
|
<module>djhk-common</module>
|
||||||
<module>djhk-uav</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user