Skip to content

Commit

Permalink
chore: 优化代码格式
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 11, 2024
1 parent 1fc80cd commit 46773df
Show file tree
Hide file tree
Showing 40 changed files with 99 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.configuration.SpringDocConfiguration;
import org.springdoc.core.customizers.*;
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.providers.JavadocProvider;
import org.springdoc.core.service.OpenAPIService;
Expand All @@ -48,7 +50,9 @@
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.continew.starter.core.util.GeneralPropertySourceFactory;

import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.springdoc.core.customizers.ParameterCustomizer;
import org.springdoc.core.customizers.PropertyCustomizer;
import org.springframework.core.MethodParameter;
import top.continew.starter.apidoc.util.DocUtils;
import top.continew.starter.core.enums.BaseEnum;

import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
import top.continew.starter.apidoc.util.DocUtils;
import top.continew.starter.core.enums.BaseEnum;

/**
* 自定义 BaseEnum 枚举参数处理器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,25 @@ public OpenApiHandler(Optional<OpenAPI> openAPI,
super(openAPI, securityParser, springDocConfigProperties, propertyResolverUtils, openApiBuilderCustomizers, serverBaseUrlCustomizers, javadocProvider);
if (openAPI.isPresent()) {
this.openAPI = openAPI.get();
if (this.openAPI.getComponents() == null)
if (this.openAPI.getComponents() == null) {
this.openAPI.setComponents(new Components());
if (this.openAPI.getPaths() == null)
}
if (this.openAPI.getPaths() == null) {
this.openAPI.setPaths(new Paths());
if (!CollectionUtils.isEmpty(this.openAPI.getServers()))
}
if (!CollectionUtils.isEmpty(this.openAPI.getServers())) {
this.isServersPresent = true;
}
}
this.propertyResolverUtils = propertyResolverUtils;
this.securityParser = securityParser;
this.springDocConfigProperties = springDocConfigProperties;
this.openApiBuilderCustomisers = openApiBuilderCustomizers;
this.serverBaseUrlCustomizers = serverBaseUrlCustomizers;
this.javadocProvider = javadocProvider;
if (springDocConfigProperties.isUseFqn())
if (springDocConfigProperties.isUseFqn()) {
TypeNameResolver.std.setUseFqn(true);
}
}

@Override
Expand All @@ -172,10 +176,11 @@ public Operation buildTags(HandlerMethod handlerMethod, Operation operation, Ope
buildTagsFromMethod(handlerMethod.getMethod(), tags, tagsStr, locale);
buildTagsFromClass(handlerMethod.getBeanType(), tags, tagsStr, locale);

if (!CollectionUtils.isEmpty(tagsStr))
if (!CollectionUtils.isEmpty(tagsStr)) {
tagsStr = tagsStr.stream()
.map(str -> propertyResolverUtils.resolve(str, locale))
.collect(Collectors.toSet());
}

if (springdocTags.containsKey(handlerMethod)) {
Tag tag = springdocTags.get(handlerMethod);
Expand All @@ -186,9 +191,9 @@ public Operation buildTags(HandlerMethod handlerMethod, Operation operation, Ope
}

if (!CollectionUtils.isEmpty(tagsStr)) {
if (CollectionUtils.isEmpty(operation.getTags()))
if (CollectionUtils.isEmpty(operation.getTags())) {
operation.setTags(new ArrayList<>(tagsStr));
else {
} else {
Set<String> operationTagsSet = new HashSet<>(operation.getTags());
operationTagsSet.addAll(tagsStr);
operation.getTags().clear();
Expand Down Expand Up @@ -223,19 +228,21 @@ public Operation buildTags(HandlerMethod handlerMethod, Operation operation, Ope
if (!CollectionUtils.isEmpty(tags)) {
// Existing tags
List<Tag> openApiTags = openAPI.getTags();
if (!CollectionUtils.isEmpty(openApiTags))
if (!CollectionUtils.isEmpty(openApiTags)) {
tags.addAll(openApiTags);
}
openAPI.setTags(new ArrayList<>(tags));
}

// Handle SecurityRequirement at operation level
io.swagger.v3.oas.annotations.security.SecurityRequirement[] securityRequirements = securityParser
.getSecurityRequirements(handlerMethod);
if (securityRequirements != null) {
if (securityRequirements.length == 0)
if (securityRequirements.length == 0) {
operation.setSecurity(Collections.emptyList());
else
} else {
securityParser.buildSecurityRequirement(securityRequirements, operation);
}
}

return operation;
Expand Down Expand Up @@ -263,8 +270,9 @@ private void addTags(List<io.swagger.v3.oas.annotations.tags.Tag> sourceTags, Se
tagsSet.forEach(tag -> {
tag.name(propertyResolverUtils.resolve(tag.getName(), locale));
tag.description(propertyResolverUtils.resolve(tag.getDescription(), locale));
if (tags.stream().noneMatch(t -> t.getName().equals(tag.getName())))
if (tags.stream().noneMatch(t -> t.getName().equals(tag.getName()))) {
tags.add(tag);
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

package top.continew.starter.apidoc.util;

import org.springframework.web.bind.annotation.RestController;
import top.continew.starter.core.enums.BaseEnum;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.web.bind.annotation.RestController;
import top.continew.starter.core.enums.BaseEnum;

/**
* 接口文档工具类
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.continew.starter.auth.satoken.autoconfigure.dao.SaTokenDaoConfiguration;
Expand Down Expand Up @@ -78,8 +81,7 @@ public SaInterceptor saInterceptor() {
@Configuration
@Import({SaTokenDaoConfiguration.Default.class, SaTokenDaoConfiguration.Redis.class,
SaTokenDaoConfiguration.Custom.class})
protected static class SaTokenDaoAutoConfiguration {
}
protected static class SaTokenDaoAutoConfiguration {}

/**
* 整合 JWT(简单模式)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package top.continew.starter.captcha.graphic.core;

import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ReflectUtil;
import com.wf.captcha.base.Captcha;
import top.continew.starter.captcha.graphic.autoconfigure.GraphicCaptchaProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
@ComponentScan("cn.hutool.extra.spring")
@Import(cn.hutool.extra.spring.SpringUtil.class)
@EnableConfigurationProperties(ProjectProperties.class)
public class ProjectAutoConfiguration {
}
public class ProjectAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public class StringConstants {
public static final String DOT = StrPool.DOT;

/**
* 字符串常量:双点 {@code ".."} <br>
* 用途:作为指向上级文件夹的路径,如:{@code "../path"}
* 字符串常量:双点 {@code ".."} <br> 用途:作为指向上级文件夹的路径,如:{@code "../path"}
*/
public static final String DOUBLE_DOT = StrPool.DOUBLE_DOT;

Expand All @@ -136,8 +135,7 @@ public class StringConstants {
public static final String BACKSLASH = StrPool.BACKSLASH;

/**
* 字符串常量:回车符 {@code "\r"} <br>
* 解释:该字符常用于表示 Linux 系统和 MacOS 系统下的文本换行
* 字符串常量:回车符 {@code "\r"} <br> 解释:该字符常用于表示 Linux 系统和 MacOS 系统下的文本换行
*/
public static final String CR = StrPool.CR;

Expand All @@ -147,8 +145,7 @@ public class StringConstants {
public static final String LF = StrPool.LF;

/**
* 字符串常量:Windows 换行 {@code "\r\n"} <br>
* 解释:该字符串常用于表示 Windows 系统下的文本换行
* 字符串常量:Windows 换行 {@code "\r\n"} <br> 解释:该字符串常用于表示 Windows 系统下的文本换行
*/
public static final String CRLF = StrPool.CRLF;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
* @author hellokaton
* @since 1.2.0
*/
public interface IService<T> extends com.mybatisflex.core.service.IService<T> {
}
public interface IService<T> extends com.mybatisflex.core.service.IService<T> {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import net.sf.jsqlparser.expression.operators.relational.InExpression;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.select.*;
import net.sf.jsqlparser.statement.select.ParenthesedSelect;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.SelectItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.continew.starter.core.constant.StringConstants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
* @author Charles7c
* @since 1.2.0
*/
public interface IService<T> extends com.baomidou.mybatisplus.extension.service.IService<T> {
}
public interface IService<T> extends com.baomidou.mybatisplus.extension.service.IService<T> {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package top.continew.starter.data.mp.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Sort;
import top.continew.starter.core.exception.BadRequestException;
import top.continew.starter.core.util.ReflectUtils;
Expand All @@ -33,7 +33,10 @@
import top.continew.starter.data.core.util.SqlInjectionUtils;

import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({CrudRestControllerAutoConfiguration.class})
public @interface EnableCrudRestController {
}
public @interface EnableCrudRestController {}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ interface Crud extends ValidateGroup {
/**
* 分组校验-创建
*/
interface Add extends Crud {
}
interface Add extends Crud {}

/**
* 分组校验-修改
*/
interface Update extends Crud {
}
interface Update extends Crud {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import cn.hutool.core.lang.tree.Tree;
import jakarta.servlet.http.HttpServletResponse;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.model.resp.PageResp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
import top.continew.starter.core.util.ReflectUtils;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.data.mf.base.BaseMapper;
import top.continew.starter.data.mf.util.QueryWrapperHelper;
import top.continew.starter.data.mf.service.impl.ServiceImpl;
import top.continew.starter.data.mf.util.QueryWrapperHelper;
import top.continew.starter.extension.crud.annotation.TreeField;
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
import top.continew.starter.extension.crud.service.BaseService;
import top.continew.starter.extension.crud.util.TreeUtils;
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
import top.continew.starter.file.excel.util.ExcelUtils;

import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.req.BaseReq;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.util.ValidateGroup;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
import top.continew.starter.extension.crud.service.BaseService;
import top.continew.starter.extension.crud.util.ValidateGroup;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
/**
* Easy Excel 枚举接口转换器
*
* @see BaseEnum
* @author Charles7c
* @see BaseEnum
* @since 1.2.0
*/
public class ExcelBaseEnumConverter implements Converter<BaseEnum<Integer>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import top.continew.starter.log.core.enums.Include;

import java.util.*;
import java.util.Map;
import java.util.Set;

/**
* 响应信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Collections;
import java.util.Map;

/**
* 可记录的 HTTP 请求信息适配器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import top.continew.starter.log.core.model.RecordableHttpResponse;
import top.continew.starter.web.util.ServletUtils;

import java.util.*;
import java.util.Map;

/**
* 可记录的 HTTP 响应信息适配器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import top.continew.starter.core.constant.PropertiesConstants;
import top.continew.starter.core.constant.StringConstants;

import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void handleTransportError(WebSocketSession session, Throwable exception)

/**
* 获取客户端 ID
*
*
* @param session 会话
* @return 客户端 ID
*/
Expand Down
Loading

0 comments on commit 46773df

Please sign in to comment.