Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
afanti-open-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
java-ms
afanti-open-api
Commits
9fcf6dd4
Commit
9fcf6dd4
authored
Jul 19, 2023
by
陈炎
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-8.9.0' into 'develop'
Dev 8.9.0 See merge request
!22
parents
d2a56755
7ff9f4f3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
28 deletions
+36
-28
pom.xml
pom.xml
+9
-9
TokenInterceptor.java
.../com/afanticar/afantiopenapi/config/TokenInterceptor.java
+8
-5
CommonDataController.java
...nticar/afantiopenapi/controller/CommonDataController.java
+2
-2
FawOpenController.java
...afanticar/afantiopenapi/controller/FawOpenController.java
+1
-0
BaseService.java
...java/com/afanticar/afantiopenapi/service/BaseService.java
+1
-4
bootstrap.yml
src/main/resources/bootstrap.yml
+15
-8
No files found.
pom.xml
View file @
9fcf6dd4
...
@@ -166,6 +166,10 @@
...
@@ -166,6 +166,10 @@
<artifactId>
ops-java-common
</artifactId>
<artifactId>
ops-java-common
</artifactId>
<version>
0.0.1-Release
</version>
<version>
0.0.1-Release
</version>
</dependency>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
...
@@ -173,7 +177,7 @@
...
@@ -173,7 +177,7 @@
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-vault-config-databases
</artifactId>
<artifactId>
spring-cloud-vault-config-databases
</artifactId>
<version>
3.0.
4
</version>
<version>
3.0.
5
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
...
@@ -183,16 +187,12 @@
...
@@ -183,16 +187,12 @@
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-vault-config
</artifactId>
<artifactId>
spring-cloud-starter-vault-config
</artifactId>
<version>
2.1.5.RELEASE
</version>
<version>
3.0.5
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.vault
</groupId>
<artifactId>
spring-cloud-vault-config
</artifactId>
<artifactId>
spring-vault-core
</artifactId>
<version>
2.1.5.RELEASE
</version>
<version>
2.3.2
</version>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
</dependency>
</dependency>
<!-- 运维类依赖-->
<!-- 运维类依赖-->
...
...
src/main/java/com/afanticar/afantiopenapi/config/TokenInterceptor.java
View file @
9fcf6dd4
...
@@ -4,8 +4,9 @@ import cn.hutool.core.util.StrUtil;
...
@@ -4,8 +4,9 @@ import cn.hutool.core.util.StrUtil;
import
com.afanticar.afantiopenapi.controller.BaseController
;
import
com.afanticar.afantiopenapi.controller.BaseController
;
import
com.afanticar.afantiopenapi.utils.JWTUtils
;
import
com.afanticar.afantiopenapi.utils.JWTUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.b
eans.factory.annotation.Value
;
import
org.springframework.b
oot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.HandlerInterceptor
;
...
@@ -18,17 +19,19 @@ import java.util.Set;
...
@@ -18,17 +19,19 @@ import java.util.Set;
* @contact chenyan@afanticar.com
* @contact chenyan@afanticar.com
* @since 2023/4/26/026
* @since 2023/4/26/026
*/
*/
@Component
@Slf4j
@Slf4j
@Setter
@Component
@ConfigurationProperties
(
prefix
=
"ignored"
)
public
class
TokenInterceptor
implements
HandlerInterceptor
{
public
class
TokenInterceptor
implements
HandlerInterceptor
{
@Value
(
"#{'${ignored.uri}'.split(',')}"
)
private
Set
<
String
>
uris
;
private
Set
<
String
>
ignoredUris
;
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
String
requestUri
=
request
.
getRequestURI
();
String
requestUri
=
request
.
getRequestURI
();
if
(
ignoredUris
.
contains
(
requestUri
))
{
log
.
info
(
"请求uri"
+
requestUri
);
if
(
uris
.
contains
(
requestUri
))
{
return
true
;
return
true
;
}
}
String
token
=
request
.
getHeader
(
"authorization"
);
String
token
=
request
.
getHeader
(
"authorization"
);
...
...
src/main/java/com/afanticar/afantiopenapi/controller/CommonDataController.java
View file @
9fcf6dd4
...
@@ -59,7 +59,7 @@ public class CommonDataController extends BaseController {
...
@@ -59,7 +59,7 @@ public class CommonDataController extends BaseController {
@GetMapping
(
"/activity"
)
@GetMapping
(
"/activity"
)
public
BaseResponse
<
BasePageVO
<
ActivityInfoVO
>>
getActionData
(
HttpServletRequest
request
,
@Max
(
value
=
500
,
message
=
"单页数据page_size过大"
)
@RequestParam
(
name
=
"page_size"
,
defaultValue
=
"100"
,
required
=
false
)
Integer
pageSize
,
public
BaseResponse
<
BasePageVO
<
ActivityInfoVO
>>
getActionData
(
HttpServletRequest
request
,
@Max
(
value
=
500
,
message
=
"单页数据page_size过大"
)
@RequestParam
(
name
=
"page_size"
,
defaultValue
=
"100"
,
required
=
false
)
Integer
pageSize
,
@RequestParam
(
name
=
"current_page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
pageNum
)
{
@RequestParam
(
name
=
"current_page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
pageNum
)
{
BaseResponse
check
=
baseService
.
baseLimit
(
request
,
dateType
,
limit
,
limitPeriod
);
BaseResponse
check
=
baseService
.
baseLimit
(
dateType
,
limit
,
limitPeriod
);
if
(
check
!=
null
)
{
if
(
check
!=
null
)
{
return
check
;
return
check
;
}
}
...
@@ -70,7 +70,7 @@ public class CommonDataController extends BaseController {
...
@@ -70,7 +70,7 @@ public class CommonDataController extends BaseController {
@ApiOperation
(
value
=
"获取token"
,
notes
=
"token数据"
,
produces
=
"application/json"
)
@ApiOperation
(
value
=
"获取token"
,
notes
=
"token数据"
,
produces
=
"application/json"
)
@PostMapping
(
"/token"
)
@PostMapping
(
"/token"
)
public
BaseResponse
<
TokenVO
>
getToken
(
@RequestBody
@Valid
TokenDTO
dto
)
{
public
BaseResponse
<
TokenVO
>
getToken
(
@RequestBody
@Valid
TokenDTO
dto
)
{
BaseResponse
check
=
baseService
.
baseLimit
(
null
,
dateType
,
limit
,
limitPeriod
);
BaseResponse
check
=
baseService
.
baseLimit
(
dateType
,
limit
,
limitPeriod
);
if
(
check
!=
null
)
{
if
(
check
!=
null
)
{
return
check
;
return
check
;
}
}
...
...
src/main/java/com/afanticar/afantiopenapi/controller/FawOpenController.java
View file @
9fcf6dd4
...
@@ -67,6 +67,7 @@ public class FawOpenController extends BaseController {
...
@@ -67,6 +67,7 @@ public class FawOpenController extends BaseController {
@RequestParam
(
name
=
"publish_date_start"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateStart
,
@RequestParam
(
name
=
"publish_date_start"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateStart
,
@RequestParam
(
name
=
"publish_date_end"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateEnd
,
@RequestParam
(
name
=
"publish_date_end"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateEnd
,
@RequestParam
(
name
=
"type"
)
String
type
)
{
@RequestParam
(
name
=
"type"
)
String
type
)
{
log
.
info
(
"AAAAAAAAA:"
+
limit
);
BaseResponse
check
=
baseService
.
baseValidator
(
request
,
client
,
dataType
,
limit
,
limitPeriod
);
BaseResponse
check
=
baseService
.
baseValidator
(
request
,
client
,
dataType
,
limit
,
limitPeriod
);
if
(
check
!=
null
)
{
if
(
check
!=
null
)
{
return
check
;
return
check
;
...
...
src/main/java/com/afanticar/afantiopenapi/service/BaseService.java
View file @
9fcf6dd4
...
@@ -38,11 +38,8 @@ public class BaseService {
...
@@ -38,11 +38,8 @@ public class BaseService {
return
null
;
return
null
;
}
}
public
BaseResponse
baseLimit
(
HttpServletRequest
request
,
String
dataType
,
Integer
limit
,
Integer
limitPeriod
)
{
public
BaseResponse
baseLimit
(
String
dataType
,
Integer
limit
,
Integer
limitPeriod
)
{
String
header
=
"token"
;
String
header
=
"token"
;
if
(
request
!=
null
)
{
header
=
(
String
)
request
.
getAttribute
(
BaseController
.
header
);
}
String
fawKey
=
String
.
format
(
"%s:%s:limit"
,
dataType
,
header
);
String
fawKey
=
String
.
format
(
"%s:%s:limit"
,
dataType
,
header
);
RRateLimiter
rateLimiter
=
redissonClient
.
getRateLimiter
(
fawKey
);
RRateLimiter
rateLimiter
=
redissonClient
.
getRateLimiter
(
fawKey
);
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
limit
,
limitPeriod
,
RateIntervalUnit
.
SECONDS
);
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
limit
,
limitPeriod
,
RateIntervalUnit
.
SECONDS
);
...
...
src/main/resources/bootstrap.yml
View file @
9fcf6dd4
...
@@ -34,16 +34,23 @@ spring:
...
@@ -34,16 +34,23 @@ spring:
access-key-property
:
spring.rocket-mq.accessKey
access-key-property
:
spring.rocket-mq.accessKey
secret-key-property
:
spring.rocket-mq.secretKey
secret-key-property
:
spring.rocket-mq.secretKey
# adb链接
# adb链接
generic
:
kv
:
enabled
:
tru
e
enabled
:
fals
e
backend
:
${spring.profiles.active}
backend
:
${spring.profiles.active}
default-context
:
etladb
default-context
:
etladb
database
:
databases
:
master
:
enabled
:
true
enabled
:
true
backend
:
${spring.profiles.active}db
backend
:
${spring.profiles.active}db
role
:
app-role
role
:
app-role
username-property
:
spring.datasource.dynamic.datasource.master.username
username-property
:
spring.datasource.dynamic.datasource.master.username
password-property
:
spring.datasource.dynamic.datasource.master.password
password-property
:
spring.datasource.dynamic.datasource.master.password
tmp
:
enabled
:
true
backend
:
${spring.profiles.active}db
role
:
external-role
username-property
:
spring.datasource.dynamic.datasource.tmp.username
password-property
:
spring.datasource.dynamic.datasource.tmp.password
#
#
#
#
...
...
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