refactor: 删除heritage-common配置和常量
- 移除Web配置和XSS过滤器配置 - 移除所有常量定义类 - 移��枚举类型定义 - 清理项目基础配置文件
This commit is contained in:
parent
98f3964a4f
commit
7b7b767a5a
@ -1,80 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.config;
|
|
||||||
|
|
||||||
import org.leocoder.heritage.common.filter.XssFilter;
|
|
||||||
import org.leocoder.heritage.common.interceptor.CoderIpBlockListInterceptor;
|
|
||||||
import org.leocoder.heritage.common.interceptor.CoderTrackIdInterceptor;
|
|
||||||
import org.leocoder.heritage.common.interceptor.CoderWebInvokeTimeInterceptor;
|
|
||||||
import org.leocoder.heritage.common.utils.string.CutOutUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @description [防止SQL注入、XSS攻击、CSRF/CROS恶意访问,需要guava包依赖]
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
|
||||||
|
|
||||||
@Value("${coder.filePath}")
|
|
||||||
private String baseFilePath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description [将拦截器bean化,否则无法直接使用RedisUtil]
|
|
||||||
* 原因:拦截器的执行是在spring容器中bean初始化之前的,拦截器执行时,spring中我们定义的bean还未初始化,自然也就无法自动注入,无法使用。
|
|
||||||
* @author : Leocoder
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public CoderIpBlockListInterceptor CoderIpBlockListInterceptor() {
|
|
||||||
return new CoderIpBlockListInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
|
||||||
// 全局访问性能拦截
|
|
||||||
registry.addInterceptor(new CoderWebInvokeTimeInterceptor());
|
|
||||||
// 黑名单IP拦截
|
|
||||||
registry.addInterceptor(CoderIpBlockListInterceptor());
|
|
||||||
// TrackId拦截
|
|
||||||
registry.addInterceptor(new CoderTrackIdInterceptor());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -excludes用于配置不需要参数过滤的请求url
|
|
||||||
// -isIncludeRichText默认为true,主要用于设置富文本内容是否需要过滤
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<XssFilter> xssFilterRegistrationBean() {
|
|
||||||
FilterRegistrationBean<XssFilter> filterRegistrationBean = new FilterRegistrationBean<>();
|
|
||||||
filterRegistrationBean.setFilter(new XssFilter());
|
|
||||||
filterRegistrationBean.setOrder(1);
|
|
||||||
filterRegistrationBean.setEnabled(true);
|
|
||||||
// 使用List代替数组
|
|
||||||
filterRegistrationBean.setUrlPatterns(List.of("/*"));
|
|
||||||
Map<String, String> initParameters = new HashMap<>();
|
|
||||||
// 使用逗号分隔的字符串
|
|
||||||
initParameters.put("excludes", "/favicon.ico,/img/*,/js/*,/css/*,/captcha/*,/auth/*");
|
|
||||||
initParameters.put("isIncludeRichText", "true");
|
|
||||||
filterRegistrationBean.setInitParameters(initParameters);
|
|
||||||
return filterRegistrationBean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description [配置静态资源映射-本地图片回显-实现implements WebMvcConfigurer]
|
|
||||||
* @author : Leocoder
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
// SpringBoot 所需 favicon.ico 图标
|
|
||||||
registry.addResourceHandler("favicon.ico").addResourceLocations("classpath:/static/");
|
|
||||||
// 本地文件上传路径
|
|
||||||
registry.addResourceHandler(CutOutUtil.deleteCharacterBefore("/", baseFilePath) + "/**").addResourceLocations("file:" + baseFilePath + "/");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @description [CacheConstants缓存的key常量]
|
|
||||||
*/
|
|
||||||
public class CoderCacheConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字典 redis key
|
|
||||||
*/
|
|
||||||
public static final String DICT_REDIS_KEY = "coderDict:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码 redis key
|
|
||||||
*/
|
|
||||||
public static final String CAPTCHA_CODE_KEY = "coderCaptchaCodes:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录账户密码错误次数 redis key
|
|
||||||
*/
|
|
||||||
public static final String PWD_ERROR_KEY = "coderPwdError:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 防重提交 redis key
|
|
||||||
*/
|
|
||||||
public static final String REPEAT_SUBMIT_KEY = "coderRepeatSubmit:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 限流 redis key
|
|
||||||
*/
|
|
||||||
public static final String RATE_LIMIT_KEY = "coderRateLimit:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 黑名单IP redis key
|
|
||||||
*/
|
|
||||||
public static final String BLACKLIST_IP_KEY = "coderBlacklistIp:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 白名单IP redis key
|
|
||||||
*/
|
|
||||||
public static final String WHITELIST_IP_KEY = "coderWhitelistIp:";
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,144 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description [通用常量信息]
|
|
||||||
* @author : Leocoder
|
|
||||||
*/
|
|
||||||
public class CoderConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 令牌
|
|
||||||
*/
|
|
||||||
public static final String TOKEN = "token";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redis数据缓存用户信息
|
|
||||||
*/
|
|
||||||
public static final String REDIS_CACHE_LOGIN_USER = "Authorization:login:session:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码有效期[分钟]
|
|
||||||
*/
|
|
||||||
public static final Integer CAPTCHA_EXPIRATION = 6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PC端
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_PC = "PC";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信小程序端
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_WECHAT = "wechat";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主库
|
|
||||||
*/
|
|
||||||
public static final String MASTER = "master";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从库
|
|
||||||
*/
|
|
||||||
public static final String SLAVE = "slave";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 图库上传路径
|
|
||||||
*/
|
|
||||||
public static final String PICTURES = "pictures";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* true
|
|
||||||
*/
|
|
||||||
public static final Boolean TRUE = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* false
|
|
||||||
*/
|
|
||||||
public static final Boolean FALSE = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符零
|
|
||||||
*/
|
|
||||||
public static final String ZERO_STRING = "0";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符壹
|
|
||||||
*/
|
|
||||||
public static final String ONE_STRING = "1";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符贰
|
|
||||||
*/
|
|
||||||
public static final String TWO_STRING = "2";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符叁
|
|
||||||
*/
|
|
||||||
public static final String THREE_STRING = "3";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符肆
|
|
||||||
*/
|
|
||||||
public static final String FOUR_STRING = "4";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符负一
|
|
||||||
*/
|
|
||||||
public static final String MINUS_ONE_STRING = "-1";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字0
|
|
||||||
*/
|
|
||||||
public static final Integer ZERO_NUMBER = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字1
|
|
||||||
*/
|
|
||||||
public static final Integer ONE_NUMBER = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字2
|
|
||||||
*/
|
|
||||||
public static final Integer TWO_NUMBER = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字10
|
|
||||||
*/
|
|
||||||
public static final Integer TEN_NUMBER = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字666666
|
|
||||||
*/
|
|
||||||
public static final Integer SIX_INFINITE_NUMBER = 666666;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字0L
|
|
||||||
*/
|
|
||||||
public static final Long ZERO_LONG = 0L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字1L
|
|
||||||
*/
|
|
||||||
public static final Long ONE_LONG = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用角色、部门和岗位编码
|
|
||||||
*/
|
|
||||||
public static final String CODER_COMMON = "CODER_COMMON";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据计数阈值 - 多条记录
|
|
||||||
*/
|
|
||||||
public static final Long COUNT_THRESHOLD_MULTIPLE = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据计数阈值 - 单条记录
|
|
||||||
*/
|
|
||||||
public static final Long COUNT_THRESHOLD_SINGLE = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据计数阈值 - 存在性判断
|
|
||||||
*/
|
|
||||||
public static final Long COUNT_THRESHOLD_EXISTS = 0L;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @description [SaTokenSessionConstants]
|
|
||||||
*/
|
|
||||||
public class SaTokenSessionConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户信息
|
|
||||||
*/
|
|
||||||
public static final String LOGIN_USER = "saSessionLoginUserCache";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户ID
|
|
||||||
*/
|
|
||||||
public static final String USER_ID = "saSessionUserIdCache";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色列表
|
|
||||||
*/
|
|
||||||
public static final String ROLE_LIST = "saSessionRoleListCache";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限列表
|
|
||||||
*/
|
|
||||||
public static final String PERMISSION_LIST = "saSessionPermissionListCache";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单列表
|
|
||||||
*/
|
|
||||||
public static final String MENU_LIST = "saSessionMenuListCache";
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.enmus.common;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2025-06-28 14:09
|
|
||||||
* @description : [枚举定义]
|
|
||||||
*/
|
|
||||||
public interface IResultEnum {
|
|
||||||
|
|
||||||
// 项目服务名 系统编码
|
|
||||||
// 前台系统
|
|
||||||
String A = "101";
|
|
||||||
// APP系统
|
|
||||||
String B = "202";
|
|
||||||
|
|
||||||
// 登录
|
|
||||||
String LOGIN = "100";
|
|
||||||
// 用户
|
|
||||||
String USER = "101";
|
|
||||||
// 角色
|
|
||||||
String ROLE = "102";
|
|
||||||
// 菜单
|
|
||||||
String PERMISSION = "103";
|
|
||||||
// 登录日志
|
|
||||||
String LOGIN_LOG = "106";
|
|
||||||
// 操作日志
|
|
||||||
String OPER_LOG = "107";
|
|
||||||
|
|
||||||
// 成功状态常量
|
|
||||||
int SUCCESS = 200;
|
|
||||||
String SUCCESS_TEXT = "SUCCESS";
|
|
||||||
|
|
||||||
// 无法捕获的异常状态
|
|
||||||
int SERVER_ERROR = 500;
|
|
||||||
|
|
||||||
// 需要覆盖的方法 每个子类堆外暴露的方法
|
|
||||||
int status();
|
|
||||||
|
|
||||||
String message();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.enmus.limit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2025-06-28 14:09
|
|
||||||
* @description [限流类型,放入common工程防止不使用限流依赖后,注解报错]
|
|
||||||
*/
|
|
||||||
public enum LimitType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认策略全局限流
|
|
||||||
*/
|
|
||||||
DEFAULT,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据请求者IP进行限流
|
|
||||||
*/
|
|
||||||
IP;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.enmus.log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2025-06-28 14:09
|
|
||||||
* 业务状态
|
|
||||||
*/
|
|
||||||
public enum BusinessStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功
|
|
||||||
*/
|
|
||||||
SUCCESS,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 失败
|
|
||||||
*/
|
|
||||||
FAIL,
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
package org.leocoder.heritage.common.enmus.log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Leocoder
|
|
||||||
* @version 1.0
|
|
||||||
* @date 2025-06-28 14:09
|
|
||||||
* 客户端类型
|
|
||||||
*/
|
|
||||||
public enum ClientType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 其它
|
|
||||||
*/
|
|
||||||
OTHER,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后台用户
|
|
||||||
*/
|
|
||||||
MANAGE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移动端用户
|
|
||||||
*/
|
|
||||||
MOBILE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PC
|
|
||||||
*/
|
|
||||||
PC
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user