提交 a9dfb9db authored 作者: Matrix's avatar Matrix

[架构升级]

1. swagger2版本升至 3.0.0(本想引入OPEN API 3标准) 2. spring boot 版本升至 2.2.7 RELEASE 3. 引入knife4j swagger 增加UI页面
上级 75285542
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>
<swagger.version>2.9.0</swagger.version> <swagger.version>3.0.0</swagger.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -27,27 +27,17 @@ ...@@ -27,27 +27,17 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.caspar-chen</groupId> <groupId>com.github.caspar-chen</groupId>
<artifactId>swagger-ui-layer</artifactId> <artifactId>swagger-ui-layer</artifactId>
<version>0.0.4</version> <version>1.1.3</version>
</dependency> </dependency>
<dependency> <dependency>
<scope>compile</scope>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId> <artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
...@@ -79,13 +69,15 @@ ...@@ -79,13 +69,15 @@
<version>4.1.14</version> <version>4.1.14</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!--<dependency>--> <dependency>
<!--<groupId>com.alibaba</groupId>--> <groupId>com.github.xiaoymin</groupId>
<!--<artifactId>fastjson</artifactId>--> <artifactId>knife4j-spring-boot-starter</artifactId>
<!--<version>1.2.46</version>--> <version>2.0.5</version>
<!--</dependency>--> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -29,7 +29,7 @@ public class Swagger2Config { ...@@ -29,7 +29,7 @@ public class Swagger2Config {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.produces(Sets.newHashSet("application/json")) .produces(Sets.newHashSet("application/json"))
.consumes(Sets.newHashSet("application/json")) .consumes(Sets.newHashSet("application/json"))
.protocols(Sets.newHashSet("https","http")) .protocols(Sets.newHashSet("https", "http"))
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.forCodeGeneration(true) .forCodeGeneration(true)
.useDefaultResponseMessages(true) .useDefaultResponseMessages(true)
...@@ -46,15 +46,14 @@ public class Swagger2Config { ...@@ -46,15 +46,14 @@ public class Swagger2Config {
private ApiInfo apiInfo() { private ApiInfo apiInfo() {
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 文档标题 .title("装备管理系统接口文档")
.title("文件传输系统接口文档") .description("装备管理系统接口文档与测试页面")
// 文档描述 .termsOfServiceUrl("http://121.36.222.103:8087/")
.description("文件传输系统的接口文档与测试页面") .version("v1.0")
.termsOfServiceUrl("git地址待更新") .contact(new Contact("ty", "example", "example@gmail.com"))
.version("v1")
.contact(new Contact("efs", "git", "ty@example.com"))
.build(); .build();
} }
private SecurityContext securityContext() { private SecurityContext securityContext() {
return SecurityContext.builder() return SecurityContext.builder()
.securityReferences(Collections.singletonList(new SecurityReference("spring_oauth", scopes()))) .securityReferences(Collections.singletonList(new SecurityReference("spring_oauth", scopes())))
...@@ -71,6 +70,7 @@ public class Swagger2Config { ...@@ -71,6 +70,7 @@ public class Swagger2Config {
.scopes(Arrays.asList(scopes())) .scopes(Arrays.asList(scopes()))
.build(); .build();
} }
private AuthorizationScope[] scopes() { private AuthorizationScope[] scopes() {
return new AuthorizationScope[]{ return new AuthorizationScope[]{
new AuthorizationScope("all", "All scope is trusted!") new AuthorizationScope("all", "All scope is trusted!")
......
...@@ -57,9 +57,9 @@ import static java.util.stream.Collectors.*; ...@@ -57,9 +57,9 @@ import static java.util.stream.Collectors.*;
@RestController @RestController
@RequestMapping(value = "/check/confirm") @RequestMapping(value = "/check/confirm")
@AutoDocument @AutoDocument
@Api(tags = "核查模块", description = "核查模块")
@Transactional @Transactional
@Slf4j @Slf4j
@Api(tags = "核查模块", description = "核查模块", position = 1)
public class DeviceCheckController { public class DeviceCheckController {
@Autowired @Autowired
...@@ -682,3 +682,7 @@ public class DeviceCheckController { ...@@ -682,3 +682,7 @@ public class DeviceCheckController {
return originalNode + fatherId + "."; return originalNode + fatherId + ".";
} }
} }
...@@ -40,7 +40,7 @@ import static com.tykj.dev.misc.utils.TimestampUtil.localDateToDate; ...@@ -40,7 +40,7 @@ import static com.tykj.dev.misc.utils.TimestampUtil.localDateToDate;
@AutoDocument @AutoDocument
@RestController @RestController
@RequestMapping("/check/final") @RequestMapping("/check/final")
@Api(tags = "决算模块", description = "决算模块") @Api(tags = "决算模块", description = "决算模块", position = 2)
public class FinalCheckController { public class FinalCheckController {
@Autowired @Autowired
...@@ -83,7 +83,7 @@ public class FinalCheckController { ...@@ -83,7 +83,7 @@ public class FinalCheckController {
@GetMapping("/reports") @GetMapping("/reports")
@ApiOperation(value = "查询所有决算报告(不附带详情数据)") @ApiOperation(value = "查询所有决算报告(不附带详情数据)")
public ResponseEntity<ResultObj<Page<FinalReportVo>>> findAllReports( public ResponseEntity<ResultObj<Page<FinalReportVo>>> findAllReports(
@RequestParam(required = false, defaultValue = "xw") String keyword, @RequestParam(required = false, defaultValue = "") String keyword,
@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "1") int page,
@RequestParam(required = false, defaultValue = "10") int size) { @RequestParam(required = false, defaultValue = "10") int size) {
return ResultUtil.success(fcService.findAllWithoutDetail(keyword, --page, size)); return ResultUtil.success(fcService.findAllWithoutDetail(keyword, --page, size));
......
...@@ -24,6 +24,7 @@ import java.time.LocalDateTime; ...@@ -24,6 +24,7 @@ import java.time.LocalDateTime;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(value = "时间参数") @ApiModel(value = "时间参数")
@JsonPropertyOrder({"startTime","endTime"})
public class TimeParam { public class TimeParam {
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
......
...@@ -29,7 +29,7 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, ...@@ -29,7 +29,7 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
* @param locations 装备所在地列表 * @param locations 装备所在地列表
* @return 装备数量 * @return 装备数量
*/ */
int countByModelAndLocationUnitContains(String model, List<String> locations); int countByModelAndLocationUnitIn(String model, List<String> locations);
/** /**
* 根据装备型号与装备所在地(一个地区)查询装备数量 * 根据装备型号与装备所在地(一个地区)查询装备数量
......
...@@ -24,29 +24,7 @@ ...@@ -24,29 +24,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>com.tykj.dev</groupId>-->
<!--<artifactId>config</artifactId>-->
<!--<version>1.0-SNAPSHOT</version>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.tykj.dev</groupId>-->
<!--<artifactId>device</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.tykj.dev</groupId>-->
<!--<artifactId>misc</artifactId>-->
<!--<version>1.0-SNAPSHOT</version>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.tykj.dev</groupId>-->
<!--<artifactId>device</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>misc</artifactId> <artifactId>misc</artifactId>
......
...@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
resp.setContentType("application/json;charset=utf-8"); resp.setContentType("application/json;charset=utf-8");
resp.setStatus(401); resp.setStatus(401);
PrintWriter out = resp.getWriter(); PrintWriter out = resp.getWriter();
out.write(new ObjectMapper().writeValueAsString(ApiResult.build(405,"您已在另一台设备登录,本次登录已下线!"))); out.write(new ObjectMapper().writeValueAsString(ApiResult.build(405, "您已在另一台设备登录,本次登录已下线!")));
out.flush(); out.flush();
out.close(); out.close();
}), ConcurrentSessionFilter.class) }), ConcurrentSessionFilter.class)
...@@ -125,9 +125,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -125,9 +125,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
} }
@Override @Override
public void configure(WebSecurity web){ public void configure(WebSecurity web) {
//swagger静态资源访问 //swagger静态资源访问
web.ignoring().antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**","/swagger-resources/configuration/ui","**/swagge‌​r-ui.html","/static/**","/**/index.html","index.html","/js/**","/css/**","/fonds/**","/img/**"); web.ignoring().antMatchers("/v2/api-docs", "/v2/api-docs-ext","/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui/", "/swagger-ui/**","/swagger-ui.html", "/doc.html", "/webjars/**", "/swagger-resources/configuration/ui", "**/swagge‌​r-ui.html", "/static/**", "/**/index.html", "index.html", "/js/**", "/css/**", "/fonds/**", "/img/**");
} }
@Bean @Bean
...@@ -153,13 +153,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -153,13 +153,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
HttpSessionEventPublisher httpSessionEventPublisher() { HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher(); return new HttpSessionEventPublisher();
} }
@Bean @Bean
public SessionRegistryImpl sessionRegistry(){ public SessionRegistryImpl sessionRegistry() {
return new SessionRegistryImpl(); return new SessionRegistryImpl();
} }
@Bean @Bean
public BCryptPasswordEncoder bCryptPasswordEncoder(){ public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder(); return new BCryptPasswordEncoder();
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version> <version>2.2.7.RELEASE</version>
</parent> </parent>
<modules> <modules>
<module>dev-socket</module> <module>dev-socket</module>
...@@ -74,6 +74,11 @@ ...@@ -74,6 +74,11 @@
<version>3.3.0</version> <version>3.3.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>union</artifactId> <artifactId>union</artifactId>
...@@ -251,6 +256,11 @@ ...@@ -251,6 +256,11 @@
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies> </dependencies>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论