diff --git a/code-style/Java开发手册(黄山版).pdf b/.style/Java开发手册(黄山版).pdf similarity index 100% rename from code-style/Java开发手册(黄山版).pdf rename to .style/Java开发手册(黄山版).pdf diff --git a/code-style/license-header b/.style/license-header similarity index 100% rename from code-style/license-header rename to .style/license-header diff --git a/.style/p3c-codestyle.xml b/.style/p3c-codestyle.xml new file mode 100644 index 00000000..fb5f47f3 --- /dev/null +++ b/.style/p3c-codestyle.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java b/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java index 91525096..e6d37d5a 100644 --- a/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java +++ b/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; - /** * API 文档自动配置 * @@ -63,8 +62,9 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer { public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/"); registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/") - .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic()); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/") + .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic()); } /** @@ -73,20 +73,16 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer { @Bean @ConditionalOnMissingBean public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionProperties properties) { - Info info = new Info() - .title(String.format("%s %s", projectProperties.getName(), "API 文档")) - .version(projectProperties.getVersion()) - .description(projectProperties.getDescription()); + Info info = new Info().title(String.format("%s %s", projectProperties.getName(), "API 文档")) + .version(projectProperties.getVersion()) + .description(projectProperties.getDescription()); ProjectProperties.Contact contact = projectProperties.getContact(); if (null != contact) { - info.contact(new Contact().name(contact.getName()) - .email(contact.getEmail()) - .url(contact.getUrl())); + info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl())); } ProjectProperties.License license = projectProperties.getLicense(); if (null != license) { - info.license(new License().name(license.getName()) - .url(license.getUrl())); + info.license(new License().name(license.getName()).url(license.getUrl())); } OpenAPI openAPI = new OpenAPI(); openAPI.info(info); @@ -120,7 +116,10 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer { Map securitySchemeMap = components.getSecuritySchemes(); pathItem.readOperations().forEach(operation -> { SecurityRequirement securityRequirement = new SecurityRequirement(); - List list = securitySchemeMap.values().stream().map(SecurityScheme::getName).toList(); + List list = securitySchemeMap.values() + .stream() + .map(SecurityScheme::getName) + .toList(); list.forEach(securityRequirement::addList); operation.addSecurityItem(securityRequirement); }); diff --git a/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocExtensionProperties.java b/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocExtensionProperties.java index 323c2aff..a1977b4b 100644 --- a/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocExtensionProperties.java +++ b/continew-starter-api-doc/src/main/java/top/charles7c/continew/starter/apidoc/autoconfigure/SpringDocExtensionProperties.java @@ -21,7 +21,6 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; - /** * API 文档扩展配置属性 * diff --git a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java index bbe83db1..65f88999 100644 --- a/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java +++ b/continew-starter-auth/continew-starter-auth-justauth/src/main/java/top/charles7c/continew/starter/auth/justauth/impl/JustAuthStateCacheRedisImpl.java @@ -40,8 +40,7 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache { @Override public void cache(String key, String value) { // 参考:在 JustAuth 中,内置了一个基于 map 的 state 缓存器,默认缓存有效期为 3 分钟 - RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value, - Duration.ofMinutes(3)); + RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value, Duration.ofMinutes(3)); } /** @@ -53,8 +52,7 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache { */ @Override public void cache(String key, String value, long timeout) { - RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value, - Duration.ofMillis(timeout)); + RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value, Duration.ofMillis(timeout)); } /** diff --git a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java index 3176deed..a4950623 100644 --- a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java +++ b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java @@ -57,8 +57,9 @@ public class SaTokenAutoConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { // 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验 - registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin())).addPathPatterns(StringConstants.PATH_PATTERN) - .excludePathPatterns(properties.getSecurity().getExcludes()); + registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin())) + .addPathPatterns(StringConstants.PATH_PATTERN) + .excludePathPatterns(properties.getSecurity().getExcludes()); } /** diff --git a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenExtensionProperties.java b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenExtensionProperties.java index 9c4894a5..970935c4 100644 --- a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenExtensionProperties.java +++ b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/charles7c/continew/starter/auth/satoken/autoconfigure/SaTokenExtensionProperties.java @@ -23,7 +23,6 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; import top.charles7c.continew.starter.auth.satoken.properties.SaTokenDaoProperties; import top.charles7c.continew.starter.auth.satoken.properties.SaTokenSecurityProperties; - /** * SaToken 扩展配置属性 * diff --git a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java index 71f12eb7..608c3bf4 100644 --- a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java +++ b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java @@ -86,7 +86,9 @@ public class RedissonAutoConfiguration { // 下方配置如果为空,则使用 Redis 的配置 if (CollUtil.isEmpty(sentinelServersConfig.getSentinelAddresses())) { List nodeList = redisProperties.getSentinel().getNodes(); - nodeList.stream().map(node -> protocol + node).forEach(sentinelServersConfig::addSentinelAddress); + nodeList.stream() + .map(node -> protocol + node) + .forEach(sentinelServersConfig::addSentinelAddress); } if (StrUtil.isBlank(sentinelServersConfig.getPassword())) { sentinelServersConfig.setPassword(redisProperties.getPassword()); @@ -107,7 +109,8 @@ public class RedissonAutoConfiguration { singleServerConfig.setPassword(redisProperties.getPassword()); } if (StrUtil.isBlank(singleServerConfig.getAddress())) { - singleServerConfig.setAddress(protocol + redisProperties.getHost() + StringConstants.COLON + redisProperties.getPort()); + singleServerConfig.setAddress(protocol + redisProperties + .getHost() + StringConstants.COLON + redisProperties.getPort()); } } } diff --git a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonProperties.java b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonProperties.java index 8c6aa3cd..efdc1067 100644 --- a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonProperties.java +++ b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/charles7c/continew/starter/cache/redisson/autoconfigure/RedissonProperties.java @@ -22,7 +22,6 @@ import org.redisson.config.SentinelServersConfig; import org.redisson.config.SingleServerConfig; import org.springframework.boot.context.properties.ConfigurationProperties; - /** * Redisson 配置属性 * diff --git a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaAutoConfiguration.java b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaAutoConfiguration.java index c384d4d4..bb5e1a89 100644 --- a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaAutoConfiguration.java +++ b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaAutoConfiguration.java @@ -62,8 +62,7 @@ public class BehaviorCaptchaAutoConfiguration { */ @Configuration @Import({BehaviorCaptchaCacheConfiguration.Redis.class, BehaviorCaptchaCacheConfiguration.Custom.class}) - protected static class BehaviorCaptchaCacheAutoConfiguration { - } + protected static class BehaviorCaptchaCacheAutoConfiguration {} /** * 行为验证码服务接口 @@ -94,8 +93,8 @@ public class BehaviorCaptchaAutoConfiguration { config.put(Const.CAPTCHA_FONT_SIZE, properties.getFontSize()); config.put(Const.CAPTCHA_FONT_STYLE, properties.getFontStyle()); config.put(Const.CAPTCHA_WORD_COUNT, 4); - if (StrUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:") - || StrUtil.startWith(properties.getPicClickBaseMapPath(), "classpath:")) { + if (StrUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:") || StrUtil.startWith(properties + .getPicClickBaseMapPath(), "classpath:")) { // 自定义 resources 目录下初始化底图 config.put(Const.CAPTCHA_INIT_ORIGINAL, true); initializeBaseMap(properties.getJigsawBaseMapPath(), properties.getPicClickBaseMapPath()); @@ -110,9 +109,8 @@ public class BehaviorCaptchaAutoConfiguration { * @param picClick 点选验证码底图路径 */ private static void initializeBaseMap(String jigsaw, String picClick) { - ImageUtils.cacheBootImage(getResourcesImagesFile(jigsaw + "/original/*.png"), - getResourcesImagesFile(jigsaw + "/slidingBlock/*.png"), - getResourcesImagesFile(picClick + "/*.png")); + ImageUtils + .cacheBootImage(getResourcesImagesFile(jigsaw + "/original/*.png"), getResourcesImagesFile(jigsaw + "/slidingBlock/*.png"), getResourcesImagesFile(picClick + "/*.png")); } /** diff --git a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java index 2fc127c7..08bd11d1 100644 --- a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java +++ b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java @@ -53,7 +53,8 @@ abstract class BehaviorCaptchaCacheConfiguration { @ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "redis") static class Redis { static { - CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl()); + CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name() + .toLowerCase(), new BehaviorCaptchaCacheServiceImpl()); log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization."); } } @@ -72,7 +73,8 @@ abstract class BehaviorCaptchaCacheConfiguration { @PostConstruct public void postConstruct() { - CaptchaServiceFactory.cacheService.put(StorageType.CUSTOM.name().toLowerCase(), SpringUtil.getBean(CaptchaCacheService.class)); + CaptchaServiceFactory.cacheService.put(StorageType.CUSTOM.name().toLowerCase(), SpringUtil + .getBean(CaptchaCacheService.class)); log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Custom' completed initialization."); } } diff --git a/continew-starter-captcha/continew-starter-captcha-graphic/src/main/java/top/charles7c/continew/starter/captcha/graphic/enums/GraphicCaptchaType.java b/continew-starter-captcha/continew-starter-captcha-graphic/src/main/java/top/charles7c/continew/starter/captcha/graphic/enums/GraphicCaptchaType.java index 506992c7..1afffcaf 100644 --- a/continew-starter-captcha/continew-starter-captcha-graphic/src/main/java/top/charles7c/continew/starter/captcha/graphic/enums/GraphicCaptchaType.java +++ b/continew-starter-captcha/continew-starter-captcha-graphic/src/main/java/top/charles7c/continew/starter/captcha/graphic/enums/GraphicCaptchaType.java @@ -54,8 +54,7 @@ public enum GraphicCaptchaType { /** * 特殊类型 */ - SPEC(SpecCaptcha.class), - ; + SPEC(SpecCaptcha.class),; /** * 验证码实现 diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/project/ProjectProperties.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/project/ProjectProperties.java index 39bdebe2..2a363721 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/project/ProjectProperties.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/project/ProjectProperties.java @@ -81,8 +81,9 @@ public class ProjectProperties { public static final boolean IP_ADDR_LOCAL_PARSE_ENABLED; static { - IP_ADDR_LOCAL_PARSE_ENABLED = SpringUtil.getProperty("project.ip-addr-local-parse-enabled", boolean.class, false) - || SpringUtil.getProperty("project.ipAddrLocalParseEnabled", boolean.class, false); + IP_ADDR_LOCAL_PARSE_ENABLED = SpringUtil + .getProperty("project.ip-addr-local-parse-enabled", boolean.class, false) || SpringUtil + .getProperty("project.ipAddrLocalParseEnabled", boolean.class, false); } /** diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/AsyncAutoConfiguration.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/AsyncAutoConfiguration.java index cfa09ea2..6ca95689 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/AsyncAutoConfiguration.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/AsyncAutoConfiguration.java @@ -66,8 +66,10 @@ public class AsyncAutoConfiguration implements AsyncConfigurer { return (throwable, method, objects) -> { throwable.printStackTrace(); StringBuilder sb = new StringBuilder(); - sb.append("Exception message: ").append(throwable.getMessage()).append(", Method name: ") - .append(method.getName()); + sb.append("Exception message: ") + .append(throwable.getMessage()) + .append(", Method name: ") + .append(method.getName()); if (ArrayUtil.isNotEmpty(objects)) { sb.append(", Parameter value: ").append(Arrays.toString(objects)); } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java index 5bbcf617..ee3f47cc 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java @@ -78,9 +78,9 @@ public class ThreadPoolAutoConfiguration { @Bean @ConditionalOnMissingBean public ScheduledExecutorService scheduledExecutorService(ThreadPoolProperties properties) { - ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(ObjectUtil.defaultIfNull(properties.getCorePoolSize(), corePoolSize), - ThreadUtil.newNamedThreadFactory("schedule-pool-%d", true), - new ThreadPoolExecutor.CallerRunsPolicy()) { + ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(ObjectUtil.defaultIfNull(properties + .getCorePoolSize(), corePoolSize), ThreadUtil + .newNamedThreadFactory("schedule-pool-%d", true), new ThreadPoolExecutor.CallerRunsPolicy()) { @Override protected void afterExecute(Runnable runnable, Throwable throwable) { super.afterExecute(runnable, throwable); diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/handler/GeneralPropertySourceFactory.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/handler/GeneralPropertySourceFactory.java index aa5e3d6d..506d110d 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/handler/GeneralPropertySourceFactory.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/handler/GeneralPropertySourceFactory.java @@ -27,7 +27,11 @@ import org.springframework.lang.Nullable; import java.io.IOException; /** - * 通用配置文件读取工厂(DefaultPropertySourceFactory 仅支持 properties 配置文件读取,详见:YAML Shortcomings) + * 通用配置文件读取工厂 + *

+ * DefaultPropertySourceFactory 仅支持 properties + * 配置文件读取,详见:YAMLShortcomings + *

* * @author Charles7c * @since 1.0.0 @@ -35,7 +39,8 @@ import java.io.IOException; public class GeneralPropertySourceFactory extends DefaultPropertySourceFactory { @Override - public PropertySource createPropertySource(@Nullable String name, EncodedResource encodedResource) throws IOException { + public PropertySource createPropertySource(@Nullable String name, + EncodedResource encodedResource) throws IOException { Resource resource = encodedResource.getResource(); String resourceName = resource.getFilename(); if (StrUtil.isNotBlank(resourceName) && StrUtil.endWithAny(resourceName, ".yml", ".yaml")) { diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/FileUploadUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/FileUploadUtils.java index 86eef811..f73e320b 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/FileUploadUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/FileUploadUtils.java @@ -53,8 +53,8 @@ public class FileUploadUtils { String fileName; if (isKeepOriginalFilename) { - fileName = String.format("%s-%s.%s", FileNameUtil.getPrefix(originalFilename), - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), extensionName); + fileName = String.format("%s-%s.%s", FileNameUtil.getPrefix(originalFilename), DateUtil.format(LocalDateTime + .now(), DatePattern.PURE_DATETIME_MS_PATTERN), extensionName); } else { fileName = String.format("%s.%s", IdUtil.fastSimpleUUID(), extensionName); } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/ServletUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/ServletUtils.java index 9187d72a..80a7ed10 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/ServletUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/ServletUtils.java @@ -120,6 +120,6 @@ public class ServletUtils { } private static ServletRequestAttributes getServletRequestAttributes() { - return (ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes()); + return (ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes()); } } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/SpringUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/SpringUtils.java index d30b89b6..379d4c88 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/SpringUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/SpringUtils.java @@ -49,8 +49,10 @@ public class SpringUtils { public static void deRegisterResourceHandler(Map handlerMap) { ApplicationContext applicationContext = SpringUtil.getApplicationContext(); // 获取已经注册的映射 - final HandlerMapping resourceHandlerMapping = applicationContext.getBean("resourceHandlerMapping", HandlerMapping.class); - final Map oldHandlerMap = (Map) ReflectUtil.getFieldValue(resourceHandlerMapping, "handlerMap"); + final HandlerMapping resourceHandlerMapping = applicationContext + .getBean("resourceHandlerMapping", HandlerMapping.class); + final Map oldHandlerMap = (Map)ReflectUtil + .getFieldValue(resourceHandlerMapping, "handlerMap"); // 移除之前注册的映射 for (Map.Entry entry : handlerMap.entrySet()) { String pathPattern = StrUtil.appendIfMissing(entry.getKey(), StringConstants.PATH_PATTERN); @@ -66,11 +68,14 @@ public class SpringUtils { public static void registerResourceHandler(Map handlerMap) { ApplicationContext applicationContext = SpringUtil.getApplicationContext(); // 获取已经注册的映射 - final HandlerMapping resourceHandlerMapping = applicationContext.getBean("resourceHandlerMapping", HandlerMapping.class); - final Map oldHandlerMap = (Map) ReflectUtil.getFieldValue(resourceHandlerMapping, "handlerMap"); + final HandlerMapping resourceHandlerMapping = applicationContext + .getBean("resourceHandlerMapping", HandlerMapping.class); + final Map oldHandlerMap = (Map)ReflectUtil + .getFieldValue(resourceHandlerMapping, "handlerMap"); // 重新注册映射 final ServletContext servletContext = applicationContext.getBean(ServletContext.class); - final ContentNegotiationManager contentNegotiationManager = applicationContext.getBean("mvcContentNegotiationManager", ContentNegotiationManager.class); + final ContentNegotiationManager contentNegotiationManager = applicationContext + .getBean("mvcContentNegotiationManager", ContentNegotiationManager.class); final UrlPathHelper urlPathHelper = applicationContext.getBean("mvcUrlPathHelper", UrlPathHelper.class); final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper); for (Map.Entry entry : handlerMap.entrySet()) { @@ -81,7 +86,9 @@ public class SpringUtils { String resourceLocations = StrUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH); resourceHandlerRegistry.addResourceHandler(pathPattern).addResourceLocations("file:" + resourceLocations); } - final Map additionalUrlMap = ReflectUtil.invoke(resourceHandlerRegistry, "getHandlerMapping").getUrlMap(); + final Map additionalUrlMap = ReflectUtil + .invoke(resourceHandlerRegistry, "getHandlerMapping") + .getUrlMap(); ReflectUtil.invoke(resourceHandlerMapping, "registerHandlers", additionalUrlMap); } } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/TemplateUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/TemplateUtils.java index 2205bc4b..607833e6 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/TemplateUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/TemplateUtils.java @@ -56,8 +56,8 @@ public class TemplateUtils { * @return 渲染后的内容 */ public static String render(String parentPath, String templatePath, Map bindingMap) { - TemplateEngine engine = - TemplateUtil.createEngine(new TemplateConfig(parentPath, TemplateConfig.ResourceMode.CLASSPATH)); + TemplateEngine engine = TemplateUtil + .createEngine(new TemplateConfig(parentPath, TemplateConfig.ResourceMode.CLASSPATH)); Template template = engine.getTemplate(templatePath); return template.render(bindingMap); } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/CheckUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/CheckUtils.java index cf153047..ae900362 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/CheckUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/CheckUtils.java @@ -47,8 +47,8 @@ public class CheckUtils extends Validator { * @param fieldValue 字段值 */ public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) { - String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, - StrUtil.replace(entityName, "DO", StringConstants.EMPTY)); + String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil + .replace(entityName, "DO", StringConstants.EMPTY)); throwIfNull(obj, message, EXCEPTION_TYPE); } @@ -175,7 +175,9 @@ public class CheckUtils extends Validator { * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null" * @param params 参数值 */ - public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, + public static void throwIfNotEqualIgnoreCase(CharSequence str1, + CharSequence str2, + String template, Object... params) { throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE); } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/ValidationUtils.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/ValidationUtils.java index b1d25811..74c20ce1 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/ValidationUtils.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/ValidationUtils.java @@ -147,7 +147,9 @@ public class ValidationUtils extends Validator { * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null,返回 "null" * @param params 参数值 */ - public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, + public static void throwIfNotEqualIgnoreCase(CharSequence str1, + CharSequence str2, + String template, Object... params) { throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE); } diff --git a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/Validator.java b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/Validator.java index ee43f605..cf986f9e 100644 --- a/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/Validator.java +++ b/continew-starter-core/src/main/java/top/charles7c/continew/starter/core/util/validate/Validator.java @@ -86,7 +86,8 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfBlank(CharSequence str, String message, + protected static void throwIfBlank(CharSequence str, + String message, Class exceptionType) { throwIf(StrUtil.isBlank(str), message, exceptionType); } @@ -98,7 +99,8 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfNotBlank(CharSequence str, String message, + protected static void throwIfNotBlank(CharSequence str, + String message, Class exceptionType) { throwIf(StrUtil.isNotBlank(str), message, exceptionType); } @@ -111,7 +113,9 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfEqual(Object obj1, Object obj2, String message, + protected static void throwIfEqual(Object obj1, + Object obj2, + String message, Class exceptionType) { throwIf(ObjectUtil.equal(obj1, obj2), message, exceptionType); } @@ -124,7 +128,9 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfNotEqual(Object obj1, Object obj2, String message, + protected static void throwIfNotEqual(Object obj1, + Object obj2, + String message, Class exceptionType) { throwIf(ObjectUtil.notEqual(obj1, obj2), message, exceptionType); } @@ -137,7 +143,9 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message, + protected static void throwIfEqualIgnoreCase(CharSequence str1, + CharSequence str2, + String message, Class exceptionType) { throwIf(StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType); } @@ -150,7 +158,9 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message, + protected static void throwIfNotEqualIgnoreCase(CharSequence str1, + CharSequence str2, + String message, Class exceptionType) { throwIf(!StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType); } @@ -176,7 +186,8 @@ public class Validator { * @param message 错误信息 * @param exceptionType 异常类型 */ - protected static void throwIf(BooleanSupplier conditionSupplier, String message, + protected static void throwIf(BooleanSupplier conditionSupplier, + String message, Class exceptionType) { if (null != conditionSupplier && conditionSupplier.getAsBoolean()) { log.error(message); diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/ConditionalOnEnabledDataPermission.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/ConditionalOnEnabledDataPermission.java index 2e22fd18..49a4bdc7 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/ConditionalOnEnabledDataPermission.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/ConditionalOnEnabledDataPermission.java @@ -27,7 +27,8 @@ import java.lang.annotation.*; * @since 1.1.0 */ @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Documented @ConditionalOnProperty(prefix = "mybatis-plus.extension.data-permission", name = "enabled", havingValue = "true") -public @interface ConditionalOnEnabledDataPermission {} \ No newline at end of file +public @interface ConditionalOnEnabledDataPermission { +} \ No newline at end of file diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MyBatisPlusExtensionProperties.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MyBatisPlusExtensionProperties.java index b4dcbd29..4bb73b9e 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MyBatisPlusExtensionProperties.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MyBatisPlusExtensionProperties.java @@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.annotation.DbType; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; - /** * MyBatis Plus 扩展配置属性 * diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MybatisPlusAutoConfiguration.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MybatisPlusAutoConfiguration.java index dae8830e..ce92c2c3 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MybatisPlusAutoConfiguration.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/autoconfigure/MybatisPlusAutoConfiguration.java @@ -39,7 +39,6 @@ import top.charles7c.continew.starter.core.handler.GeneralPropertySourceFactory; import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionFilter; import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionHandlerImpl; - /** * MyBatis Plus 自动配置 * @@ -63,9 +62,11 @@ public class MybatisPlusAutoConfiguration { public MybatisPlusInterceptor mybatisPlusInterceptor(MyBatisPlusExtensionProperties properties) { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // 数据权限插件 - MyBatisPlusExtensionProperties.DataPermissionProperties dataPermissionProperties = properties.getDataPermission(); + MyBatisPlusExtensionProperties.DataPermissionProperties dataPermissionProperties = properties + .getDataPermission(); if (null != dataPermissionProperties && dataPermissionProperties.isEnabled()) { - interceptor.addInnerInterceptor(new DataPermissionInterceptor(SpringUtil.getBean(DataPermissionHandler.class))); + interceptor.addInnerInterceptor(new DataPermissionInterceptor(SpringUtil + .getBean(DataPermissionHandler.class))); } // 分页插件 MyBatisPlusExtensionProperties.PaginationProperties paginationProperties = properties.getPagination(); @@ -105,8 +106,8 @@ public class MybatisPlusAutoConfiguration { private PaginationInnerInterceptor paginationInnerInterceptor(MyBatisPlusExtensionProperties.PaginationProperties paginationProperties) { // 对于单一数据库类型来说,都建议配置该值,避免每次分页都去抓取数据库类型 PaginationInnerInterceptor paginationInnerInterceptor = null != paginationProperties.getDbType() - ? new PaginationInnerInterceptor(paginationProperties.getDbType()) - : new PaginationInnerInterceptor(); + ? new PaginationInnerInterceptor(paginationProperties.getDbType()) + : new PaginationInnerInterceptor(); paginationInnerInterceptor.setOverflow(paginationProperties.isOverflow()); paginationInnerInterceptor.setMaxLimit(paginationProperties.getMaxLimit()); return paginationInnerInterceptor; diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/base/BaseMapper.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/base/BaseMapper.java index f97ec954..854b9a69 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/base/BaseMapper.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/base/BaseMapper.java @@ -107,6 +107,6 @@ public interface BaseMapper extends com.baomidou.mybatisplus.core.mapper.Base * @return 实体类 Class 对象 */ default Class currentEntityClass() { - return (Class) ClassUtil.getTypeArgument(this.getClass(), 0); + return (Class)ClassUtil.getTypeArgument(this.getClass(), 0); } } diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/datapermission/DataPermissionHandlerImpl.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/datapermission/DataPermissionHandlerImpl.java index 2fd3eb19..38664efa 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/datapermission/DataPermissionHandlerImpl.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/datapermission/DataPermissionHandlerImpl.java @@ -59,14 +59,14 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { @Override public Expression getSqlSegment(Expression where, String mappedStatementId) { try { - Class clazz = - Class.forName(mappedStatementId.substring(0, mappedStatementId.lastIndexOf(StringConstants.DOT))); + Class clazz = Class.forName(mappedStatementId.substring(0, mappedStatementId + .lastIndexOf(StringConstants.DOT))); String methodName = mappedStatementId.substring(mappedStatementId.lastIndexOf(StringConstants.DOT) + 1); Method[] methodArr = clazz.getMethods(); for (Method method : methodArr) { DataPermission dataPermission = method.getAnnotation(DataPermission.class); - if (null != dataPermission - && (method.getName().equals(methodName) || (method.getName() + "_COUNT").equals(methodName))) { + if (null != dataPermission && (method.getName().equals(methodName) || (method.getName() + "_COUNT") + .equals(methodName))) { if (dataPermissionFilter.isFilter()) { return buildDataScopeFilter(dataPermission, where); } @@ -81,10 +81,8 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { /** * 构建数据范围过滤条件 * - * @param dataPermission - * 数据权限 - * @param where - * 当前查询条件 + * @param dataPermission 数据权限 + * @param where 当前查询条件 * @return 构建后查询条件 */ private Expression buildDataScopeFilter(DataPermission dataPermission, Expression where) { @@ -112,7 +110,8 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { equalsTo.setRightExpression(new LongValue(currentUser.getDeptId())); Function function = new Function(); function.setName("find_in_set"); - function.setParameters(new ExpressionList(new LongValue(currentUser.getDeptId()), new Column("ancestors"))); + function.setParameters(new ExpressionList(new LongValue(currentUser + .getDeptId()), new Column("ancestors"))); select.setWhere(new OrExpression(equalsTo, function)); subSelect.setSelectBody(select); // 构建父查询 @@ -158,10 +157,8 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { /** * 构建 Column * - * @param tableAlias - * 表别名 - * @param columnName - * 字段名称 + * @param tableAlias 表别名 + * @param columnName 字段名称 * @return 带表别名字段 */ private Column buildColumn(String tableAlias, String columnName) { diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryHelper.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryHelper.java index 8a4c1a4e..f6d51d55 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryHelper.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryHelper.java @@ -90,8 +90,8 @@ public class QueryHelper { // 解析查询条件 parse(queryAnnotation, field.getName(), fieldValue, queryWrapper); } catch (BadRequestException e) { - log.error("Build query occurred an validation error: {}. Query: {}, Field: {}.", e.getMessage(), query, - field, e); + log.error("Build query occurred an validation error: {}. Query: {}, Field: {}.", e + .getMessage(), query, field, e); throw e; } catch (Exception e) { log.error("Build query occurred an error: {}. Query: {}, Field: {}.", e.getMessage(), query, field, e); @@ -109,7 +109,9 @@ public class QueryHelper { * @param queryWrapper MyBatis Plus 查询条件封装对象 * @param 查询数据类型 */ - private static void parse(Query queryAnnotation, String fieldName, Object fieldValue, + private static void parse(Query queryAnnotation, + String fieldName, + Object fieldValue, QueryWrapper queryWrapper) { // 解析多属性模糊查询 // 如果设置了多属性模糊查询,分割属性进行条件拼接 @@ -137,7 +139,7 @@ public class QueryHelper { case GREATER_THAN_OR_EQUAL -> queryWrapper.ge(columnName, fieldValue); case LESS_THAN_OR_EQUAL -> queryWrapper.le(columnName, fieldValue); case BETWEEN -> { - List between = new ArrayList<>((List) fieldValue); + List between = new ArrayList<>((List)fieldValue); ValidationUtils.throwIf(between.size() != 2, "[{}] 必须是一个范围", fieldName); queryWrapper.between(columnName, between.get(0), between.get(1)); } @@ -146,11 +148,11 @@ public class QueryHelper { case RIGHT_LIKE -> queryWrapper.likeRight(columnName, fieldValue); case IN -> { ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName); - queryWrapper.in(columnName, (List) fieldValue); + queryWrapper.in(columnName, (List)fieldValue); } case NOT_IN -> { ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName); - queryWrapper.notIn(columnName, (List) fieldValue); + queryWrapper.notIn(columnName, (List)fieldValue); } case IS_NULL -> queryWrapper.isNull(columnName); case IS_NOT_NULL -> queryWrapper.isNotNull(columnName); diff --git a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryType.java b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryType.java index e6ec9f97..75a1e5be 100644 --- a/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryType.java +++ b/continew-starter-data/continew-starter-data-mybatis-plus/src/main/java/top/charles7c/continew/starter/data/mybatis/plus/query/QueryType.java @@ -84,8 +84,7 @@ public enum QueryType { /** * 非空查询,例如:WHERE `email` IS NOT NULL */ - IS_NOT_NULL(14, "IS NOT NULL"), - ; + IS_NOT_NULL(14, "IS NOT NULL"),; private final Integer value; private final String description; diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/autoconfigure/CrudAutoConfiguration.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/autoconfigure/CrudAutoConfiguration.java index 993d92b1..bf3fa42f 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/autoconfigure/CrudAutoConfiguration.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/autoconfigure/CrudAutoConfiguration.java @@ -50,10 +50,9 @@ public class CrudAutoConfiguration extends DelegatingWebMvcConfiguration { @Bean @Primary @Override - public RequestMappingHandlerMapping requestMappingHandlerMapping( - @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, - @Qualifier("mvcConversionService") FormattingConversionService conversionService, - @Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) { + public RequestMappingHandlerMapping requestMappingHandlerMapping(@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, + @Qualifier("mvcConversionService") FormattingConversionService conversionService, + @Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) { return super.requestMappingHandlerMapping(contentNegotiationManager, conversionService, resourceUrlProvider); } diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseDetailResp.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseDetailResp.java index 5f6d7263..300d57a5 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseDetailResp.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseDetailResp.java @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; import java.time.LocalDateTime; /** @@ -34,7 +35,7 @@ import java.time.LocalDateTime; @EqualsAndHashCode(callSuper = true) public class BaseDetailResp extends BaseResp { - + @Serial private static final long serialVersionUID = 1L; /** diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseServiceImpl.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseServiceImpl.java index c28e233b..669a8965 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseServiceImpl.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/base/BaseServiceImpl.java @@ -62,8 +62,7 @@ import java.util.List; * @author Charles7c * @since 1.0.0 */ -public abstract class BaseServiceImpl, T extends BaseDO, L, D, Q, C extends BaseReq> - implements BaseService { +public abstract class BaseServiceImpl, T extends BaseDO, L, D, Q, C extends BaseReq> implements BaseService { @Autowired protected M baseMapper; @@ -104,10 +103,10 @@ public abstract class BaseServiceImpl, T extends BaseDO, tree.setWeight(ReflectUtil.invoke(node, StrUtil.genGetter(treeField.weightKey()))); if (!isSimple) { List fieldList = ReflectUtils.getNonStaticFields(listClass); - fieldList.removeIf(f -> StrUtil.containsAnyIgnoreCase(f.getName(), treeField.value(), - treeField.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey())); - fieldList - .forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, StrUtil.genGetter(f.getName())))); + fieldList.removeIf(f -> StrUtil.containsAnyIgnoreCase(f.getName(), treeField.value(), treeField + .parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey())); + fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, StrUtil.genGetter(f + .getName())))); } }); } @@ -133,7 +132,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, this.sort(queryWrapper, sortQuery); List entityList = baseMapper.selectList(queryWrapper); if (entityClass == targetClass) { - return (List) entityList; + return (List)entityList; } return BeanUtil.copyToList(entityList, targetClass); } @@ -242,7 +241,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, * @return 当前实体类型 */ protected Class currentEntityClass() { - return (Class) this.typeArguments[1]; + return (Class)this.typeArguments[1]; } /** @@ -251,7 +250,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, * @return 当前列表信息类型 */ protected Class currentListClass() { - return (Class) this.typeArguments[2]; + return (Class)this.typeArguments[2]; } /** @@ -260,6 +259,6 @@ public abstract class BaseServiceImpl, T extends BaseDO, * @return 当前详情信息类型 */ protected Class currentDetailClass() { - return (Class) this.typeArguments[3]; + return (Class)this.typeArguments[3]; } } diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/CrudRequestMappingHandlerMapping.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/CrudRequestMappingHandlerMapping.java index 26ec032f..c8c5d797 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/CrudRequestMappingHandlerMapping.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/CrudRequestMappingHandlerMapping.java @@ -60,7 +60,9 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi return this.getMappingForMethodWrapper(method, handlerType, crudRequestMapping); } - private RequestMappingInfo getMappingForMethodWrapper(@NonNull Method method, @NonNull Class handlerType, CrudRequestMapping crudRequestMapping) { + private RequestMappingInfo getMappingForMethodWrapper(@NonNull Method method, + @NonNull Class handlerType, + CrudRequestMapping crudRequestMapping) { RequestMappingInfo info = this.createRequestMappingInfo(method); if (null != info) { RequestMappingInfo typeInfo = this.createRequestMappingInfo(handlerType); @@ -79,8 +81,9 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); - RequestCondition condition = (element instanceof Class clazz ? - getCustomTypeCondition(clazz) : getCustomMethodCondition((Method) element)); + RequestCondition condition = (element instanceof Class clazz + ? getCustomTypeCondition(clazz) + : getCustomMethodCondition((Method)element)); return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null); } } diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalErrorHandler.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalErrorHandler.java index 82a735dd..25450317 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalErrorHandler.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalErrorHandler.java @@ -51,18 +51,18 @@ public class GlobalErrorHandler extends BasicErrorController { @Resource private ObjectMapper objectMapper; - public GlobalErrorHandler(ErrorAttributes errorAttributes, ServerProperties serverProperties, + public GlobalErrorHandler(ErrorAttributes errorAttributes, + ServerProperties serverProperties, List errorViewResolvers) { super(errorAttributes, serverProperties.getError(), errorViewResolvers); } @Override public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { - Map errorAttributeMap = - super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.TEXT_HTML)); - String path = (String) errorAttributeMap.get("path"); + Map errorAttributeMap = super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.TEXT_HTML)); + String path = (String)errorAttributeMap.get("path"); HttpStatus status = super.getStatus(request); - R result = R.fail(status.value(), (String) errorAttributeMap.get("error")); + R result = R.fail(status.value(), (String)errorAttributeMap.get("error")); result.setData(path); try { response.setStatus(HttpStatus.OK.value()); @@ -77,11 +77,10 @@ public class GlobalErrorHandler extends BasicErrorController { @Override public ResponseEntity> error(HttpServletRequest request) { - Map errorAttributeMap = - super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.ALL)); - String path = (String) errorAttributeMap.get("path"); + Map errorAttributeMap = super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.ALL)); + String path = (String)errorAttributeMap.get("path"); HttpStatus status = super.getStatus(request); - R result = R.fail(status.value(), (String) errorAttributeMap.get("error")); + R result = R.fail(status.value(), (String)errorAttributeMap.get("error")); result.setData(path); log.error("请求地址 [{}],发生错误,错误信息:{}。", path, JSONUtil.toJsonStr(errorAttributeMap)); return new ResponseEntity<>(BeanUtil.beanToMap(result), HttpStatus.OK); diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalExceptionHandler.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalExceptionHandler.java index 671189a1..3a727e57 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalExceptionHandler.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/handler/GlobalExceptionHandler.java @@ -68,8 +68,8 @@ public class GlobalExceptionHandler { @ExceptionHandler(ConstraintViolationException.class) public R constraintViolationException(ConstraintViolationException e, HttpServletRequest request) { log.warn("请求地址 [{}],参数验证失败。", request.getRequestURI(), e); - String errorMsg = - CollUtil.join(e.getConstraintViolations(), StringConstants.CHINESE_COMMA, ConstraintViolation::getMessage); + String errorMsg = CollUtil.join(e + .getConstraintViolations(), StringConstants.CHINESE_COMMA, ConstraintViolation::getMessage); return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg); } @@ -79,8 +79,8 @@ public class GlobalExceptionHandler { @ExceptionHandler(BindException.class) public R handleBindException(BindException e, HttpServletRequest request) { log.warn("请求地址 [{}],参数验证失败。", request.getRequestURI(), e); - String errorMsg = CollUtil.join(e.getAllErrors(), StringConstants.CHINESE_COMMA, - DefaultMessageSourceResolvable::getDefaultMessage); + String errorMsg = CollUtil.join(e + .getAllErrors(), StringConstants.CHINESE_COMMA, DefaultMessageSourceResolvable::getDefaultMessage); return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg); } @@ -90,8 +90,8 @@ public class GlobalExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) public R handleMethodArgumentNotValidException(MethodArgumentNotValidException e, HttpServletRequest request) { log.warn("请求地址 [{}],参数验证失败。", request.getRequestURI(), e); - String errorMsg = ExceptionUtils - .exToNull(() -> Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage()); + String errorMsg = ExceptionUtils.exToNull(() -> Objects.requireNonNull(e.getBindingResult().getFieldError()) + .getDefaultMessage()); return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg); } @@ -100,7 +100,7 @@ public class GlobalExceptionHandler { */ @ExceptionHandler(MethodArgumentTypeMismatchException.class) public R handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, - HttpServletRequest request) { + HttpServletRequest request) { String errorMsg = StrUtil.format("参数名:[{}],期望参数类型:[{}]", e.getName(), e.getParameter().getParameterType()); log.warn("请求地址 [{}],参数转换失败,{}。", request.getRequestURI(), errorMsg, e); return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg); diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/model/query/SortQuery.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/model/query/SortQuery.java index 1dfc3e92..be2cd694 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/model/query/SortQuery.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/model/query/SortQuery.java @@ -62,8 +62,8 @@ public class SortQuery implements Serializable { // e.g "sort=createTime,desc&sort=name,asc" for (String s : sort) { List sortList = StrUtil.splitTrim(s, StringConstants.COMMA); - Sort.Order order = - new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList.get(0)); + Sort.Order order = new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList + .get(0)); orders.add(order); } } else { diff --git a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/util/TreeUtils.java b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/util/TreeUtils.java index 048f5605..be8fcea6 100644 --- a/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/util/TreeUtils.java +++ b/continew-starter-extension/continew-starter-extension-crud/src/main/java/top/charles7c/continew/starter/extension/crud/util/TreeUtils.java @@ -42,8 +42,9 @@ public class TreeUtils { /** * 默认字段配置对象(根据前端树结构灵活调整名称) */ - public static final TreeNodeConfig DEFAULT_CONFIG = - TreeNodeConfig.DEFAULT_CONFIG.setNameKey("title").setIdKey("key").setWeightKey("sort"); + public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("title") + .setIdKey("key") + .setWeightKey("sort"); /** * 树构建 @@ -72,7 +73,7 @@ public class TreeUtils { if (CollUtil.isEmpty(list)) { return new ArrayList<>(0); } - E parentId = (E) ReflectUtil.getFieldValue(list.get(0), treeNodeConfig.getParentIdKey()); + E parentId = (E)ReflectUtil.getFieldValue(list.get(0), treeNodeConfig.getParentIdKey()); return TreeUtil.build(list, parentId, treeNodeConfig, nodeParser); } @@ -84,8 +85,11 @@ public class TreeUtils { */ public static TreeNodeConfig genTreeNodeConfig(TreeField treeField) { CheckUtils.throwIfNull(treeField, "请添加并配置 @TreeField 树结构信息"); - return new TreeNodeConfig().setIdKey(treeField.value()).setParentIdKey(treeField.parentIdKey()) - .setNameKey(treeField.nameKey()).setWeightKey(treeField.weightKey()).setChildrenKey(treeField.childrenKey()) - .setDeep(treeField.deep() < 0 ? null : treeField.deep()); + return new TreeNodeConfig().setIdKey(treeField.value()) + .setParentIdKey(treeField.parentIdKey()) + .setNameKey(treeField.nameKey()) + .setWeightKey(treeField.weightKey()) + .setChildrenKey(treeField.childrenKey()) + .setDeep(treeField.deep() < 0 ? null : treeField.deep()); } } diff --git a/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/converter/ExcelBigNumberConverter.java b/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/converter/ExcelBigNumberConverter.java index dfb433c3..77c63e5b 100644 --- a/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/converter/ExcelBigNumberConverter.java +++ b/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/converter/ExcelBigNumberConverter.java @@ -55,7 +55,8 @@ public class ExcelBigNumberConverter implements Converter { * 转换为 Java 数据(读取 Excel) */ @Override - public Long convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, + public Long convertToJavaData(ReadCellData cellData, + ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return Convert.toLong(cellData.getData()); } @@ -64,7 +65,8 @@ public class ExcelBigNumberConverter implements Converter { * 转换为 Excel 数据(写入 Excel) */ @Override - public WriteCellData convertToExcelData(Long value, ExcelContentProperty contentProperty, + public WriteCellData convertToExcelData(Long value, + ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { if (null != value) { String str = Long.toString(value); diff --git a/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/util/ExcelUtils.java b/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/util/ExcelUtils.java index 2cda4976..5c7b89aa 100644 --- a/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/util/ExcelUtils.java +++ b/continew-starter-file/continew-starter-file-excel/src/main/java/top/charles7c/continew/starter/file/excel/util/ExcelUtils.java @@ -62,19 +62,25 @@ public class ExcelUtils { * @param clazz 导出数据类型 * @param response 响应对象 */ - public static void export(List list, String fileName, String sheetName, Class clazz, + public static void export(List list, + String fileName, + String sheetName, + Class clazz, HttpServletResponse response) { try { - fileName = - String.format("%s_%s.xlsx", fileName, DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN)); + fileName = String.format("%s_%s.xlsx", fileName, DateUtil + .format(new Date(), DatePattern.PURE_DATETIME_PATTERN)); fileName = URLUtil.encode(fileName); response.setHeader("Content-disposition", "attachment;filename=" + fileName); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); - EasyExcel.write(response.getOutputStream(), clazz).autoCloseStream(false) - // 自动适配宽度 - .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) - // 自动转换大数值 - .registerConverter(new ExcelBigNumberConverter()).sheet(sheetName).doWrite(list); + EasyExcel.write(response.getOutputStream(), clazz) + .autoCloseStream(false) + // 自动适配宽度 + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + // 自动转换大数值 + .registerConverter(new ExcelBigNumberConverter()) + .sheet(sheetName) + .doWrite(list); } catch (Exception e) { log.error("Export excel occurred an error: {}. fileName: {}.", e.getMessage(), fileName, e); throw new BaseException("导出 Excel 出现错误"); diff --git a/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/enums/Include.java b/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/enums/Include.java index 1460ca79..74d06952 100644 --- a/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/enums/Include.java +++ b/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/enums/Include.java @@ -84,8 +84,7 @@ public enum Include { /** * 响应参数(默认) */ - RESPONSE_PARAM, - ; + RESPONSE_PARAM,; private static final Set DEFAULT_INCLUDES; diff --git a/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/model/LogRecord.java b/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/model/LogRecord.java index d423fe12..bee81f4c 100644 --- a/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/model/LogRecord.java +++ b/continew-starter-log/continew-starter-log-common/src/main/java/top/charles7c/continew/starter/log/common/model/LogRecord.java @@ -16,7 +16,6 @@ package top.charles7c.continew.starter.log.common.model; - import lombok.Data; import top.charles7c.continew.starter.log.common.enums.Include; diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/autoconfigure/ConditionalOnEnabledLog.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/autoconfigure/ConditionalOnEnabledLog.java index af89eaea..af9e8d7b 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/autoconfigure/ConditionalOnEnabledLog.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/autoconfigure/ConditionalOnEnabledLog.java @@ -28,7 +28,8 @@ import java.lang.annotation.*; * @since 1.1.0 */ @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.METHOD}) @Documented @ConditionalOnProperty(prefix = PropertiesConstants.LOG, name = PropertiesConstants.ENABLED, havingValue = "true") -public @interface ConditionalOnEnabledLog {} \ No newline at end of file +public @interface ConditionalOnEnabledLog { +} \ No newline at end of file diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogFilter.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogFilter.java index b01e228b..8759fbea 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogFilter.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogFilter.java @@ -58,7 +58,8 @@ public class LogFilter extends OncePerRequestFilter implements Ordered { } @Override - protected void doFilterInternal(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, + protected void doFilterInternal(@NonNull HttpServletRequest request, + @NonNull HttpServletResponse response, @NonNull FilterChain filterChain) throws ServletException, IOException { if (!isRequestValid(request)) { filterChain.doFilter(request, response); @@ -103,8 +104,8 @@ public class LogFilter extends OncePerRequestFilter implements Ordered { */ private boolean isRequestWrapper(HttpServletRequest request) { Set includeSet = logProperties.getInclude(); - return !(request instanceof ContentCachingRequestWrapper) - && (includeSet.contains(Include.REQUEST_BODY) || includeSet.contains(Include.REQUEST_PARAM)); + return !(request instanceof ContentCachingRequestWrapper) && (includeSet + .contains(Include.REQUEST_BODY) || includeSet.contains(Include.REQUEST_PARAM)); } /** @@ -115,8 +116,8 @@ public class LogFilter extends OncePerRequestFilter implements Ordered { */ private boolean isResponseWrapper(HttpServletResponse response) { Set includeSet = logProperties.getInclude(); - return !(response instanceof ContentCachingResponseWrapper) - && (includeSet.contains(Include.RESPONSE_BODY) || includeSet.contains(Include.RESPONSE_PARAM)); + return !(response instanceof ContentCachingResponseWrapper) && (includeSet + .contains(Include.RESPONSE_BODY) || includeSet.contains(Include.RESPONSE_PARAM)); } /** @@ -126,8 +127,8 @@ public class LogFilter extends OncePerRequestFilter implements Ordered { * @throws IOException / */ private void updateResponse(HttpServletResponse response) throws IOException { - ContentCachingResponseWrapper responseWrapper = - WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class); + ContentCachingResponseWrapper responseWrapper = WebUtils + .getNativeResponse(response, ContentCachingResponseWrapper.class); Objects.requireNonNull(responseWrapper).copyBodyToResponse(); } } diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java index 623a8f76..c5b26def 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/LogInterceptor.java @@ -54,7 +54,8 @@ public class LogInterceptor implements HandlerInterceptor { private final TransmittableThreadLocal timestampTtl = new TransmittableThreadLocal<>(); @Override - public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, + public boolean preHandle(@NonNull HttpServletRequest request, + @NonNull HttpServletResponse response, @NonNull Object handler) { Clock timestamp = Clock.systemUTC(); if (this.isRequestRecord(handler, request)) { @@ -68,8 +69,10 @@ public class LogInterceptor implements HandlerInterceptor { } @Override - public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, - @NonNull Object handler, Exception e) { + public void afterCompletion(@NonNull HttpServletRequest request, + @NonNull HttpServletResponse response, + @NonNull Object handler, + Exception e) { LogRecord.Started startedLogRecord = timestampTtl.get(); if (null == startedLogRecord) { return; @@ -77,8 +80,9 @@ public class LogInterceptor implements HandlerInterceptor { timestampTtl.remove(); Set includeSet = logProperties.getInclude(); try { - LogRecord finishedLogRecord = startedLogRecord.finish(new RecordableServletHttpResponse(response, response.getStatus()), includeSet); - HandlerMethod handlerMethod = (HandlerMethod) handler; + LogRecord finishedLogRecord = startedLogRecord.finish(new RecordableServletHttpResponse(response, response + .getStatus()), includeSet); + HandlerMethod handlerMethod = (HandlerMethod)handler; // 记录日志描述 if (includeSet.contains(Include.DESCRIPTION)) { this.logDescription(finishedLogRecord, handlerMethod); @@ -89,7 +93,8 @@ public class LogInterceptor implements HandlerInterceptor { } if (Boolean.TRUE.equals(logProperties.getIsPrint())) { LogResponse logResponse = finishedLogRecord.getResponse(); - log.info("[{}] {} {} {}ms", request.getMethod(), request.getRequestURI(), logResponse.getStatus(), finishedLogRecord.getTimeTaken().toMillis()); + log.info("[{}] {} {} {}ms", request.getMethod(), request.getRequestURI(), logResponse + .getStatus(), finishedLogRecord.getTimeTaken().toMillis()); } logDao.add(finishedLogRecord); } catch (Exception ex) { @@ -131,7 +136,7 @@ public class LogInterceptor implements HandlerInterceptor { return; } Log classLog = handlerMethod.getBeanType().getDeclaredAnnotation(Log.class); - if(null != classLog && StrUtil.isNotBlank(classLog.module())) { + if (null != classLog && StrUtil.isNotBlank(classLog.module())) { logRecord.setModule(classLog.module()); return; } diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpRequest.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpRequest.java index 87dc6895..9b05bd17 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpRequest.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpRequest.java @@ -90,8 +90,8 @@ public final class RecordableServletHttpRequest implements RecordableHttpRequest public Map getParam() { String body = this.getBody(); return StrUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body) - ? JSONUtil.toBean(body, Map.class) - : Collections.unmodifiableMap(request.getParameterMap()); + ? JSONUtil.toBean(body, Map.class) + : Collections.unmodifiableMap(request.getParameterMap()); } private StringBuffer appendQueryString(String queryString) { diff --git a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpResponse.java b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpResponse.java index 3e960f73..1a427c07 100644 --- a/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpResponse.java +++ b/continew-starter-log/continew-starter-log-httptrace-pro/src/main/java/top/charles7c/continew/starter/log/httptracepro/handler/RecordableServletHttpResponse.java @@ -56,7 +56,8 @@ public final class RecordableServletHttpResponse implements RecordableHttpRespon @Override public String getBody() { - ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class); + ContentCachingResponseWrapper wrapper = WebUtils + .getNativeResponse(response, ContentCachingResponseWrapper.class); if (null != wrapper) { return StrUtil.utf8Str(wrapper.getContentAsByteArray()); } @@ -66,8 +67,6 @@ public final class RecordableServletHttpResponse implements RecordableHttpRespon @Override public Map getParam() { String body = this.getBody(); - return StrUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body) - ? JSONUtil.toBean(body, Map.class) - : null; + return StrUtil.isNotBlank(body) && JSONUtil.isTypeJSON(body) ? JSONUtil.toBean(body, Map.class) : null; } } diff --git a/continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/charles7c/continew/starter/messaging/mail/util/MailUtils.java b/continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/charles7c/continew/starter/messaging/mail/util/MailUtils.java index ccb765c6..0c5ce4b6 100644 --- a/continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/charles7c/continew/starter/messaging/mail/util/MailUtils.java +++ b/continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/charles7c/continew/starter/messaging/mail/util/MailUtils.java @@ -94,8 +94,10 @@ public class MailUtils { * @param files 附件列表 * @throws MessagingException / */ - public static void sendHtml(Collection tos, String subject, String content, File... files) - throws MessagingException { + public static void sendHtml(Collection tos, + String subject, + String content, + File... files) throws MessagingException { send(tos, null, null, subject, content, true, files); } @@ -109,7 +111,10 @@ public class MailUtils { * @param files 附件列表 * @throws MessagingException / */ - public static void sendHtml(Collection tos, Collection ccs, String subject, String content, + public static void sendHtml(Collection tos, + Collection ccs, + String subject, + String content, File... files) throws MessagingException { send(tos, ccs, null, subject, content, true, files); } @@ -125,8 +130,12 @@ public class MailUtils { * @param files 附件列表 * @throws MessagingException / */ - public static void sendHtml(Collection tos, Collection ccs, Collection bccs, String subject, - String content, File... files) throws MessagingException { + public static void sendHtml(Collection tos, + Collection ccs, + Collection bccs, + String subject, + String content, + File... files) throws MessagingException { send(tos, ccs, bccs, subject, content, true, files); } @@ -142,12 +151,17 @@ public class MailUtils { * @param files 附件列表 * @throws MessagingException / */ - public static void send(Collection tos, Collection ccs, Collection bccs, String subject, - String content, boolean isHtml, File... files) throws MessagingException { + public static void send(Collection tos, + Collection ccs, + Collection bccs, + String subject, + String content, + boolean isHtml, + File... files) throws MessagingException { Assert.isTrue(CollUtil.isEmpty(tos), "请至少指定一名收件人"); MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage(); - MimeMessageHelper messageHelper = - new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8.displayName()); + MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8 + .displayName()); // 设置基本信息 messageHelper.setFrom(SpringUtil.getProperty("spring.mail.username")); diff --git a/continew-starter-storage/continew-starter-storage-local/src/main/java/top/charles7c/continew/starter/storage/local/autoconfigure/LocalStorageAutoConfiguration.java b/continew-starter-storage/continew-starter-storage-local/src/main/java/top/charles7c/continew/starter/storage/local/autoconfigure/LocalStorageAutoConfiguration.java index 65f58e41..63467492 100644 --- a/continew-starter-storage/continew-starter-storage-local/src/main/java/top/charles7c/continew/starter/storage/local/autoconfigure/LocalStorageAutoConfiguration.java +++ b/continew-starter-storage/continew-starter-storage-local/src/main/java/top/charles7c/continew/starter/storage/local/autoconfigure/LocalStorageAutoConfiguration.java @@ -31,7 +31,6 @@ import top.charles7c.continew.starter.core.constant.StringConstants; import java.util.Map; - /** * 本地文件自动配置 * @@ -59,8 +58,10 @@ public class LocalStorageAutoConfiguration implements WebMvcConfigurer { throw new IllegalArgumentException(String.format("Path pattern [%s] location is null.", pathPattern)); } registry.addResourceHandler(StrUtil.appendIfMissing(pathPattern, StringConstants.PATH_PATTERN)) - .addResourceLocations(!location.startsWith("file:") ? String.format("file:%s", this.format(location)) : this.format(location)) - .setCachePeriod(0); + .addResourceLocations(!location.startsWith("file:") + ? String.format("file:%s", this.format(location)) + : this.format(location)) + .setCachePeriod(0); } } diff --git a/pom.xml b/pom.xml index 3f1c1a10..a619cf3f 100644 --- a/pom.xml +++ b/pom.xml @@ -110,8 +110,11 @@ + + .style/p3c-codestyle.xml + - code-style/license-header + .style/license-header