fix():格式规范修改
parent
9a60f4e7c4
commit
fdd5cd030f
|
@ -7,6 +7,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口文档配置
|
||||||
|
* @Author DongZeLiang
|
||||||
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SpringDocConfig {
|
public class SpringDocConfig {
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,6 +148,9 @@ public @interface Excel {
|
||||||
*/
|
*/
|
||||||
Type type () default Type.ALL;
|
Type type () default Type.ALL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段类型
|
||||||
|
*/
|
||||||
enum Type {
|
enum Type {
|
||||||
ALL(0), EXPORT(1), IMPORT(2);
|
ALL(0), EXPORT(1), IMPORT(2);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
@ -162,6 +164,9 @@ public @interface Excel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列类型
|
||||||
|
*/
|
||||||
enum ColumnType {
|
enum ColumnType {
|
||||||
NUMERIC(0), STRING(1), IMAGE(2);
|
NUMERIC(0), STRING(1), IMAGE(2);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
|
@ -11,7 +11,14 @@ import lombok.Getter;
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public enum SysNormalDisableEnum {
|
public enum SysNormalDisableEnum {
|
||||||
|
/**
|
||||||
|
* 正常
|
||||||
|
*/
|
||||||
ENABLE("0", "正常"),
|
ENABLE("0", "正常"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停用
|
||||||
|
*/
|
||||||
DISABLE("1", "停用");
|
DISABLE("1", "停用");
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String info;
|
private final String info;
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class ServletUtils {
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> getParamMap (ServletRequest request) {
|
public static Map<String, String> getParamMap (ServletRequest request) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>(16);
|
||||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class HTMLFilter {
|
||||||
/**
|
/**
|
||||||
* counts of open tags for each (allowable) html element
|
* counts of open tags for each (allowable) html element
|
||||||
**/
|
**/
|
||||||
private final Map<String, Integer> vTagCounts = new HashMap<>();
|
private final Map<String, Integer> vTagCounts = new HashMap<>(16);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* html elements which must always be self-closing (e.g. "<img />")
|
* html elements which must always be self-closing (e.g. "<img />")
|
||||||
|
@ -98,7 +98,7 @@ public final class HTMLFilter {
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public HTMLFilter () {
|
public HTMLFilter () {
|
||||||
vAllowed = new HashMap<>();
|
vAllowed = new HashMap<>(16);
|
||||||
|
|
||||||
final List<String> aAttList = new ArrayList<>();
|
final List<String> aAttList = new ArrayList<>();
|
||||||
aAttList.add("href");
|
aAttList.add("href");
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class IpUtils {
|
||||||
/**
|
/**
|
||||||
* 是否为IP
|
* 是否为IP
|
||||||
*/
|
*/
|
||||||
public static boolean isIP (String ip) {
|
public static boolean isIp(String ip) {
|
||||||
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
|
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class IpUtils {
|
||||||
/**
|
/**
|
||||||
* 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
|
* 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
|
||||||
*/
|
*/
|
||||||
public static boolean isIPSegment (String ipSeg) {
|
public static boolean isIpSegment(String ipSeg) {
|
||||||
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
|
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,11 +317,11 @@ public class IpUtils {
|
||||||
}
|
}
|
||||||
String[] ips = filter.split(";");
|
String[] ips = filter.split(";");
|
||||||
for (String iStr : ips) {
|
for (String iStr : ips) {
|
||||||
if (isIP(iStr) && iStr.equals(ip)) {
|
if (isIp(iStr) && iStr.equals(ip)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip)) {
|
} else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
|
} else if (isIpSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ExcelUtil<T> {
|
||||||
/**
|
/**
|
||||||
* Excel sheet最大行数,默认65536
|
* Excel sheet最大行数,默认65536
|
||||||
*/
|
*/
|
||||||
public static final int sheetSize = 65536;
|
public static final int SHEET_SIZE = 65536;
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
||||||
/**
|
/**
|
||||||
* 数字格式
|
* 数字格式
|
||||||
|
@ -121,7 +121,7 @@ public class ExcelUtil<T> {
|
||||||
/**
|
/**
|
||||||
* 统计列表
|
* 统计列表
|
||||||
*/
|
*/
|
||||||
private final Map<Integer, Double> statistics = new HashMap<>();
|
private final Map<Integer, Double> statistics = new HashMap<>(16);
|
||||||
|
|
||||||
public ExcelUtil (Class<T> clazz) {
|
public ExcelUtil (Class<T> clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
|
@ -322,7 +322,7 @@ public class ExcelUtil<T> {
|
||||||
int rows = sheet.getLastRowNum();
|
int rows = sheet.getLastRowNum();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
// 定义一个map用于存放excel列的序号和field.
|
// 定义一个map用于存放excel列的序号和field.
|
||||||
Map<String, Integer> cellMap = new HashMap<>();
|
Map<String, Integer> cellMap = new HashMap<>(16);
|
||||||
// 获取表头
|
// 获取表头
|
||||||
Row heard = sheet.getRow(titleNum);
|
Row heard = sheet.getRow(titleNum);
|
||||||
for (int i = 0 ; i < heard.getPhysicalNumberOfCells() ; i++) {
|
for (int i = 0 ; i < heard.getPhysicalNumberOfCells() ; i++) {
|
||||||
|
@ -336,7 +336,7 @@ public class ExcelUtil<T> {
|
||||||
}
|
}
|
||||||
// 有数据时才处理 得到类的所有field.
|
// 有数据时才处理 得到类的所有field.
|
||||||
List<Object[]> fields = this.getFields();
|
List<Object[]> fields = this.getFields();
|
||||||
Map<Integer, Object[]> fieldsMap = new HashMap<>();
|
Map<Integer, Object[]> fieldsMap = new HashMap<>(16);
|
||||||
for (Object[] objects : fields) {
|
for (Object[] objects : fields) {
|
||||||
Excel attr = (Excel) objects[1];
|
Excel attr = (Excel) objects[1];
|
||||||
Integer column = cellMap.get(attr.name());
|
Integer column = cellMap.get(attr.name());
|
||||||
|
@ -489,7 +489,7 @@ public class ExcelUtil<T> {
|
||||||
*/
|
*/
|
||||||
public void writeSheet () {
|
public void writeSheet () {
|
||||||
// 取出一共有多少个sheet.
|
// 取出一共有多少个sheet.
|
||||||
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
|
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / SHEET_SIZE));
|
||||||
for (int index = 0 ; index < sheetNo ; index++) {
|
for (int index = 0 ; index < sheetNo ; index++) {
|
||||||
createSheet(sheetNo, index);
|
createSheet(sheetNo, index);
|
||||||
|
|
||||||
|
@ -524,8 +524,8 @@ public class ExcelUtil<T> {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void fillExcelData (int index, Row row) {
|
public void fillExcelData (int index, Row row) {
|
||||||
int startNo = index * sheetSize;
|
int startNo = index * SHEET_SIZE;
|
||||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
int endNo = Math.min(startNo + SHEET_SIZE, list.size());
|
||||||
int rowNo = (1 + rownum) - startNo;
|
int rowNo = (1 + rownum) - startNo;
|
||||||
for (int i = startNo ; i < endNo ; i++) {
|
for (int i = startNo ; i < endNo ; i++) {
|
||||||
rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo;
|
rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo;
|
||||||
|
@ -582,7 +582,7 @@ public class ExcelUtil<T> {
|
||||||
*/
|
*/
|
||||||
private Map<String, CellStyle> createStyles (Workbook wb) {
|
private Map<String, CellStyle> createStyles (Workbook wb) {
|
||||||
// 写入各条记录,每条记录对应excel表中的一行
|
// 写入各条记录,每条记录对应excel表中的一行
|
||||||
Map<String, CellStyle> styles = new HashMap<>();
|
Map<String, CellStyle> styles = new HashMap<>(16);
|
||||||
CellStyle style = wb.createCellStyle();
|
CellStyle style = wb.createCellStyle();
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
@ -634,7 +634,7 @@ public class ExcelUtil<T> {
|
||||||
* @return 自定义样式列表
|
* @return 自定义样式列表
|
||||||
*/
|
*/
|
||||||
private Map<String, CellStyle> annotationHeaderStyles (Workbook wb, Map<String, CellStyle> styles) {
|
private Map<String, CellStyle> annotationHeaderStyles (Workbook wb, Map<String, CellStyle> styles) {
|
||||||
Map<String, CellStyle> headerStyles = new HashMap<>();
|
Map<String, CellStyle> headerStyles = new HashMap<>(16);
|
||||||
for (Object[] os : fields) {
|
for (Object[] os : fields) {
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
|
String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
|
||||||
|
@ -665,7 +665,7 @@ public class ExcelUtil<T> {
|
||||||
* @return 自定义样式列表
|
* @return 自定义样式列表
|
||||||
*/
|
*/
|
||||||
private Map<String, CellStyle> annotationDataStyles (Workbook wb) {
|
private Map<String, CellStyle> annotationDataStyles (Workbook wb) {
|
||||||
Map<String, CellStyle> styles = new HashMap<>();
|
Map<String, CellStyle> styles = new HashMap<>(16);
|
||||||
for (Object[] os : fields) {
|
for (Object[] os : fields) {
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());
|
String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class IdUtils {
|
||||||
*
|
*
|
||||||
* @return 随机UUID
|
* @return 随机UUID
|
||||||
*/
|
*/
|
||||||
public static String randomUUID () {
|
public static String randomUuid() {
|
||||||
return UUID.randomUUID().toString();
|
return UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class IdUtils {
|
||||||
*
|
*
|
||||||
* @return 简化的UUID,去掉了横线
|
* @return 简化的UUID,去掉了横线
|
||||||
*/
|
*/
|
||||||
public static String simpleUUID () {
|
public static String simpleUuid() {
|
||||||
return UUID.randomUUID().toString(true);
|
return UUID.randomUUID().toString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class IdUtils {
|
||||||
*
|
*
|
||||||
* @return 随机UUID
|
* @return 随机UUID
|
||||||
*/
|
*/
|
||||||
public static String fastUUID () {
|
public static String fastUuid() {
|
||||||
return UUID.fastUUID().toString();
|
return UUID.fastUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class IdUtils {
|
||||||
*
|
*
|
||||||
* @return 简化的UUID,去掉了横线
|
* @return 简化的UUID,去掉了横线
|
||||||
*/
|
*/
|
||||||
public static String fastSimpleUUID () {
|
public static String fastSimpleUuid() {
|
||||||
return UUID.fastUUID().toString(true);
|
return UUID.fastUUID().toString(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class BaseEntity implements Serializable {
|
||||||
|
|
||||||
public Map<String, Object> getParams () {
|
public Map<String, Object> getParams () {
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new HashMap<>();
|
params = new HashMap<>(16);
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ public class AuthUtil {
|
||||||
/**
|
/**
|
||||||
* 底层的 AuthLogic 对象
|
* 底层的 AuthLogic 对象
|
||||||
*/
|
*/
|
||||||
public final static AuthLogic authLogic = new AuthLogic();
|
public final static AuthLogic AUTH_LOGIC = new AuthLogic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会话注销
|
* 会话注销
|
||||||
*/
|
*/
|
||||||
public static void logout () {
|
public static void logout () {
|
||||||
authLogic.logout();
|
AUTH_LOGIC.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,14 +28,14 @@ public class AuthUtil {
|
||||||
* @param token 指定token
|
* @param token 指定token
|
||||||
*/
|
*/
|
||||||
public static void logoutByToken (String token) {
|
public static void logoutByToken (String token) {
|
||||||
authLogic.logoutByToken(token);
|
AUTH_LOGIC.logoutByToken(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检验当前会话是否已经登录,如未登录,则抛出异常
|
* 检验当前会话是否已经登录,如未登录,则抛出异常
|
||||||
*/
|
*/
|
||||||
public static void checkLogin () {
|
public static void checkLogin () {
|
||||||
authLogic.checkLogin();
|
AUTH_LOGIC.checkLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ public class AuthUtil {
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
public static LoginUser getLoginUser (String token) {
|
public static LoginUser getLoginUser (String token) {
|
||||||
return authLogic.getLoginUser(token);
|
return AUTH_LOGIC.getLoginUser(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class AuthUtil {
|
||||||
* @param loginUser 用户信息
|
* @param loginUser 用户信息
|
||||||
*/
|
*/
|
||||||
public static void verifyLoginUserExpire (LoginUser loginUser) {
|
public static void verifyLoginUserExpire (LoginUser loginUser) {
|
||||||
authLogic.verifyLoginUserExpire(loginUser);
|
AUTH_LOGIC.verifyLoginUserExpire(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,7 @@ public class AuthUtil {
|
||||||
* @return 是否含有指定角色标识
|
* @return 是否含有指定角色标识
|
||||||
*/
|
*/
|
||||||
public static boolean hasRole (String role) {
|
public static boolean hasRole (String role) {
|
||||||
return authLogic.hasRole(role);
|
return AUTH_LOGIC.hasRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,7 @@ public class AuthUtil {
|
||||||
* @param role 角色标识
|
* @param role 角色标识
|
||||||
*/
|
*/
|
||||||
public static void checkRole (String role) {
|
public static void checkRole (String role) {
|
||||||
authLogic.checkRole(role);
|
AUTH_LOGIC.checkRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public class AuthUtil {
|
||||||
* @param requiresRoles 角色权限注解
|
* @param requiresRoles 角色权限注解
|
||||||
*/
|
*/
|
||||||
public static void checkRole (RequiresRoles requiresRoles) {
|
public static void checkRole (RequiresRoles requiresRoles) {
|
||||||
authLogic.checkRole(requiresRoles);
|
AUTH_LOGIC.checkRole(requiresRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ public class AuthUtil {
|
||||||
* @param roles 角色标识数组
|
* @param roles 角色标识数组
|
||||||
*/
|
*/
|
||||||
public static void checkRoleAnd (String... roles) {
|
public static void checkRoleAnd (String... roles) {
|
||||||
authLogic.checkRoleAnd(roles);
|
AUTH_LOGIC.checkRoleAnd(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,7 @@ public class AuthUtil {
|
||||||
* @param roles 角色标识数组
|
* @param roles 角色标识数组
|
||||||
*/
|
*/
|
||||||
public static void checkRoleOr (String... roles) {
|
public static void checkRoleOr (String... roles) {
|
||||||
authLogic.checkRoleOr(roles);
|
AUTH_LOGIC.checkRoleOr(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +113,7 @@ public class AuthUtil {
|
||||||
* @return 是否含有指定权限
|
* @return 是否含有指定权限
|
||||||
*/
|
*/
|
||||||
public static boolean hasPermi (String permission) {
|
public static boolean hasPermi (String permission) {
|
||||||
return authLogic.hasPermi(permission);
|
return AUTH_LOGIC.hasPermi(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@ public class AuthUtil {
|
||||||
* @param permission 权限码
|
* @param permission 权限码
|
||||||
*/
|
*/
|
||||||
public static void checkPermi (String permission) {
|
public static void checkPermi (String permission) {
|
||||||
authLogic.checkPermi(permission);
|
AUTH_LOGIC.checkPermi(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,7 @@ public class AuthUtil {
|
||||||
* @param requiresPermissions 权限注解
|
* @param requiresPermissions 权限注解
|
||||||
*/
|
*/
|
||||||
public static void checkPermi (RequiresPermissions requiresPermissions) {
|
public static void checkPermi (RequiresPermissions requiresPermissions) {
|
||||||
authLogic.checkPermi(requiresPermissions);
|
AUTH_LOGIC.checkPermi(requiresPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,7 @@ public class AuthUtil {
|
||||||
* @param permissions 权限码数组
|
* @param permissions 权限码数组
|
||||||
*/
|
*/
|
||||||
public static void checkPermiAnd (String... permissions) {
|
public static void checkPermiAnd (String... permissions) {
|
||||||
authLogic.checkPermiAnd(permissions);
|
AUTH_LOGIC.checkPermiAnd(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,6 +149,6 @@ public class AuthUtil {
|
||||||
* @param permissions 权限码数组
|
* @param permissions 权限码数组
|
||||||
*/
|
*/
|
||||||
public static void checkPermiOr (String... permissions) {
|
public static void checkPermiOr (String... permissions) {
|
||||||
authLogic.checkPermiOr(permissions);
|
AUTH_LOGIC.checkPermiOr(permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
/**
|
/**
|
||||||
* 不需要拦截地址
|
* 不需要拦截地址
|
||||||
*/
|
*/
|
||||||
public static final String[] excludeUrls = {"/login", "/logout", "/refresh"};
|
public static final String[] EXCLUDE_URLS = {"/login", "/logout", "/refresh"};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors (InterceptorRegistry registry) {
|
public void addInterceptors (InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(getHeaderInterceptor())
|
registry.addInterceptor(getHeaderInterceptor())
|
||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns(excludeUrls)
|
.excludePathPatterns(EXCLUDE_URLS)
|
||||||
.order(-10);
|
.order(-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class TokenService {
|
||||||
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
|
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
|
||||||
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
||||||
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
|
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
|
||||||
private final static long expireTime = CacheConstants.EXPIRATION;
|
private final static long EXPIRE_TIME = CacheConstants.EXPIRATION;
|
||||||
|
|
||||||
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -41,7 +41,7 @@ public class TokenService {
|
||||||
* 创建令牌
|
* 创建令牌
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> createToken (LoginUser loginUser) {
|
public Map<String, Object> createToken (LoginUser loginUser) {
|
||||||
String token = IdUtils.fastUUID();
|
String token = IdUtils.fastUuid();
|
||||||
Long userId = loginUser.getSysUser().getUserId();
|
Long userId = loginUser.getSysUser().getUserId();
|
||||||
String userName = loginUser.getSysUser().getUserName();
|
String userName = loginUser.getSysUser().getUserName();
|
||||||
loginUser.setToken(token);
|
loginUser.setToken(token);
|
||||||
|
@ -51,15 +51,15 @@ public class TokenService {
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
|
|
||||||
// Jwt存储信息
|
// Jwt存储信息
|
||||||
Map<String, Object> claimsMap = new HashMap<>();
|
Map<String, Object> claimsMap = new HashMap<>(16);
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
|
|
||||||
// 接口返回信息
|
// 接口返回信息
|
||||||
Map<String, Object> rspMap = new HashMap<>();
|
Map<String, Object> rspMap = new HashMap<>(16);
|
||||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||||
rspMap.put("expires_in", expireTime);
|
rspMap.put("expires_in", EXPIRE_TIME);
|
||||||
return rspMap;
|
return rspMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,10 +141,10 @@ public class TokenService {
|
||||||
*/
|
*/
|
||||||
public void refreshToken (LoginUser loginUser) {
|
public void refreshToken (LoginUser loginUser) {
|
||||||
loginUser.setLoginTime(System.currentTimeMillis());
|
loginUser.setLoginTime(System.currentTimeMillis());
|
||||||
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_MINUTE);
|
||||||
// 根据uuid将loginUser缓存
|
// 根据uuid将loginUser缓存
|
||||||
String userKey = getTokenKey(loginUser.getToken());
|
String userKey = getTokenKey(loginUser.getToken());
|
||||||
redisService.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
redisService.setCacheObject(userKey, loginUser, EXPIRE_TIME, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTokenKey (String token) {
|
private String getTokenKey (String token) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
||||||
.queryParams(request.getQueryParams())
|
.queryParams(request.getQueryParams())
|
||||||
.requestHeaders(request.getHeaders())
|
.requestHeaders(request.getHeaders())
|
||||||
.startTime(LocalDateTime.now())
|
.startTime(LocalDateTime.now())
|
||||||
.userIp(WebFrameworkUtils.getClientIP(exchange))
|
.userIp(WebFrameworkUtils.getClientIp(exchange))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 继续 filter 过滤
|
// 继续 filter 过滤
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
String uuid = IdUtils.simpleUUID();
|
String uuid = IdUtils.simpleUuid();
|
||||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
||||||
|
|
||||||
String capStr = null, code = null;
|
String capStr = null, code = null;
|
||||||
|
|
|
@ -4,8 +4,6 @@ import cn.hutool.core.net.NetUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.cloud.gateway.route.Route;
|
import org.springframework.cloud.gateway.route.Route;
|
||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||||
|
@ -54,7 +52,7 @@ public class WebFrameworkUtils {
|
||||||
* @param object 对象,会序列化成 JSON 字符串
|
* @param object 对象,会序列化成 JSON 字符串
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码
|
@SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码
|
||||||
public static Mono<Void> writeJSON(ServerWebExchange exchange, Object object) {
|
public static Mono<Void> writeJson(ServerWebExchange exchange, Object object) {
|
||||||
// 设置 header
|
// 设置 header
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
ServerHttpResponse response = exchange.getResponse();
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8);
|
response.getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||||
|
@ -79,7 +77,7 @@ public class WebFrameworkUtils {
|
||||||
* @param otherHeaderNames 其它 header 名字的数组
|
* @param otherHeaderNames 其它 header 名字的数组
|
||||||
* @return 客户端 IP
|
* @return 客户端 IP
|
||||||
*/
|
*/
|
||||||
public static String getClientIP(ServerWebExchange exchange, String... otherHeaderNames) {
|
public static String getClientIp(ServerWebExchange exchange, String... otherHeaderNames) {
|
||||||
String[] headers = { "X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR" };
|
String[] headers = { "X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR" };
|
||||||
if (ArrayUtil.isNotEmpty(otherHeaderNames)) {
|
if (ArrayUtil.isNotEmpty(otherHeaderNames)) {
|
||||||
headers = ArrayUtil.addAll(headers, otherHeaderNames);
|
headers = ArrayUtil.addAll(headers, otherHeaderNames);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class GenController extends BaseController {
|
||||||
GenTable table = genTableService.selectGenTableById(tableId);
|
GenTable table = genTableService.selectGenTableById(tableId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>(16);
|
||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
map.put("tables", tables);
|
map.put("tables", tables);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SysDictTypePageQueryModel extends QueryModel<SysDictTypePageQueryMo
|
||||||
|
|
||||||
public Map<String, Object> getParams () {
|
public Map<String, Object> getParams () {
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new HashMap<>();
|
params = new HashMap<>(16);
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue