Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-platform
Commits
6c4f1c67
Commit
6c4f1c67
authored
Aug 19, 2020
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增swagger2配置
parent
38a83471
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
1 deletion
+133
-1
pom.xml
pom.xml
+18
-0
Swagger2Config.java
src/main/java/cn/qg/qaplatform/config/Swagger2Config.java
+75
-0
GenLoanUserDataController.java
...n/qg/qaplatform/controller/GenLoanUserDataController.java
+11
-0
QueryLoanUserDataController.java
...qg/qaplatform/controller/QueryLoanUserDataController.java
+29
-1
No files found.
pom.xml
View file @
6c4f1c67
...
...
@@ -129,6 +129,24 @@
<version>
1.1.35
</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.9.2
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
</dependency>
<!--修改swagger主题-->
<dependency>
<groupId>
com.github.caspar-chen
</groupId>
<artifactId>
swagger-ui-layer
</artifactId>
<version>
1.1.3
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
...
...
src/main/java/cn/qg/qaplatform/config/Swagger2Config.java
0 → 100644
View file @
6c4f1c67
package
cn
.
qg
.
qaplatform
.
config
;
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.*
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
@EnableSwagger2
public
class
Swagger2Config
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
groupName
(
"测试平台后台"
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"cn.qg.qaplatform.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
()
.
securitySchemes
(
securitySchemes
())
.
securityContexts
(
securityContexts
());
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"测试平台后台"
)
.
description
(
"测试平台后台"
)
.
contact
(
new
Contact
(
"点击这里可以跳转"
,
""
,
"bo.li@quantgroup.cn"
))
.
version
(
"1.0"
)
.
build
();
}
private
List
<
ApiKey
>
securitySchemes
()
{
//设置请求头信息
List
<
ApiKey
>
result
=
new
ArrayList
<>();
ApiKey
apiKey
=
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
);
result
.
add
(
apiKey
);
return
result
;
}
private
List
<
SecurityContext
>
securityContexts
()
{
//设置需要登录认证的路径
List
<
SecurityContext
>
result
=
new
ArrayList
<>();
result
.
add
(
getContextByPath
(
"/brand/.*"
));
result
.
add
(
getContextByPath
(
"/product/.*"
));
result
.
add
(
getContextByPath
(
"/productCategory/.*"
));
return
result
;
}
private
SecurityContext
getContextByPath
(
String
pathRegex
)
{
return
SecurityContext
.
builder
()
.
securityReferences
(
defaultAuth
())
.
forPaths
(
PathSelectors
.
regex
(
pathRegex
))
.
build
();
}
private
List
<
SecurityReference
>
defaultAuth
()
{
List
<
SecurityReference
>
result
=
new
ArrayList
<>();
AuthorizationScope
authorizationScope
=
new
AuthorizationScope
(
"global"
,
"accessEverything"
);
AuthorizationScope
[]
authorizationScopes
=
new
AuthorizationScope
[
1
];
authorizationScopes
[
0
]
=
authorizationScope
;
result
.
add
(
new
SecurityReference
(
"Authorization"
,
authorizationScopes
));
return
result
;
}
}
src/main/java/cn/qg/qaplatform/controller/GenLoanUserDataController.java
View file @
6c4f1c67
...
...
@@ -8,6 +8,10 @@ import cn.qg.qaplatform.service.GenUserDataService;
import
cn.qg.qaplatform.service.QueryBasicLoanStatusDataService
;
import
cn.qg.qaplatform.utils.EnumUtils
;
import
cn.qg.qaplatform.utils.RandomDataUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -18,6 +22,7 @@ import java.util.Map;
@RestController
@CrossOrigin
@RequestMapping
(
"/gen"
)
@Api
(
tags
=
"造数据相关接口"
)
public
class
GenLoanUserDataController
{
@Autowired
...
...
@@ -26,6 +31,7 @@ public class GenLoanUserDataController {
@Autowired
QueryBasicLoanStatusDataService
queryBasicLoanStatusDataService
;
@ApiOperation
(
value
=
"造数据接口"
)
@PostMapping
(
"/loanUser"
)
public
JsonResult
genLoanUserData
(
@RequestBody
ApplyLoanInfo
applyLoanInfo
)
throws
Exception
{
if
(
applyLoanInfo
.
getNamespace
()
==
null
)
{
...
...
@@ -34,6 +40,9 @@ public class GenLoanUserDataController {
if
(
applyLoanInfo
.
getChannel
()
==
null
)
{
return
JsonResult
.
clientFailed
(
"渠道不能为空!"
);
}
if
(
applyLoanInfo
.
getFundId
()
==
null
)
{
return
JsonResult
.
clientFailed
(
"资方不能为空!"
);
}
if
(
applyLoanInfo
.
getStatus
()
==
null
)
{
return
JsonResult
.
clientFailed
(
"借款状态不能为空!"
);
}
...
...
@@ -57,6 +66,7 @@ public class GenLoanUserDataController {
return
JsonResult
.
success
(
result
);
}
@ApiOperation
(
value
=
"获取所有支持的资方和渠道"
)
@GetMapping
(
"/supportChannelAndFund"
)
public
JsonResult
getSupportedLoanUserData
()
{
Map
<
String
,
List
>
map
=
new
HashMap
();
...
...
@@ -67,6 +77,7 @@ public class GenLoanUserDataController {
return
JsonResult
.
success
(
map
);
}
@ApiOperation
(
value
=
"获取所有支持的用户状态"
)
@GetMapping
(
"/userStatus"
)
public
JsonResult
queryUserStatus
(
@RequestParam
String
namespace
,
@RequestParam
String
phoneNo
)
{
...
...
src/main/java/cn/qg/qaplatform/controller/QueryLoanUserDataController.java
View file @
6c4f1c67
...
...
@@ -4,6 +4,10 @@ import cn.qg.qaplatform.service.QueryLoanUserDataService;
import
cn.qg.qaplatform.common.JsonResult
;
import
cn.qg.qaplatform.service.QueryBasicLoanStatusDataService
;
import
cn.qg.qaplatform.utils.page.PageResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -13,6 +17,7 @@ import java.util.Map;
@CrossOrigin
@RestController
@RequestMapping
(
"query"
)
@Api
(
tags
=
"捞数据相关接口"
)
public
class
QueryLoanUserDataController
{
@Autowired
...
...
@@ -24,6 +29,7 @@ public class QueryLoanUserDataController {
/**
* @return 获取所有借款用户状态
*/
@ApiOperation
(
value
=
"获取所有借款状态"
)
@GetMapping
(
"/getAllStatus"
)
public
JsonResult
getLoanUserDataStatus
()
{
List
<
Map
<
String
,
Object
>>
statusList
=
basicLoanStatusDataService
.
getAllUserLoanStatus
();
...
...
@@ -33,6 +39,7 @@ public class QueryLoanUserDataController {
/**
* @return 获取所有环境namespace
*/
@ApiOperation
(
value
=
"获取所有环境信息"
)
@GetMapping
(
"/getAllEnv"
)
public
JsonResult
getAllEnvInfo
()
{
List
<
Map
<
String
,
Object
>>
envList
=
basicLoanStatusDataService
.
getAllEnvInfo
();
...
...
@@ -45,6 +52,15 @@ public class QueryLoanUserDataController {
* @param pageSize
* @return 所有借款用户数据
*/
@ApiOperation
(
value
=
"捞数据接口"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"namespace"
,
value
=
"环境,qa、qa2等"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"借款状态"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"channel"
,
value
=
"渠道id"
),
@ApiImplicitParam
(
name
=
"fundId"
,
value
=
"资方id"
),
@ApiImplicitParam
(
name
=
"pageNum"
,
value
=
"页码"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页数量"
,
defaultValue
=
"10"
)
})
@GetMapping
(
"/loanUser"
)
public
JsonResult
getLoanUserData
(
@RequestParam
(
value
=
"namespace"
)
String
namespace
,
@RequestParam
(
value
=
"status"
)
Integer
status
,
...
...
@@ -61,14 +77,26 @@ public class QueryLoanUserDataController {
* @param phone
* @return
*/
@ApiOperation
(
value
=
"查询手机号是否存在于环境中"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"namespace"
,
value
=
"环境"
),
@ApiImplicitParam
(
name
=
"phone"
,
value
=
"手机号"
)
})
@GetMapping
(
"/phoneExistence"
)
public
JsonResult
checkPhoneExistence
(
@RequestParam
(
value
=
"namespace"
)
String
namespace
,
@RequestParam
(
value
=
"phone"
)
String
phone
)
{
return
JsonResult
.
success
(
basicLoanStatusDataService
.
queryIfPhoneExist
(
namespace
,
phone
));
}
/**
* todo
* @param namespace
* @param phoneNo
* @return
*/
@GetMapping
(
"/getUserInfoByPhoneNo"
)
public
JsonResult
getUserInfoByPhoneNo
(
@RequestParam
(
value
=
"phoneNo"
)
String
phoneNo
)
{
public
JsonResult
getUserInfoByPhoneNo
(
@RequestParam
(
value
=
"namespace"
)
String
namespace
,
@RequestParam
(
value
=
"phoneNo"
)
String
phoneNo
)
{
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment