parent
e9bd79b231
commit
2c15d4f95b
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 79 KiB |
@ -0,0 +1,51 @@
|
|||||||
|
package com.example.demo.config;
|
||||||
|
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lyr
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Profile({"prd","test","dev"})
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
@EnableSwaggerBootstrapUI
|
||||||
|
public class SwaggerConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket api() {
|
||||||
|
// List<RequestParameter> globalRequestParameters = new ArrayList<>();
|
||||||
|
// RequestParameter build = new RequestParameterBuilder().name("abc").description("添加swagger公共请求参数abc").required(true).build();
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.qkc.stat.controller"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build()
|
||||||
|
// .globalRequestParameters(globalRequestParameters)
|
||||||
|
// .securitySchemes(securitySchemes()) //添加token
|
||||||
|
// .securityContexts(securityContexts()) //swagger配置页面访问是否需要传token
|
||||||
|
.apiInfo(apiInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("统计信息服务")
|
||||||
|
.description("统计服务相关接口")
|
||||||
|
.termsOfServiceUrl("127.0.0.1")
|
||||||
|
.version("1.0.0")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.example.demo.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: lyr
|
||||||
|
* @Date: 2021-04-21 10:13
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebMvnConfig extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
|
||||||
|
registry.addMapping("/**")
|
||||||
|
.allowedOrigins("*")
|
||||||
|
.allowedMethods("PUT", "DELETE", "GET", "POST", "OPTIONS")
|
||||||
|
.allowCredentials(true).maxAge(3600);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||||
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.demo.pojo;
|
package com.example.demo.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
@ -1,13 +1,12 @@
|
|||||||
package com.example.demo.mapper;
|
package com.example.demo.mapper;
|
||||||
|
|
||||||
import com.example.demo.pojo.User;
|
import com.example.demo.domain.User;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc
|
* @desc
|
||||||
*
|
*
|
||||||
* @author lastwhisper
|
|
||||||
* @email gaojun56@163.com
|
|
||||||
*/
|
*/
|
||||||
public interface UserMapper extends BaseMapper<User> {
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
}
|
}
|
Loading…
Reference in new issue