| @@ -21,6 +21,7 @@ | |||||
| <module>suimangSchedule</module> | <module>suimangSchedule</module> | ||||
| <module>suimangMQConsumer</module> | <module>suimangMQConsumer</module> | ||||
| <module>open-api</module> | <module>open-api</module> | ||||
| <module>suimang-swagger</module> | |||||
| </modules> | </modules> | ||||
| <parent> | <parent> | ||||
| @@ -186,21 +187,21 @@ | |||||
| </dependency> | </dependency> | ||||
| <!-- Swagger --> | <!-- Swagger --> | ||||
| <dependency> | |||||
| <groupId>io.springfox</groupId> | |||||
| <artifactId>springfox-swagger2</artifactId> | |||||
| <version>2.8.0</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>io.springfox</groupId> | |||||
| <artifactId>springfox-swagger-ui</artifactId> | |||||
| <version>2.8.0</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>io.springfox</groupId> | |||||
| <artifactId>springfox-spring-web</artifactId> | |||||
| <version>2.8.0</version> | |||||
| </dependency> | |||||
| <!-- <dependency>--> | |||||
| <!-- <groupId>io.springfox</groupId>--> | |||||
| <!-- <artifactId>springfox-swagger2</artifactId>--> | |||||
| <!-- <version>2.8.0</version>--> | |||||
| <!-- </dependency>--> | |||||
| <!-- <dependency>--> | |||||
| <!-- <groupId>io.springfox</groupId>--> | |||||
| <!-- <artifactId>springfox-swagger-ui</artifactId>--> | |||||
| <!-- <version>2.8.0</version>--> | |||||
| <!-- </dependency>--> | |||||
| <!-- <dependency>--> | |||||
| <!-- <groupId>io.springfox</groupId>--> | |||||
| <!-- <artifactId>springfox-spring-web</artifactId>--> | |||||
| <!-- <version>2.8.0</version>--> | |||||
| <!-- </dependency>--> | |||||
| <dependency> | <dependency> | ||||
| <groupId>com.fasterxml.jackson.core</groupId> | <groupId>com.fasterxml.jackson.core</groupId> | ||||
| <artifactId>jackson-core</artifactId> | <artifactId>jackson-core</artifactId> | ||||
| @@ -0,0 +1,28 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <parent> | |||||
| <artifactId>suimang</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <artifactId>suimang-swagger</artifactId> | |||||
| <dependencies> | |||||
| <!--swagger 相关依赖--> | |||||
| <dependency> | |||||
| <groupId>io.springfox</groupId> | |||||
| <artifactId>springfox-swagger2</artifactId> | |||||
| <version>2.9.2</version> | |||||
| </dependency> | |||||
| <!--doc.html模式--> | |||||
| <dependency> | |||||
| <groupId>com.github.xiaoymin</groupId> | |||||
| <artifactId>swagger-bootstrap-ui</artifactId> | |||||
| <version>1.9.3</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| </project> | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.ElementType; | |||||
| import java.lang.annotation.Retention; | |||||
| import java.lang.annotation.RetentionPolicy; | |||||
| import java.lang.annotation.Target; | |||||
| @Target(ElementType.METHOD) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| public @interface ApiVersion { | |||||
| /** | |||||
| * 接口版本号(对应swagger中的group) | |||||
| * | |||||
| * @return String[] | |||||
| */ | |||||
| String[] group(); | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.annotation; | |||||
| import com.iformall.config.SwaggerConfiguration; | |||||
| import org.springframework.context.annotation.Import; | |||||
| import java.lang.annotation.*; | |||||
| @Target({ElementType.TYPE}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| @Inherited | |||||
| @Import({SwaggerConfiguration.class}) | |||||
| public @interface BaseEnableSwagger { | |||||
| } | |||||
| @@ -0,0 +1,94 @@ | |||||
| package com.iformall.config; | |||||
| import com.google.common.base.Predicate; | |||||
| import com.google.common.base.Predicates; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||||
| 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 springfox.documentation.builders.ApiInfoBuilder; | |||||
| import springfox.documentation.builders.PathSelectors; | |||||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| import springfox.documentation.service.ApiInfo; | |||||
| import springfox.documentation.service.Contact; | |||||
| import springfox.documentation.spi.DocumentationType; | |||||
| import springfox.documentation.spring.web.plugins.Docket; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import javax.servlet.ServletContext; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableSwagger2 | |||||
| @EnableAutoConfiguration | |||||
| @EnableConfigurationProperties(SwaggerProperties.class) | |||||
| @ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) | |||||
| public class SwaggerConfiguration { | |||||
| private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error"); | |||||
| private static final String BASE_PATH = "/**"; | |||||
| @Autowired | |||||
| private SwaggerProperties swaggerProperties; | |||||
| /** | |||||
| * 1、分组 | |||||
| * 2、切换分组,修改访问/v2/api-docs/ 接口的路径 | |||||
| * https://admintest.malls.iformall.com/v2/api-docs/ | |||||
| * https://admintest.malls.iformall.com/B/v2/api-docs/ | |||||
| * | |||||
| * @param servletContext | |||||
| * @return {@link Docket} | |||||
| */ | |||||
| @Bean | |||||
| public Docket api(ServletContext servletContext) { | |||||
| // base-path处理 | |||||
| if (swaggerProperties.getBasePath().isEmpty()) { | |||||
| swaggerProperties.getBasePath().add(BASE_PATH); | |||||
| } | |||||
| List<Predicate<String>> basePath = new ArrayList<>(swaggerProperties.getBasePath().size()); | |||||
| 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))); | |||||
| return new Docket(DocumentationType.SWAGGER_2) | |||||
| .host(swaggerProperties.getHost()) | |||||
| .apiInfo(apiInfo(swaggerProperties)).select() | |||||
| .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) | |||||
| .apis(input -> { | |||||
| ApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(ApiVersion.class); | |||||
| return apiVersion != null && Arrays.asList(apiVersion.group()).contains(SwaggerConstant.V_1_0_0); | |||||
| }) | |||||
| .paths( | |||||
| Predicates.and( | |||||
| Predicates.not(Predicates.or(excludePath)), | |||||
| Predicates.or(basePath) | |||||
| ) | |||||
| ) | |||||
| .build(); | |||||
| } | |||||
| 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(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,123 @@ | |||||
| package com.iformall.config; | |||||
| import lombok.Data; | |||||
| import lombok.NoArgsConstructor; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| @ConfigurationProperties("swagger") | |||||
| public class SwaggerProperties { | |||||
| private Map<String, String> services; | |||||
| private String prePath; | |||||
| /** | |||||
| * 是否开启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(); | |||||
| @Data | |||||
| public static class Contact { | |||||
| /** | |||||
| * 联系人 | |||||
| **/ | |||||
| private String name = ""; | |||||
| /** | |||||
| * 联系人url | |||||
| **/ | |||||
| private String url = ""; | |||||
| /** | |||||
| * 联系人email | |||||
| **/ | |||||
| private String email = ""; | |||||
| } | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| 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<>(); | |||||
| } | |||||
| @Data | |||||
| @NoArgsConstructor | |||||
| public static class AuthorizationScope { | |||||
| /** | |||||
| * 作用域名称 | |||||
| */ | |||||
| private String scope = ""; | |||||
| /** | |||||
| * 作用域描述 | |||||
| */ | |||||
| private String description = ""; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.iformall.constant; | |||||
| public interface SwaggerConstant { | |||||
| /** | |||||
| * | |||||
| */ | |||||
| String V_1_0_0 = "v1.0.0"; | |||||
| } | |||||
| @@ -25,6 +25,7 @@ | |||||
| <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE" level="project" /> | ||||
| <orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | <orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> | <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> | ||||
| <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.4.RELEASE" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.4.RELEASE" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.4.RELEASE" level="project" /> | ||||
| @@ -161,7 +162,7 @@ | |||||
| <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> | ||||
| <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> | ||||
| <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> | ||||
| <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||||
| <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||||
| <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" /> | ||||
| <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | ||||
| <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | ||||
| @@ -184,21 +185,6 @@ | |||||
| <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" /> | <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" /> | ||||
| <orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" /> | <orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | ||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.14" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.14" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.8.0" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" /> | |||||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" /> | ||||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" /> | ||||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" /> | ||||
| @@ -239,6 +225,7 @@ | |||||
| <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.1" level="project" /> | <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.1" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" /> | <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" /> | ||||
| <orderEntry type="library" name="Maven: ognl:ognl:3.2.6" level="project" /> | <orderEntry type="library" name="Maven: ognl:ognl:3.2.6" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" /> | |||||
| <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> | <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> | ||||
| <orderEntry type="library" name="Maven: cn.afterturn:easypoi-annotation:4.1.3.A" level="project" /> | <orderEntry type="library" name="Maven: cn.afterturn:easypoi-annotation:4.1.3.A" level="project" /> | ||||
| <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.5.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.5.RELEASE" level="project" /> | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.iformall.annotation.BaseEnableSwagger; | |||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
| import org.mybatis.spring.annotation.MapperScan; | import org.mybatis.spring.annotation.MapperScan; | ||||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | import org.rocketmq.starter.annotation.EnableRocketMQ; | ||||
| @@ -18,7 +19,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| */ | */ | ||||
| @SpringBootApplication | @SpringBootApplication | ||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | @MapperScan(basePackages = {"com.iformall.mapper"}) | ||||
| @EnableSwagger2 | |||||
| @BaseEnableSwagger | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| @EnableAsync | @EnableAsync | ||||
| @EnableRocketMQ | @EnableRocketMQ | ||||
| @@ -139,6 +139,7 @@ public class ShiroConfig { | |||||
| // } | // } | ||||
| // swagger-ui | // swagger-ui | ||||
| filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | ||||
| filterChainDefinitionMap.put("/doc.html", "anon"); | |||||
| filterChainDefinitionMap.put("/v2/**", "anon"); | filterChainDefinitionMap.put("/v2/**", "anon"); | ||||
| filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | ||||
| filterChainDefinitionMap.put("/webjars/**", "anon"); | filterChainDefinitionMap.put("/webjars/**", "anon"); | ||||
| @@ -1,61 +1,61 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import springfox.documentation.builders.ApiInfoBuilder; | |||||
| import springfox.documentation.builders.ParameterBuilder; | |||||
| import springfox.documentation.builders.PathSelectors; | |||||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| import springfox.documentation.schema.ModelRef; | |||||
| import springfox.documentation.service.ApiInfo; | |||||
| import springfox.documentation.service.Parameter; | |||||
| import springfox.documentation.spi.DocumentationType; | |||||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
| import springfox.documentation.spring.web.plugins.Docket; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import javax.servlet.ServletContext; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
| @Configuration | |||||
| @EnableSwagger2 | |||||
| public class Swagger2Config { | |||||
| @Autowired | |||||
| private ServletContext servletContext; | |||||
| @Bean | |||||
| public Docket createRestApi() { | |||||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||||
| //增加一个request的header参数 | |||||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
| pars.add(tokenPar.build()); | |||||
| return new Docket(DocumentationType.SWAGGER_2) | |||||
| .apiInfo(apiInfo()) | |||||
| .select() | |||||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
| .paths(PathSelectors.any()) | |||||
| .build() | |||||
| .globalOperationParameters(pars) | |||||
| .pathProvider(new RelativePathProvider(servletContext) { | |||||
| @Override | |||||
| public String getApplicationBasePath() { | |||||
| return "/api"; | |||||
| } | |||||
| }); | |||||
| } | |||||
| private ApiInfo apiInfo() { | |||||
| return new ApiInfoBuilder() | |||||
| .title("a端 api") | |||||
| .description("a api") | |||||
| .termsOfServiceUrl("http://localhost:7000") | |||||
| .version("2.0") | |||||
| .build(); | |||||
| } | |||||
| } | |||||
| //package com.iformall.config; | |||||
| // | |||||
| //import org.springframework.beans.factory.annotation.Autowired; | |||||
| //import org.springframework.context.annotation.Bean; | |||||
| //import org.springframework.context.annotation.Configuration; | |||||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||||
| //import springfox.documentation.builders.ParameterBuilder; | |||||
| //import springfox.documentation.builders.PathSelectors; | |||||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| //import springfox.documentation.schema.ModelRef; | |||||
| //import springfox.documentation.service.ApiInfo; | |||||
| //import springfox.documentation.service.Parameter; | |||||
| //import springfox.documentation.spi.DocumentationType; | |||||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
| //import springfox.documentation.spring.web.plugins.Docket; | |||||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| // | |||||
| //import javax.servlet.ServletContext; | |||||
| //import java.util.ArrayList; | |||||
| //import java.util.List; | |||||
| // | |||||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
| //@Configuration | |||||
| //@EnableSwagger2 | |||||
| //public class Swagger2Config { | |||||
| // | |||||
| // @Autowired | |||||
| // private ServletContext servletContext; | |||||
| // | |||||
| // @Bean | |||||
| // public Docket createRestApi() { | |||||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||||
| // //增加一个request的header参数 | |||||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
| // pars.add(tokenPar.build()); | |||||
| // return new Docket(DocumentationType.SWAGGER_2) | |||||
| // .apiInfo(apiInfo()) | |||||
| // .select() | |||||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
| // .paths(PathSelectors.any()) | |||||
| // .build() | |||||
| // .globalOperationParameters(pars) | |||||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||||
| // @Override | |||||
| // public String getApplicationBasePath() { | |||||
| // return "/api"; | |||||
| // } | |||||
| // }); | |||||
| // } | |||||
| // | |||||
| // private ApiInfo apiInfo() { | |||||
| // return new ApiInfoBuilder() | |||||
| // .title("a端 api") | |||||
| // .description("a api") | |||||
| // .termsOfServiceUrl("http://localhost:7000") | |||||
| // .version("2.0") | |||||
| // .build(); | |||||
| // } | |||||
| // | |||||
| //} | |||||
| @@ -100,7 +100,9 @@ public class WebConfig implements WebMvcConfigurer { | |||||
| @Override | @Override | ||||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||||
| registry.addResourceHandler("swagger-ui.html") | |||||
| // registry.addResourceHandler("swagger-ui.html") | |||||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("doc.html") | |||||
| .addResourceLocations("classpath:/META-INF/resources/"); | .addResourceLocations("classpath:/META-INF/resources/"); | ||||
| registry.addResourceHandler("/webjars/**") | registry.addResourceHandler("/webjars/**") | ||||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | .addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.domain.dto.sm.SaveApiGuideDTO; | import com.iformall.domain.dto.sm.SaveApiGuideDTO; | ||||
| import com.iformall.domain.dto.sm.UpdateApiGuideDTO; | import com.iformall.domain.dto.sm.UpdateApiGuideDTO; | ||||
| import com.iformall.domain.po.sm.ApiGuide; | import com.iformall.domain.po.sm.ApiGuide; | ||||
| @@ -18,12 +20,14 @@ public class ApiGuideController { | |||||
| @Autowired | @Autowired | ||||
| private ApiGuideService apiGuideService; | private ApiGuideService apiGuideService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("分页查询api指南") | @ApiOperation("分页查询api指南") | ||||
| @GetMapping("/page") | @GetMapping("/page") | ||||
| public ResultData pageApiGuide(ApiGuide apiGuide, Integer pageNum, Integer pageSize) { | public ResultData pageApiGuide(ApiGuide apiGuide, Integer pageNum, Integer pageSize) { | ||||
| return new ResultData(apiGuideService.pageApiGuide(apiGuide, pageNum, pageSize)); | return new ResultData(apiGuideService.pageApiGuide(apiGuide, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("新增api指南") | @ApiOperation("新增api指南") | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| public ResultData saveApiGuide(@RequestBody SaveApiGuideDTO dto) { | public ResultData saveApiGuide(@RequestBody SaveApiGuideDTO dto) { | ||||
| @@ -31,6 +35,7 @@ public class ApiGuideController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("修改api指南") | @ApiOperation("修改api指南") | ||||
| @PostMapping("/update") | @PostMapping("/update") | ||||
| public ResultData updateApiGuide(@RequestBody UpdateApiGuideDTO dto) { | public ResultData updateApiGuide(@RequestBody UpdateApiGuideDTO dto) { | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.domain.dto.sm.SaveApiMenuDTO; | import com.iformall.domain.dto.sm.SaveApiMenuDTO; | ||||
| import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | ||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| @@ -20,12 +22,14 @@ public class ApiMenuController { | |||||
| @Autowired | @Autowired | ||||
| private ApiMenuService apiMenuService; | private ApiMenuService apiMenuService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("分页查询api菜单") | @ApiOperation("分页查询api菜单") | ||||
| @GetMapping("/page") | @GetMapping("/page") | ||||
| public ResultData pageApiMenu(ApiMenu ApiMenu, Integer pageNum, Integer pageSize) { | public ResultData pageApiMenu(ApiMenu ApiMenu, Integer pageNum, Integer pageSize) { | ||||
| return new ResultData(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | return new ResultData(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("单个查询api菜单") | @ApiOperation("单个查询api菜单") | ||||
| @GetMapping("/get") | @GetMapping("/get") | ||||
| public ResultData getApiMenu(Long id) { | public ResultData getApiMenu(Long id) { | ||||
| @@ -35,6 +39,7 @@ public class ApiMenuController { | |||||
| return new ResultData(apiMenuService.getApiMenu(id)); | return new ResultData(apiMenuService.getApiMenu(id)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("新增api菜单") | @ApiOperation("新增api菜单") | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| public ResultData saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | public ResultData saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | ||||
| @@ -42,6 +47,7 @@ public class ApiMenuController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("修改api菜单") | @ApiOperation("修改api菜单") | ||||
| @PostMapping("/update") | @PostMapping("/update") | ||||
| public ResultData updateApiMenu(@RequestBody UpdateApiMenuDTO dto) { | public ResultData updateApiMenu(@RequestBody UpdateApiMenuDTO dto) { | ||||
| @@ -49,6 +55,7 @@ public class ApiMenuController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("全查询父级api菜单") | @ApiOperation("全查询父级api菜单") | ||||
| @GetMapping("/listParentMenu") | @GetMapping("/listParentMenu") | ||||
| public ResultData listParentMenu() { | public ResultData listParentMenu() { | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.dto.sm.SaveServiceInfoDTO; | import com.iformall.domain.dto.sm.SaveServiceInfoDTO; | ||||
| import com.iformall.domain.dto.sm.UpdateServiceInfoDTO; | import com.iformall.domain.dto.sm.UpdateServiceInfoDTO; | ||||
| @@ -20,12 +22,14 @@ public class ServiceInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private ServiceInfoService serviceInfoService; | private ServiceInfoService serviceInfoService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("分页查询合作商") | @ApiOperation("分页查询合作商") | ||||
| @GetMapping("/page") | @GetMapping("/page") | ||||
| public ResultData pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | public ResultData pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | ||||
| return new ResultData(serviceInfoService.pageServiceInfo(serviceInfo, pageNum, pageSize)); | return new ResultData(serviceInfoService.pageServiceInfo(serviceInfo, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("新增合作商") | @ApiOperation("新增合作商") | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| public ResultData saveServiceInfo(@RequestBody SaveServiceInfoDTO dto) { | public ResultData saveServiceInfo(@RequestBody SaveServiceInfoDTO dto) { | ||||
| @@ -33,6 +37,7 @@ public class ServiceInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("修改合作商") | @ApiOperation("修改合作商") | ||||
| @PostMapping("/update") | @PostMapping("/update") | ||||
| public ResultData updateServiceInfo(@RequestBody UpdateServiceInfoDTO dto) { | public ResultData updateServiceInfo(@RequestBody UpdateServiceInfoDTO dto) { | ||||
| @@ -40,6 +45,7 @@ public class ServiceInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("修改合作商状态") | @ApiOperation("修改合作商状态") | ||||
| @PostMapping("/updateStatus") | @PostMapping("/updateStatus") | ||||
| public ResultData updateServiceInfoStatus(@RequestBody UpdateServiceInfoStatusDTO dto) { | public ResultData updateServiceInfoStatus(@RequestBody UpdateServiceInfoStatusDTO dto) { | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | ||||
| import com.iformall.domain.po.WxThirdPartyApi; | import com.iformall.domain.po.WxThirdPartyApi; | ||||
| import com.iformall.exception.BizException; | import com.iformall.exception.BizException; | ||||
| @@ -19,12 +21,14 @@ public class ThirdPartyApiController { | |||||
| @Autowired | @Autowired | ||||
| private WxThirdPartyApiService thirdPartyApiService; | private WxThirdPartyApiService thirdPartyApiService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("分页查询秘钥") | @ApiOperation("分页查询秘钥") | ||||
| @GetMapping("/page") | @GetMapping("/page") | ||||
| public ResultData pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | public ResultData pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | ||||
| return new ResultData(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | return new ResultData(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("单个查询秘钥") | @ApiOperation("单个查询秘钥") | ||||
| @GetMapping("/get") | @GetMapping("/get") | ||||
| public ResultData getThirdPartyApi(Long id) { | public ResultData getThirdPartyApi(Long id) { | ||||
| @@ -34,6 +38,7 @@ public class ThirdPartyApiController { | |||||
| return new ResultData(thirdPartyApiService.getThirdPartyApi(id)); | return new ResultData(thirdPartyApiService.getThirdPartyApi(id)); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("修改秘钥状态") | @ApiOperation("修改秘钥状态") | ||||
| @PostMapping("/updateStatus") | @PostMapping("/updateStatus") | ||||
| public ResultData updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | public ResultData updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | ||||
| @@ -2,9 +2,11 @@ package com.iformall.controller.sys; | |||||
| import com.google.code.kaptcha.Constants; | import com.google.code.kaptcha.Constants; | ||||
| import com.google.code.kaptcha.Producer; | import com.google.code.kaptcha.Producer; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| @@ -75,6 +77,7 @@ public class HomeController extends BaseController { | |||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| RedisTemplate<String, Object> redisTemplate; | RedisTemplate<String, Object> redisTemplate; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("验证码") | @ApiOperation("验证码") | ||||
| @GetMapping("/captcha.jpg") | @GetMapping("/captcha.jpg") | ||||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | public void captcha(HttpServletResponse response)throws ServletException, IOException { | ||||
| @@ -97,6 +100,7 @@ public class HomeController extends BaseController { | |||||
| IOUtils.closeQuietly(out); | IOUtils.closeQuietly(out); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("登录") | @ApiOperation("登录") | ||||
| @PostMapping("/doLogin") | @PostMapping("/doLogin") | ||||
| public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | ||||
| @@ -1,10 +1,12 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| @@ -43,6 +45,7 @@ public class MallRoleController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private MallUserRoleService mallUserRoleService; | private MallUserRoleService mallUserRoleService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色列表") | @ApiOperation("角色列表") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -95,7 +98,7 @@ public class MallRoleController extends BaseController { | |||||
| return new ResultData(role); | return new ResultData(role); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色保存") | @ApiOperation("角色保存") | ||||
| @PostMapping("saveOrUpdate") | @PostMapping("saveOrUpdate") | ||||
| //@RequiresPermissions("sys:role:save") | //@RequiresPermissions("sys:role:save") | ||||
| @@ -126,6 +129,7 @@ public class MallRoleController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("角色删除") | @ApiOperation("角色删除") | ||||
| @PostMapping("/del") | @PostMapping("/del") | ||||
| //@RequiresPermissions("sys:role:del") | //@RequiresPermissions("sys:role:del") | ||||
| @@ -1,10 +1,12 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| @@ -60,6 +62,7 @@ public class MallUserInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxMsgValidationcodeService wxMsgValidationcodeService; | WxMsgValidationcodeService wxMsgValidationcodeService; | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "用户分页接口", response = String.class) | @ApiOperation(value = "用户分页接口", response = String.class) | ||||
| @GetMapping("lists") | @GetMapping("lists") | ||||
| //@RequiresPermissions("sys:user:list") | //@RequiresPermissions("sys:user:list") | ||||
| @@ -110,6 +113,7 @@ public class MallUserInfoController extends BaseController { | |||||
| return new ResultData(user); | return new ResultData(user); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "创建用户接口", response = String.class) | @ApiOperation(value = "创建用户接口", response = String.class) | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| //@RequiresPermissions("sys:user:add") | //@RequiresPermissions("sys:user:add") | ||||
| @@ -147,6 +151,7 @@ public class MallUserInfoController extends BaseController { | |||||
| return new ResultData(userInfo); | return new ResultData(userInfo); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "修改用户接口", response = String.class) | @ApiOperation(value = "修改用户接口", response = String.class) | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| //@RequiresPermissions("sys:user:update") | //@RequiresPermissions("sys:user:update") | ||||
| @@ -225,6 +230,7 @@ public class MallUserInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "删除用户接口", response = String.class) | @ApiOperation(value = "删除用户接口", response = String.class) | ||||
| @PostMapping("/del") | @PostMapping("/del") | ||||
| //@RequiresPermissions("sys:user:del") | //@RequiresPermissions("sys:user:del") | ||||
| @@ -320,6 +326,7 @@ public class MallUserInfoController extends BaseController { | |||||
| return new ResultData(menu); | return new ResultData(menu); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "用户密码发送验证码") | @ApiOperation(value = "用户密码发送验证码") | ||||
| @GetMapping("sendvalidationcode") | @GetMapping("sendvalidationcode") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -353,6 +360,7 @@ public class MallUserInfoController extends BaseController { | |||||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation(value = "修改密码", notes = "{\"userName\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | @ApiOperation(value = "修改密码", notes = "{\"userName\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | ||||
| @PostMapping("/updatepwd") | @PostMapping("/updatepwd") | ||||
| @SystemControllerLog(description = "用户管理-修改密码") | @SystemControllerLog(description = "用户管理-修改密码") | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallPermission; | import com.iformall.domain.po.MallPermission; | ||||
| import com.iformall.domain.po.MallRole; | import com.iformall.domain.po.MallRole; | ||||
| @@ -65,6 +67,7 @@ public class SysMenuController extends BaseController { | |||||
| return new ResultData(map); | return new ResultData(map); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("所有菜单列表") | @ApiOperation("所有菜单列表") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| //@RequiresPermissions("sys:menu:list") | //@RequiresPermissions("sys:menu:list") | ||||
| @@ -208,4 +208,18 @@ suimang: | |||||
| photo_speak_hy: xxx | photo_speak_hy: xxx | ||||
| digital_avatar: xxx | digital_avatar: xxx | ||||
| digital_avatar_hy: xxx | digital_avatar_hy: xxx | ||||
| callbackUrl: xxx | |||||
| callbackUrl: xxx | |||||
| swagger: | |||||
| base-package: com.iformall.controller | |||||
| title: 遂芒_metavatar_接口文档 | |||||
| description: 前后端联调 | |||||
| version: 1.0 | |||||
| license: Apache | |||||
| license-url: https://mtest.metavatar.cc/ | |||||
| terms-of-service-url: https://mtest.metavatar.cc/ | |||||
| host: localhost:8888 | |||||
| contact: | |||||
| name: 张三 | |||||
| url: https://mtest.metavatar.cc/ | |||||
| email: zhangsan@163.com | |||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.iformall.annotation.BaseEnableSwagger; | |||||
| import org.mybatis.spring.annotation.MapperScan; | import org.mybatis.spring.annotation.MapperScan; | ||||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | import org.rocketmq.starter.annotation.EnableRocketMQ; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| @@ -15,6 +16,7 @@ import org.springframework.scheduling.annotation.EnableAsync; | |||||
| * @author chenkx | * @author chenkx | ||||
| * @date 2017-12-26 | * @date 2017-12-26 | ||||
| */ | */ | ||||
| @BaseEnableSwagger | |||||
| @SpringBootApplication | @SpringBootApplication | ||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | @MapperScan(basePackages = {"com.iformall.mapper"}) | ||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| @@ -1,61 +1,61 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import springfox.documentation.builders.ApiInfoBuilder; | |||||
| import springfox.documentation.builders.ParameterBuilder; | |||||
| import springfox.documentation.builders.PathSelectors; | |||||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| import springfox.documentation.schema.ModelRef; | |||||
| import springfox.documentation.service.ApiInfo; | |||||
| import springfox.documentation.service.Parameter; | |||||
| import springfox.documentation.spi.DocumentationType; | |||||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
| import springfox.documentation.spring.web.plugins.Docket; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import javax.servlet.ServletContext; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
| @Configuration | |||||
| @EnableSwagger2 | |||||
| public class Swagger2Config { | |||||
| @Autowired | |||||
| private ServletContext servletContext; | |||||
| @Bean | |||||
| public Docket createRestApi() { | |||||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||||
| //增加一个request的header参数 | |||||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
| pars.add(tokenPar.build()); | |||||
| return new Docket(DocumentationType.SWAGGER_2) | |||||
| .apiInfo(apiInfo()) | |||||
| .select() | |||||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
| .paths(PathSelectors.any()) | |||||
| .build() | |||||
| .globalOperationParameters(pars) | |||||
| .pathProvider(new RelativePathProvider(servletContext) { | |||||
| @Override | |||||
| public String getApplicationBasePath() { | |||||
| return "/api"; | |||||
| } | |||||
| }); | |||||
| } | |||||
| private ApiInfo apiInfo() { | |||||
| return new ApiInfoBuilder() | |||||
| .title("c端 api") | |||||
| .description("c api") | |||||
| .termsOfServiceUrl("http://localhost:7000") | |||||
| .version("2.0") | |||||
| .build(); | |||||
| } | |||||
| } | |||||
| //package com.iformall.config; | |||||
| // | |||||
| //import org.springframework.beans.factory.annotation.Autowired; | |||||
| //import org.springframework.context.annotation.Bean; | |||||
| //import org.springframework.context.annotation.Configuration; | |||||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||||
| //import springfox.documentation.builders.ParameterBuilder; | |||||
| //import springfox.documentation.builders.PathSelectors; | |||||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||||
| //import springfox.documentation.schema.ModelRef; | |||||
| //import springfox.documentation.service.ApiInfo; | |||||
| //import springfox.documentation.service.Parameter; | |||||
| //import springfox.documentation.spi.DocumentationType; | |||||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
| //import springfox.documentation.spring.web.plugins.Docket; | |||||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| // | |||||
| //import javax.servlet.ServletContext; | |||||
| //import java.util.ArrayList; | |||||
| //import java.util.List; | |||||
| // | |||||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
| //@Configuration | |||||
| //@EnableSwagger2 | |||||
| //public class Swagger2Config { | |||||
| // | |||||
| // @Autowired | |||||
| // private ServletContext servletContext; | |||||
| // | |||||
| // @Bean | |||||
| // public Docket createRestApi() { | |||||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||||
| // //增加一个request的header参数 | |||||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
| // pars.add(tokenPar.build()); | |||||
| // return new Docket(DocumentationType.SWAGGER_2) | |||||
| // .apiInfo(apiInfo()) | |||||
| // .select() | |||||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
| // .paths(PathSelectors.any()) | |||||
| // .build() | |||||
| // .globalOperationParameters(pars) | |||||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||||
| // @Override | |||||
| // public String getApplicationBasePath() { | |||||
| // return "/api"; | |||||
| // } | |||||
| // }); | |||||
| // } | |||||
| // | |||||
| // private ApiInfo apiInfo() { | |||||
| // return new ApiInfoBuilder() | |||||
| // .title("c端 api") | |||||
| // .description("c api") | |||||
| // .termsOfServiceUrl("http://localhost:7000") | |||||
| // .version("2.0") | |||||
| // .build(); | |||||
| // } | |||||
| // | |||||
| //} | |||||
| @@ -54,7 +54,9 @@ public class WebMvcConfig implements WebMvcConfigurer { | |||||
| @Override | @Override | ||||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||||
| registry.addResourceHandler("swagger-ui.html") | |||||
| // registry.addResourceHandler("swagger-ui.html") | |||||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("doc.html") | |||||
| .addResourceLocations("classpath:/META-INF/resources/"); | .addResourceLocations("classpath:/META-INF/resources/"); | ||||
| registry.addResourceHandler("/webjars/**") | registry.addResourceHandler("/webjars/**") | ||||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | .addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.service.sm.ApiGuideService; | import com.iformall.service.sm.ApiGuideService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -19,6 +21,7 @@ public class ApiGuideController { | |||||
| private ApiGuideService apiGuideService; | private ApiGuideService apiGuideService; | ||||
| @AuthIgnore | @AuthIgnore | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("单个查询api指南") | @ApiOperation("单个查询api指南") | ||||
| @GetMapping("/getAvailableApiGuide") | @GetMapping("/getAvailableApiGuide") | ||||
| public ResultData getAvailableApiGuide() { | public ResultData getAvailableApiGuide() { | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.exception.BizException; | import com.iformall.exception.BizException; | ||||
| import com.iformall.service.sm.ApiMenuService; | import com.iformall.service.sm.ApiMenuService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -19,6 +21,7 @@ public class ApiMenuController { | |||||
| private ApiMenuService apiMenuService; | private ApiMenuService apiMenuService; | ||||
| @AuthIgnore | @AuthIgnore | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("全查询api菜单") | @ApiOperation("全查询api菜单") | ||||
| @GetMapping("/list") | @GetMapping("/list") | ||||
| public ResultData listApiMenu() { | public ResultData listApiMenu() { | ||||
| @@ -26,6 +29,7 @@ public class ApiMenuController { | |||||
| } | } | ||||
| @AuthIgnore | @AuthIgnore | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("查询某个api菜单所有子菜单") | @ApiOperation("查询某个api菜单所有子菜单") | ||||
| @GetMapping("/listSubmenu") | @GetMapping("/listSubmenu") | ||||
| public ResultData listApiSubmenu(Long id) { | public ResultData listApiSubmenu(Long id) { | ||||
| @@ -36,6 +40,7 @@ public class ApiMenuController { | |||||
| } | } | ||||
| @AuthIgnore | @AuthIgnore | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("单个查询菜单详情") | @ApiOperation("单个查询菜单详情") | ||||
| @GetMapping("/get") | @GetMapping("/get") | ||||
| public ResultData getApiMenu(Long id) { | public ResultData getApiMenu(Long id) { | ||||
| @@ -195,3 +195,17 @@ suimang: | |||||
| digital_avatar: http://nas.pucao.cn:2005 | digital_avatar: http://nas.pucao.cn:2005 | ||||
| digital_avatar_hy: http://nas.pucao.cn:2003 | digital_avatar_hy: http://nas.pucao.cn:2003 | ||||
| callbackUrl: https://mtest.metavatar.cc/C | callbackUrl: https://mtest.metavatar.cc/C | ||||
| swagger: | |||||
| base-package: com.iformall.controller | |||||
| title: 遂芒_metavatar_接口文档 | |||||
| description: 前后端联调 | |||||
| version: 1.0 | |||||
| license: Apache | |||||
| license-url: https://mtest.metavatar.cc/ | |||||
| terms-of-service-url: https://mtest.metavatar.cc/ | |||||
| host: localhost:8888 | |||||
| contact: | |||||
| name: 张三 | |||||
| url: https://mtest.metavatar.cc/ | |||||
| email: zhangsan@163.com | |||||
| @@ -20,6 +20,11 @@ | |||||
| <scope>compile</scope> | <scope>compile</scope> | ||||
| </dependency> | </dependency> | ||||
| --> | --> | ||||
| <dependency> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>suimang-swagger</artifactId> | |||||
| <version>1.0</version> | |||||
| </dependency> | |||||
| <dependency> | <dependency> | ||||
| <groupId>com.iformall</groupId> | <groupId>com.iformall</groupId> | ||||
| <artifactId>suimangVideo</artifactId> | <artifactId>suimangVideo</artifactId> | ||||
| @@ -16,4 +16,6 @@ public interface ApiGuideService extends IService<ApiGuide> { | |||||
| void saveApiGuide(SaveApiGuideDTO dto); | void saveApiGuide(SaveApiGuideDTO dto); | ||||
| void updateApiGuide(UpdateApiGuideDTO dto); | void updateApiGuide(UpdateApiGuideDTO dto); | ||||
| ApiGuide getAvailableApiGuide(); | |||||
| } | } | ||||