feat():接口文档相关集成
1、集成了knife4j spring-doc相关接口文档管理工具 2、移除了swagger2相关配置 3、增加了nacos配置文件相关配置detached
parent
9176f8e1ae
commit
5f0d5163f3
|
@ -52,6 +52,12 @@
|
||||||
<artifactId>cloud-common-security</artifactId>
|
<artifactId>cloud-common-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
cloud-common-swagger系统接口
|
cloud-common-api-doc系统接口
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -23,22 +23,10 @@
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger -->
|
<!-- knife4j-openapi3 -->
|
||||||
<!--<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
<version>2.5.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.muyu.common.api.doc.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SpringDocConfig {
|
||||||
|
|
||||||
|
@Value("${spring.application.name}")
|
||||||
|
private String applicationName;
|
||||||
|
|
||||||
|
private Info info(){
|
||||||
|
return new Info()
|
||||||
|
.title(String.format("%S-微服务接口文档", applicationName))
|
||||||
|
.description("微服务接口文档,根据此接口文档可以进行前后端功能对接/联调")
|
||||||
|
.version("v1.0.0");
|
||||||
|
}
|
||||||
|
private ExternalDocumentation externalDocumentation() {
|
||||||
|
return new ExternalDocumentation()
|
||||||
|
.description("服务总站")
|
||||||
|
.url("https://gitea.qinmian.online");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenAPI springShopOpenAPI() {
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(info())
|
||||||
|
.externalDocs(externalDocumentation());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.muyu.common.api.doc.config.SpringDocConfig
|
|
@ -142,12 +142,6 @@
|
||||||
<artifactId>javax.annotation-api</artifactId>
|
<artifactId>javax.annotation-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-annotations</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- lombok -->
|
<!-- lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.muyu.common.swagger.annotation;
|
|
||||||
|
|
||||||
import com.muyu.common.swagger.config.SwaggerAutoConfiguration;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Target({ElementType.TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
@Inherited
|
|
||||||
@Import({SwaggerAutoConfiguration.class})
|
|
||||||
public @interface EnableCustomSwagger2 {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
package com.muyu.common.swagger.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
|
||||||
import springfox.documentation.builders.PathSelectors;
|
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
||||||
import springfox.documentation.service.*;
|
|
||||||
import springfox.documentation.spi.DocumentationType;
|
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
|
||||||
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
|
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableSwagger2
|
|
||||||
@EnableConfigurationProperties(SwaggerProperties.class)
|
|
||||||
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
|
|
||||||
@Import({SwaggerBeanPostProcessor.class, SwaggerWebConfiguration.class})
|
|
||||||
public class SwaggerAutoConfiguration {
|
|
||||||
/**
|
|
||||||
* 默认的排除路径,排除Spring Boot默认的错误处理路径和端点
|
|
||||||
*/
|
|
||||||
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**");
|
|
||||||
|
|
||||||
private static final String BASE_PATH = "/**";
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Docket api (SwaggerProperties swaggerProperties) {
|
|
||||||
// base-path处理
|
|
||||||
if (swaggerProperties.getBasePath().isEmpty()) {
|
|
||||||
swaggerProperties.getBasePath().add(BASE_PATH);
|
|
||||||
}
|
|
||||||
// noinspection unchecked
|
|
||||||
List<Predicate<String>> basePath = new ArrayList<Predicate<String>>();
|
|
||||||
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
|
|
||||||
|
|
||||||
// exclude-path处理
|
|
||||||
if (swaggerProperties.getExcludePath().isEmpty()) {
|
|
||||||
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Predicate<String>> excludePath = new ArrayList<>();
|
|
||||||
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
|
|
||||||
|
|
||||||
ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).host(swaggerProperties.getHost())
|
|
||||||
.apiInfo(apiInfo(swaggerProperties)).select()
|
|
||||||
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()));
|
|
||||||
|
|
||||||
swaggerProperties.getBasePath().forEach(p -> builder.paths(PathSelectors.ant(p)));
|
|
||||||
swaggerProperties.getExcludePath().forEach(p -> builder.paths(PathSelectors.ant(p).negate()));
|
|
||||||
|
|
||||||
return builder.build().securitySchemes(securitySchemes()).securityContexts(securityContexts()).pathMapping("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
|
||||||
*/
|
|
||||||
private List<SecurityScheme> securitySchemes () {
|
|
||||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
|
||||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
|
||||||
return apiKeyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全上下文
|
|
||||||
*/
|
|
||||||
private List<SecurityContext> securityContexts () {
|
|
||||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
|
||||||
securityContexts.add(
|
|
||||||
SecurityContext.builder()
|
|
||||||
.securityReferences(defaultAuth())
|
|
||||||
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
|
||||||
.build());
|
|
||||||
return securityContexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认的全局鉴权策略
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<SecurityReference> defaultAuth () {
|
|
||||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
|
||||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
|
||||||
authorizationScopes[0] = authorizationScope;
|
|
||||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
|
||||||
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
|
||||||
return securityReferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApiInfo apiInfo (SwaggerProperties swaggerProperties) {
|
|
||||||
return new ApiInfoBuilder()
|
|
||||||
.title(swaggerProperties.getTitle())
|
|
||||||
.description(swaggerProperties.getDescription())
|
|
||||||
.license(swaggerProperties.getLicense())
|
|
||||||
.licenseUrl(swaggerProperties.getLicenseUrl())
|
|
||||||
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
|
|
||||||
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail()))
|
|
||||||
.version(swaggerProperties.getVersion())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.muyu.common.swagger.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
||||||
import org.springframework.util.ReflectionUtils;
|
|
||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
|
|
||||||
import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
|
|
||||||
import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* swagger 在 springboot 2.6.x 不兼容问题的处理
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
public class SwaggerBeanPostProcessor implements BeanPostProcessor {
|
|
||||||
@Override
|
|
||||||
public Object postProcessAfterInitialization (Object bean, String beanName) throws BeansException {
|
|
||||||
if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
|
|
||||||
customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
|
|
||||||
}
|
|
||||||
return bean;
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings (List<T> mappings) {
|
|
||||||
List<T> copy = mappings.stream().filter(mapping -> mapping.getPatternParser() == null)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
mappings.clear();
|
|
||||||
mappings.addAll(copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private List<RequestMappingInfoHandlerMapping> getHandlerMappings (Object bean) {
|
|
||||||
try {
|
|
||||||
Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
|
|
||||||
field.setAccessible(true);
|
|
||||||
return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,296 +0,0 @@
|
||||||
package com.muyu.common.swagger.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@ConfigurationProperties("swagger")
|
|
||||||
public class SwaggerProperties {
|
|
||||||
/**
|
|
||||||
* 是否开启swagger
|
|
||||||
*/
|
|
||||||
private Boolean enabled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* swagger会解析的包路径
|
|
||||||
**/
|
|
||||||
private String basePackage = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* swagger会解析的url规则
|
|
||||||
**/
|
|
||||||
private List<String> basePath = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在basePath基础上需要排除的url规则
|
|
||||||
**/
|
|
||||||
private List<String> excludePath = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标题
|
|
||||||
**/
|
|
||||||
private String title = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
**/
|
|
||||||
private String description = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本
|
|
||||||
**/
|
|
||||||
private String version = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 许可证
|
|
||||||
**/
|
|
||||||
private String license = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 许可证URL
|
|
||||||
**/
|
|
||||||
private String licenseUrl = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务条款URL
|
|
||||||
**/
|
|
||||||
private String termsOfServiceUrl = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* host信息
|
|
||||||
**/
|
|
||||||
private String host = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 联系人信息
|
|
||||||
*/
|
|
||||||
private Contact contact = new Contact();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局统一鉴权配置
|
|
||||||
**/
|
|
||||||
private Authorization authorization = new Authorization();
|
|
||||||
|
|
||||||
public Boolean getEnabled () {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled (Boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBasePackage () {
|
|
||||||
return basePackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBasePackage (String basePackage) {
|
|
||||||
this.basePackage = basePackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getBasePath () {
|
|
||||||
return basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBasePath (List<String> basePath) {
|
|
||||||
this.basePath = basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getExcludePath () {
|
|
||||||
return excludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExcludePath (List<String> excludePath) {
|
|
||||||
this.excludePath = excludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle () {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle (String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription () {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription (String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVersion () {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVersion (String version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLicense () {
|
|
||||||
return license;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLicense (String license) {
|
|
||||||
this.license = license;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLicenseUrl () {
|
|
||||||
return licenseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLicenseUrl (String licenseUrl) {
|
|
||||||
this.licenseUrl = licenseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTermsOfServiceUrl () {
|
|
||||||
return termsOfServiceUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTermsOfServiceUrl (String termsOfServiceUrl) {
|
|
||||||
this.termsOfServiceUrl = termsOfServiceUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHost () {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHost (String host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Contact getContact () {
|
|
||||||
return contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContact (Contact contact) {
|
|
||||||
this.contact = contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Authorization getAuthorization () {
|
|
||||||
return authorization;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorization (Authorization authorization) {
|
|
||||||
this.authorization = authorization;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Contact {
|
|
||||||
/**
|
|
||||||
* 联系人
|
|
||||||
**/
|
|
||||||
private String name = "";
|
|
||||||
/**
|
|
||||||
* 联系人url
|
|
||||||
**/
|
|
||||||
private String url = "";
|
|
||||||
/**
|
|
||||||
* 联系人email
|
|
||||||
**/
|
|
||||||
private String email = "";
|
|
||||||
|
|
||||||
public String getName () {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName (String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl () {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl (String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail () {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail (String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Authorization {
|
|
||||||
/**
|
|
||||||
* 鉴权策略ID,需要和SecurityReferences ID保持一致
|
|
||||||
*/
|
|
||||||
private String name = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要开启鉴权URL的正则
|
|
||||||
*/
|
|
||||||
private String authRegex = "^.*$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 鉴权作用域列表
|
|
||||||
*/
|
|
||||||
private List<AuthorizationScope> authorizationScopeList = new ArrayList<>();
|
|
||||||
|
|
||||||
private List<String> tokenUrlList = new ArrayList<>();
|
|
||||||
|
|
||||||
public String getName () {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName (String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthRegex () {
|
|
||||||
return authRegex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthRegex (String authRegex) {
|
|
||||||
this.authRegex = authRegex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AuthorizationScope> getAuthorizationScopeList () {
|
|
||||||
return authorizationScopeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorizationScopeList (List<AuthorizationScope> authorizationScopeList) {
|
|
||||||
this.authorizationScopeList = authorizationScopeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getTokenUrlList () {
|
|
||||||
return tokenUrlList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTokenUrlList (List<String> tokenUrlList) {
|
|
||||||
this.tokenUrlList = tokenUrlList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AuthorizationScope {
|
|
||||||
/**
|
|
||||||
* 作用域名称
|
|
||||||
*/
|
|
||||||
private String scope = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 作用域描述
|
|
||||||
*/
|
|
||||||
private String description = "";
|
|
||||||
|
|
||||||
public String getScope () {
|
|
||||||
return scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScope (String scope) {
|
|
||||||
this.scope = scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription () {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription (String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.muyu.common.swagger.config;
|
|
||||||
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* swagger 资源映射路径
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
public class SwaggerWebConfiguration implements WebMvcConfigurer {
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers (ResourceHandlerRegistry registry) {
|
|
||||||
/** swagger-ui 地址 */
|
|
||||||
registry.addResourceHandler("/swagger-ui/**")
|
|
||||||
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
# com.muyu.common.swagger.config.SwaggerAutoConfiguration
|
|
||||||
# com.muyu.common.swagger.config.SwaggerWebConfiguration
|
|
||||||
# com.muyu.common.swagger.config.SwaggerBeanPostProcessor
|
|
|
@ -13,7 +13,7 @@
|
||||||
<module>cloud-common-core</module>
|
<module>cloud-common-core</module>
|
||||||
<module>cloud-common-redis</module>
|
<module>cloud-common-redis</module>
|
||||||
<module>cloud-common-seata</module>
|
<module>cloud-common-seata</module>
|
||||||
<module>cloud-common-swagger</module>
|
<module>cloud-common-api-doc</module>
|
||||||
<module>cloud-common-security</module>
|
<module>cloud-common-security</module>
|
||||||
<module>cloud-common-datascope</module>
|
<module>cloud-common-datascope</module>
|
||||||
<module>cloud-common-datasource</module>
|
<module>cloud-common-datasource</module>
|
||||||
|
|
|
@ -76,16 +76,10 @@
|
||||||
<artifactId>cloud-common-redis</artifactId>
|
<artifactId>cloud-common-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
|
||||||
<version>${swagger.fox.version}</version>
|
<version>4.5.0</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
package com.muyu.gateway.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cloud.gateway.config.GatewayProperties;
|
|
||||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
|
||||||
import org.springframework.cloud.gateway.support.NameUtils;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
|
||||||
import springfox.documentation.swagger.web.SwaggerResource;
|
|
||||||
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 聚合系统接口
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigurer {
|
|
||||||
/**
|
|
||||||
* Swagger2默认的url后缀
|
|
||||||
*/
|
|
||||||
public static final String SWAGGER2URL = "/v2/api-docs";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关路由
|
|
||||||
*/
|
|
||||||
@Lazy
|
|
||||||
@Autowired
|
|
||||||
private RouteLocator routeLocator;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GatewayProperties gatewayProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 聚合其他服务接口
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SwaggerResource> get () {
|
|
||||||
List<SwaggerResource> resourceList = new ArrayList<>();
|
|
||||||
List<String> routes = new ArrayList<>();
|
|
||||||
// 获取网关中配置的route
|
|
||||||
routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
|
|
||||||
gatewayProperties.getRoutes().stream()
|
|
||||||
.filter(routeDefinition -> routes
|
|
||||||
.contains(routeDefinition.getId()))
|
|
||||||
.forEach(routeDefinition -> routeDefinition.getPredicates().stream()
|
|
||||||
.filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
|
|
||||||
.filter(predicateDefinition -> !"cloud-auth".equalsIgnoreCase(routeDefinition.getId()))
|
|
||||||
.forEach(predicateDefinition -> resourceList
|
|
||||||
.add(swaggerResource(routeDefinition.getId(), predicateDefinition.getArgs()
|
|
||||||
.get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", SWAGGER2URL)))));
|
|
||||||
return resourceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SwaggerResource swaggerResource (String name, String location) {
|
|
||||||
SwaggerResource swaggerResource = new SwaggerResource();
|
|
||||||
swaggerResource.setName(name);
|
|
||||||
swaggerResource.setLocation(location);
|
|
||||||
swaggerResource.setSwaggerVersion("2.0");
|
|
||||||
return swaggerResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers (ResourceHandlerRegistry registry) {
|
|
||||||
/** swagger-ui 地址 */
|
|
||||||
registry.addResourceHandler("/swagger-ui/**")
|
|
||||||
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.muyu.gateway.filter.log;
|
package com.muyu.gateway.filter;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import com.alibaba.nacos.common.utils.StringUtils;
|
import com.alibaba.nacos.common.utils.StringUtils;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
import com.muyu.gateway.model.AccessLog;
|
||||||
import com.muyu.gateway.utils.WebFrameworkUtils;
|
import com.muyu.gateway.utils.WebFrameworkUtils;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
|
@ -1,46 +0,0 @@
|
||||||
package com.muyu.gateway.handler;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
import springfox.documentation.swagger.web.*;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/swagger-resources")
|
|
||||||
public class SwaggerHandler {
|
|
||||||
private final SwaggerResourcesProvider swaggerResources;
|
|
||||||
@Autowired(required = false)
|
|
||||||
private SecurityConfiguration securityConfiguration;
|
|
||||||
@Autowired(required = false)
|
|
||||||
private UiConfiguration uiConfiguration;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public SwaggerHandler (SwaggerResourcesProvider swaggerResources) {
|
|
||||||
this.swaggerResources = swaggerResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/configuration/security")
|
|
||||||
public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration () {
|
|
||||||
return Mono.just(new ResponseEntity<>(
|
|
||||||
Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()),
|
|
||||||
HttpStatus.OK));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/configuration/ui")
|
|
||||||
public Mono<ResponseEntity<UiConfiguration>> uiConfiguration () {
|
|
||||||
return Mono.just(new ResponseEntity<>(
|
|
||||||
Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@GetMapping("")
|
|
||||||
public Mono<ResponseEntity> swaggerResources () {
|
|
||||||
return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.muyu.gateway.filter.log;
|
package com.muyu.gateway.model;
|
||||||
|
|
||||||
import com.alibaba.cloud.commons.io.StringBuilderWriter;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -9,7 +8,6 @@ import lombok.NoArgsConstructor;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import org.springframework.cloud.gateway.route.Route;
|
import org.springframework.cloud.gateway.route.Route;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.HttpStatusCode;
|
import org.springframework.http.HttpStatusCode;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
|
@ -61,3 +61,15 @@ spring:
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
data-type: json
|
data-type: json
|
||||||
rule-type: gw-flow
|
rule-type: gw-flow
|
||||||
|
knife4j:
|
||||||
|
gateway:
|
||||||
|
enabled: true
|
||||||
|
# 指定服务发现的模式聚合微服务文档,并且是默认`default`分组
|
||||||
|
strategy: discover
|
||||||
|
discover:
|
||||||
|
enabled: true
|
||||||
|
# 指定版本号(Swagger2|OpenAPI3)
|
||||||
|
version : openapi3
|
||||||
|
# 需要排除的微服务(eg:网关服务)
|
||||||
|
excluded-services:
|
||||||
|
- cloud-monitor
|
||||||
|
|
|
@ -48,22 +48,16 @@
|
||||||
<version>${minio.version}</version>
|
<version>${minio.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
<!-- MuYu Common System-->
|
<!-- MuYu Common System-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-system</artifactId>
|
<artifactId>cloud-common-system</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -41,13 +41,6 @@
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger UI -->
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<!-- Apache Velocity -->
|
<!-- Apache Velocity -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
@ -66,15 +59,10 @@
|
||||||
<artifactId>cloud-common-log</artifactId>
|
<artifactId>cloud-common-log</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
<!-- 接口模块 -->
|
||||||
<!--<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.gen;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
//import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@ -12,7 +11,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
//@EnableCustomSwagger2
|
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class CloudGenApplication {
|
public class CloudGenApplication {
|
||||||
|
|
|
@ -41,13 +41,6 @@
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger UI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Quartz -->
|
<!-- Quartz -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.quartz-scheduler</groupId>
|
<groupId>org.quartz-scheduler</groupId>
|
||||||
|
@ -72,15 +65,10 @@
|
||||||
<artifactId>cloud-common-log</artifactId>
|
<artifactId>cloud-common-log</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
<!-- 接口模块 -->
|
||||||
<!--<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.job;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
//import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@ -12,7 +11,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
//@EnableCustomSwagger2
|
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class CloudJobApplication {
|
public class CloudJobApplication {
|
||||||
|
|
|
@ -41,13 +41,6 @@
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger UI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
<!-- Mysql Connector -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
|
@ -72,21 +65,10 @@
|
||||||
<artifactId>cloud-common-log</artifactId>
|
<artifactId>cloud-common-log</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
<!-- 接口模块 -->
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
|
||||||
<version>2.6.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.system;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
//import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,13 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.system.domain.SysConfig;
|
import com.muyu.system.domain.SysConfig;
|
||||||
import com.muyu.system.service.SysConfigService;
|
import com.muyu.system.service.SysConfigService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -25,6 +27,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/config")
|
@RequestMapping("/config")
|
||||||
|
@Tag(name = "SysConfigController", description = "系统参数配置")
|
||||||
public class SysConfigController extends BaseController {
|
public class SysConfigController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -35,6 +38,7 @@ public class SysConfigController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:list")
|
@RequiresPermissions("system:config:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "查询集合", description = "更新水果信息")
|
||||||
public Result<TableDataInfo<SysConfig>> list (SysConfig config) {
|
public Result<TableDataInfo<SysConfig>> list (SysConfig config) {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysConfig> list = configService.pageQuery(config);
|
List<SysConfig> list = configService.pageQuery(config);
|
||||||
|
|
|
@ -8,10 +8,6 @@ nacos:
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: muyu-cloud
|
namespace: muyu-cloud
|
||||||
# swagger-ui custom path
|
|
||||||
springdoc:
|
|
||||||
swagger-ui:
|
|
||||||
path: /swagger-ui.html
|
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
@ -53,4 +49,4 @@ spring:
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.system.mapper: DEBUG
|
|
@ -303,7 +303,7 @@ INSERT INTO `sys_menu` VALUES (112, 'Nacos控制台', 2, 4, 'http://localhost:88
|
||||||
INSERT INTO `sys_menu` VALUES (113, 'Admin控制台', 2, 5, 'http://localhost:9100/login', '', '', 0, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', '2024-05-23 15:08:18', '', NULL, '服务监控菜单');
|
INSERT INTO `sys_menu` VALUES (113, 'Admin控制台', 2, 5, 'http://localhost:9100/login', '', '', 0, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', '2024-05-23 15:08:18', '', NULL, '服务监控菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (114, '表单构建', 3, 1, 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', '2024-05-23 15:08:18', '', NULL, '表单构建菜单');
|
INSERT INTO `sys_menu` VALUES (114, '表单构建', 3, 1, 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', '2024-05-23 15:08:18', '', NULL, '表单构建菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (115, '代码生成', 3, 2, 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', '2024-05-23 15:08:18', '', NULL, '代码生成菜单');
|
INSERT INTO `sys_menu` VALUES (115, '代码生成', 3, 2, 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', '2024-05-23 15:08:18', '', NULL, '代码生成菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (116, '系统接口', 3, 3, 'http://localhost:8080/swagger-ui/index.html', '', '', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', '2024-05-23 15:08:18', '', NULL, '系统接口菜单');
|
INSERT INTO `sys_menu` VALUES (116, '系统接口', 3, 3, 'http://localhost:8080/doc.html', '', '', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', '2024-05-23 15:08:18', '', NULL, '系统接口菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (500, '操作日志', 108, 1, 'operlog', 'system/operlog/index', '', 1, 0, 'C', '0', '0', 'system:operlog:list', 'form', 'admin', '2024-05-23 15:08:18', '', NULL, '操作日志菜单');
|
INSERT INTO `sys_menu` VALUES (500, '操作日志', 108, 1, 'operlog', 'system/operlog/index', '', 1, 0, 'C', '0', '0', 'system:operlog:list', 'form', 'admin', '2024-05-23 15:08:18', '', NULL, '操作日志菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (501, '登录日志', 108, 2, 'logininfor', 'system/logininfor/index', '', 1, 0, 'C', '0', '0', 'system:logininfor:list', 'logininfor', 'admin', '2024-05-23 15:08:18', '', NULL, '登录日志菜单');
|
INSERT INTO `sys_menu` VALUES (501, '登录日志', 108, 2, 'logininfor', 'system/logininfor/index', '', 1, 0, 'C', '0', '0', 'system:logininfor:list', 'logininfor', 'admin', '2024-05-23 15:08:18', '', NULL, '登录日志菜单');
|
||||||
INSERT INTO `sys_menu` VALUES (1000, '用户查询', 100, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin', '2024-05-23 15:08:18', '', NULL, '');
|
INSERT INTO `sys_menu` VALUES (1000, '用户查询', 100, 1, '', '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin', '2024-05-23 15:08:18', '', NULL, '');
|
||||||
|
|
Binary file not shown.
10
pom.xml
10
pom.xml
|
@ -40,6 +40,7 @@
|
||||||
<jakarta.servlet.version>6.1.0-M2</jakarta.servlet.version>
|
<jakarta.servlet.version>6.1.0-M2</jakarta.servlet.version>
|
||||||
<javax.annotation.version>1.3.2</javax.annotation.version>
|
<javax.annotation.version>1.3.2</javax.annotation.version>
|
||||||
<hutool.version>5.8.27</hutool.version>
|
<hutool.version>5.8.27</hutool.version>
|
||||||
|
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
|
@ -86,6 +87,13 @@
|
||||||
<version>${apm-logback.version}</version>
|
<version>${apm-logback.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- knife4j-openapi3 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j-openapi3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Java jakarta Servlet -->
|
<!-- Java jakarta Servlet -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.servlet</groupId>
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
@ -184,7 +192,7 @@
|
||||||
<!-- 接口模块 -->
|
<!-- 接口模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-swagger</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue