fix():格式规范修改

boot3.0
dongzeliang 2025-02-26 22:20:53 +08:00
parent 9a60f4e7c4
commit fdd5cd030f
17 changed files with 70 additions and 56 deletions

View File

@ -7,6 +7,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
*
* @Author DongZeLiang
*/
@Configuration
public class SpringDocConfig {

View File

@ -8,7 +8,6 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
@ -149,6 +148,9 @@ public @interface Excel {
*/
Type type () default Type.ALL;
/**
*
*/
enum Type {
ALL(0), EXPORT(1), IMPORT(2);
private final int value;
@ -162,6 +164,9 @@ public @interface Excel {
}
}
/**
*
*/
enum ColumnType {
NUMERIC(0), STRING(1), IMAGE(2);
private final int value;

View File

@ -11,7 +11,14 @@ import lombok.Getter;
*/
@Getter
public enum SysNormalDisableEnum {
/**
*
*/
ENABLE("0", "正常"),
/**
*
*/
DISABLE("1", "停用");
private final String code;
private final String info;

View File

@ -95,7 +95,7 @@ public class ServletUtils {
* @return Map
*/
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()) {
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
}

View File

@ -52,7 +52,7 @@ public final class HTMLFilter {
/**
* 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 />")
@ -98,7 +98,7 @@ public final class HTMLFilter {
* Default constructor.
*/
public HTMLFilter () {
vAllowed = new HashMap<>();
vAllowed = new HashMap<>(16);
final List<String> aAttList = new ArrayList<>();
aAttList.add("href");

View File

@ -247,7 +247,7 @@ public class IpUtils {
/**
* IP
*/
public static boolean isIP (String ip) {
public static boolean isIp(String ip) {
return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
}
@ -277,7 +277,7 @@ public class IpUtils {
/**
* :10.10.10.1-10.10.10.99ip
*/
public static boolean isIPSegment (String ipSeg) {
public static boolean isIpSegment(String ipSeg) {
return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
}
@ -317,11 +317,11 @@ public class IpUtils {
}
String[] ips = filter.split(";");
for (String iStr : ips) {
if (isIP(iStr) && iStr.equals(ip)) {
if (isIp(iStr) && iStr.equals(ip)) {
return true;
} else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip)) {
return true;
} else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
} else if (isIpSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
return true;
}
}

View File

@ -48,7 +48,7 @@ public class ExcelUtil<T> {
/**
* Excel sheet65536
*/
public static final int sheetSize = 65536;
public static final int SHEET_SIZE = 65536;
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) {
this.clazz = clazz;
@ -322,7 +322,7 @@ public class ExcelUtil<T> {
int rows = sheet.getLastRowNum();
if (rows > 0) {
// 定义一个map用于存放excel列的序号和field.
Map<String, Integer> cellMap = new HashMap<>();
Map<String, Integer> cellMap = new HashMap<>(16);
// 获取表头
Row heard = sheet.getRow(titleNum);
for (int i = 0 ; i < heard.getPhysicalNumberOfCells() ; i++) {
@ -336,7 +336,7 @@ public class ExcelUtil<T> {
}
// 有数据时才处理 得到类的所有field.
List<Object[]> fields = this.getFields();
Map<Integer, Object[]> fieldsMap = new HashMap<>();
Map<Integer, Object[]> fieldsMap = new HashMap<>(16);
for (Object[] objects : fields) {
Excel attr = (Excel) objects[1];
Integer column = cellMap.get(attr.name());
@ -489,7 +489,7 @@ public class ExcelUtil<T> {
*/
public void writeSheet () {
// 取出一共有多少个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++) {
createSheet(sheetNo, index);
@ -524,8 +524,8 @@ public class ExcelUtil<T> {
*/
@SuppressWarnings("unchecked")
public void fillExcelData (int index, Row row) {
int startNo = index * sheetSize;
int endNo = Math.min(startNo + sheetSize, list.size());
int startNo = index * SHEET_SIZE;
int endNo = Math.min(startNo + SHEET_SIZE, list.size());
int rowNo = (1 + rownum) - startNo;
for (int i = startNo ; i < endNo ; i++) {
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) {
// 写入各条记录,每条记录对应excel表中的一行
Map<String, CellStyle> styles = new HashMap<>();
Map<String, CellStyle> styles = new HashMap<>(16);
CellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
@ -634,7 +634,7 @@ public class ExcelUtil<T> {
* @return
*/
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) {
Excel excel = (Excel) os[1];
String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
@ -665,7 +665,7 @@ public class ExcelUtil<T> {
* @return
*/
private Map<String, CellStyle> annotationDataStyles (Workbook wb) {
Map<String, CellStyle> styles = new HashMap<>();
Map<String, CellStyle> styles = new HashMap<>(16);
for (Object[] os : fields) {
Excel excel = (Excel) os[1];
String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());

View File

@ -11,7 +11,7 @@ public class IdUtils {
*
* @return UUID
*/
public static String randomUUID () {
public static String randomUuid() {
return UUID.randomUUID().toString();
}
@ -20,7 +20,7 @@ public class IdUtils {
*
* @return UUID线
*/
public static String simpleUUID () {
public static String simpleUuid() {
return UUID.randomUUID().toString(true);
}
@ -29,7 +29,7 @@ public class IdUtils {
*
* @return UUID
*/
public static String fastUUID () {
public static String fastUuid() {
return UUID.fastUUID().toString();
}
@ -38,7 +38,7 @@ public class IdUtils {
*
* @return UUID线
*/
public static String fastSimpleUUID () {
public static String fastSimpleUuid() {
return UUID.fastUUID().toString(true);
}
}

View File

@ -69,7 +69,7 @@ public class BaseEntity implements Serializable {
public Map<String, Object> getParams () {
if (params == null) {
params = new HashMap<>();
params = new HashMap<>(16);
}
return params;
}

View File

@ -13,13 +13,13 @@ public class AuthUtil {
/**
* AuthLogic
*/
public final static AuthLogic authLogic = new AuthLogic();
public final static AuthLogic AUTH_LOGIC = new AuthLogic();
/**
*
*/
public static void logout () {
authLogic.logout();
AUTH_LOGIC.logout();
}
/**
@ -28,14 +28,14 @@ public class AuthUtil {
* @param token token
*/
public static void logoutByToken (String token) {
authLogic.logoutByToken(token);
AUTH_LOGIC.logoutByToken(token);
}
/**
*
*/
public static void checkLogin () {
authLogic.checkLogin();
AUTH_LOGIC.checkLogin();
}
/**
@ -46,7 +46,7 @@ public class AuthUtil {
* @return
*/
public static LoginUser getLoginUser (String token) {
return authLogic.getLoginUser(token);
return AUTH_LOGIC.getLoginUser(token);
}
/**
@ -55,7 +55,7 @@ public class AuthUtil {
* @param loginUser
*/
public static void verifyLoginUserExpire (LoginUser loginUser) {
authLogic.verifyLoginUserExpire(loginUser);
AUTH_LOGIC.verifyLoginUserExpire(loginUser);
}
/**
@ -66,7 +66,7 @@ public class AuthUtil {
* @return
*/
public static boolean hasRole (String role) {
return authLogic.hasRole(role);
return AUTH_LOGIC.hasRole(role);
}
/**
@ -75,7 +75,7 @@ public class AuthUtil {
* @param role
*/
public static void checkRole (String role) {
authLogic.checkRole(role);
AUTH_LOGIC.checkRole(role);
}
/**
@ -84,7 +84,7 @@ public class AuthUtil {
* @param requiresRoles
*/
public static void checkRole (RequiresRoles requiresRoles) {
authLogic.checkRole(requiresRoles);
AUTH_LOGIC.checkRole(requiresRoles);
}
/**
@ -93,7 +93,7 @@ public class AuthUtil {
* @param roles
*/
public static void checkRoleAnd (String... roles) {
authLogic.checkRoleAnd(roles);
AUTH_LOGIC.checkRoleAnd(roles);
}
/**
@ -102,7 +102,7 @@ public class AuthUtil {
* @param roles
*/
public static void checkRoleOr (String... roles) {
authLogic.checkRoleOr(roles);
AUTH_LOGIC.checkRoleOr(roles);
}
/**
@ -113,7 +113,7 @@ public class AuthUtil {
* @return
*/
public static boolean hasPermi (String permission) {
return authLogic.hasPermi(permission);
return AUTH_LOGIC.hasPermi(permission);
}
/**
@ -122,7 +122,7 @@ public class AuthUtil {
* @param permission
*/
public static void checkPermi (String permission) {
authLogic.checkPermi(permission);
AUTH_LOGIC.checkPermi(permission);
}
/**
@ -131,7 +131,7 @@ public class AuthUtil {
* @param requiresPermissions
*/
public static void checkPermi (RequiresPermissions requiresPermissions) {
authLogic.checkPermi(requiresPermissions);
AUTH_LOGIC.checkPermi(requiresPermissions);
}
/**
@ -140,7 +140,7 @@ public class AuthUtil {
* @param permissions
*/
public static void checkPermiAnd (String... permissions) {
authLogic.checkPermiAnd(permissions);
AUTH_LOGIC.checkPermiAnd(permissions);
}
/**
@ -149,6 +149,6 @@ public class AuthUtil {
* @param permissions
*/
public static void checkPermiOr (String... permissions) {
authLogic.checkPermiOr(permissions);
AUTH_LOGIC.checkPermiOr(permissions);
}
}

View File

@ -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
public void addInterceptors (InterceptorRegistry registry) {
registry.addInterceptor(getHeaderInterceptor())
.addPathPatterns("/**")
.excludePathPatterns(excludeUrls)
.excludePathPatterns(EXCLUDE_URLS)
.order(-10);
}

View File

@ -31,7 +31,7 @@ public class TokenService {
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
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;
@Autowired
@ -41,7 +41,7 @@ public class TokenService {
*
*/
public Map<String, Object> createToken (LoginUser loginUser) {
String token = IdUtils.fastUUID();
String token = IdUtils.fastUuid();
Long userId = loginUser.getSysUser().getUserId();
String userName = loginUser.getSysUser().getUserName();
loginUser.setToken(token);
@ -51,15 +51,15 @@ public class TokenService {
refreshToken(loginUser);
// Jwt存储信息
Map<String, Object> claimsMap = new HashMap<>();
Map<String, Object> claimsMap = new HashMap<>(16);
claimsMap.put(SecurityConstants.USER_KEY, token);
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
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("expires_in", expireTime);
rspMap.put("expires_in", EXPIRE_TIME);
return rspMap;
}
@ -141,10 +141,10 @@ public class TokenService {
*/
public void refreshToken (LoginUser loginUser) {
loginUser.setLoginTime(System.currentTimeMillis());
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_MINUTE);
// 根据uuid将loginUser缓存
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) {

View File

@ -80,7 +80,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
.queryParams(request.getQueryParams())
.requestHeaders(request.getHeaders())
.startTime(LocalDateTime.now())
.userIp(WebFrameworkUtils.getClientIP(exchange))
.userIp(WebFrameworkUtils.getClientIp(exchange))
.build();
// 继续 filter 过滤

View File

@ -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 capStr = null, code = null;

View File

@ -4,8 +4,6 @@ import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.fastjson2.JSONObject;
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.support.ServerWebExchangeUtils;
import org.springframework.core.io.buffer.DataBufferFactory;
@ -54,7 +52,7 @@ public class WebFrameworkUtils {
* @param object JSON
*/
@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
ServerHttpResponse response = exchange.getResponse();
response.getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8);
@ -79,7 +77,7 @@ public class WebFrameworkUtils {
* @param otherHeaderNames header
* @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" };
if (ArrayUtil.isNotEmpty(otherHeaderNames)) {
headers = ArrayUtil.addAll(headers, otherHeaderNames);

View File

@ -55,7 +55,7 @@ public class GenController extends BaseController {
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
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("rows", list);
map.put("tables", tables);

View File

@ -58,7 +58,7 @@ public class SysDictTypePageQueryModel extends QueryModel<SysDictTypePageQueryMo
public Map<String, Object> getParams () {
if (params == null) {
params = new HashMap<>();
params = new HashMap<>(16);
}
return params;
}