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
0559a604
Commit
0559a604
authored
Sep 12, 2023
by
刘昳巡
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develo-otel' into 'develop'
Develo otel See merge request
!36
parents
57648af2
115cc9c2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
45 deletions
+99
-45
Dockerfile
Dockerfile
+1
-0
pom.xml
pom.xml
+10
-5
FawOpenController.java
...afanticar/afantiopenapi/controller/FawOpenController.java
+40
-15
FawOpenService.java
...a/com/afanticar/afantiopenapi/service/FawOpenService.java
+9
-0
logback-spring.xml
src/main/resources/logback-spring.xml
+39
-25
No files found.
Dockerfile
View file @
0559a604
FROM
registry-vpc.cn-hangzhou.aliyuncs.com/afanticar/base:ppjava8
VOLUME
/tmp
ENV
PROJECT="afanti-open-api"
...
...
pom.xml
View file @
0559a604
...
...
@@ -161,11 +161,6 @@
</dependency>
<!-- 运维类依赖-->
<dependency>
<groupId>
com.afanticar
</groupId>
<artifactId>
ops-java-common
</artifactId>
<version>
0.0.1-Release
</version>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-prometheus
</artifactId>
...
...
@@ -194,6 +189,16 @@
<artifactId>
spring-vault-core
</artifactId>
<version>
2.3.2
</version>
</dependency>
<dependency>
<groupId>
io.opentelemetry.instrumentation
</groupId>
<artifactId>
opentelemetry-logback-mdc-1.0
</artifactId>
<version>
1.29.0-alpha
</version>
</dependency>
<dependency>
<groupId>
com.afanticar
</groupId>
<artifactId>
ops-java-common
</artifactId>
<version>
1.0.1-snapshots
</version>
</dependency>
<!-- 运维类依赖-->
<dependency>
...
...
src/main/java/com/afanticar/afantiopenapi/controller/FawOpenController.java
View file @
0559a604
package
com
.
afanticar
.
afantiopenapi
.
controller
;
import
cn.hutool.core.date.DateException
;
import
cn.hutool.core.date.DateUtil
;
import
com.afanticar.afantiopenapi.model.BaseResponse
;
import
com.afanticar.afantiopenapi.model.vo.BasePageVO
;
import
com.afanticar.afantiopenapi.model.vo.HongqiAwemeIncentiveVO
;
...
...
@@ -13,7 +15,6 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
...
...
@@ -53,10 +55,12 @@ public class FawOpenController extends BaseController {
static
String
dataType
=
"faw"
;
static
String
monthly
=
"monthly"
,
quarter
=
"quarter"
;
@ApiOperation
(
value
=
"视频数据信息"
,
notes
=
"视频数据"
,
produces
=
"application/json"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"publish_date_start"
,
value
=
"开始时间,格式:2023-02-01"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Date"
),
@ApiImplicitParam
(
name
=
"publish_date_end"
,
value
=
"结束时间,格式:2023-03-01"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Date"
),
@ApiImplicitParam
(
name
=
"publish_date_start"
,
value
=
"开始时间,格式:2023-02-01
00:00:00
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Date"
),
@ApiImplicitParam
(
name
=
"publish_date_end"
,
value
=
"结束时间,格式:2023-03-01
00:00:00
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Date"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"数据类型,monthly-月度表,quarter-季度表"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"current_page"
,
value
=
"页码"
,
paramType
=
"path"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"page_size"
,
value
=
"页数"
,
paramType
=
"path"
,
dataType
=
"Integer"
),
...
...
@@ -64,13 +68,17 @@ public class FawOpenController extends BaseController {
@GetMapping
(
"/aweme"
)
public
BaseResponse
<
BasePageVO
<
HongqiAwemeIncentiveVO
>>
getAwemeData
(
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
=
"publish_date_start"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateStart
,
@RequestParam
(
name
=
"publish_date_end"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateEnd
,
@RequestParam
(
name
=
"type"
)
String
type
)
{
@NotNull
(
message
=
"publish_date_start不能为空"
)
@RequestParam
(
name
=
"publish_date_start"
,
required
=
false
)
String
publishDateStartStr
,
@NotNull
(
message
=
"publish_date_end不能为空"
)
@RequestParam
(
name
=
"publish_date_end"
,
required
=
false
)
String
publishDateEndStr
,
@NotNull
(
message
=
"type不能为空"
)
@RequestParam
(
name
=
"type"
,
required
=
false
)
String
type
)
{
Date
publishDateEnd
=
parseDate
(
publishDateEndStr
),
publishDateStart
=
parseDate
(
publishDateStartStr
);
if
(
publishDateEnd
==
null
||
publishDateStart
==
null
)
{
return
error
(
"90001"
,
"publish_date_end或publish_date_start时间格式不合法"
);
}
log
.
info
(
"AAAAAAAAA:"
+
limit
);
BaseResponse
check
=
baseService
.
baseValidator
(
request
,
client
,
dataType
,
limit
,
limitPerio
d
);
if
(
check
!=
null
)
{
return
check
;
publishDateEnd
=
endTime
(
publishDateEn
d
);
if
(
!
type
.
equals
(
quarter
)
&&
!
type
.
equals
(
monthly
)
)
{
return
error
(
"90001"
,
"type传参异常,未开放数据类型"
)
;
}
return
success
(
fawOpenService
.
awemes
(
publishDateStart
,
publishDateEnd
,
type
,
pageNum
,
pageSize
));
}
...
...
@@ -86,14 +94,31 @@ public class FawOpenController extends BaseController {
@GetMapping
(
"/live"
)
public
BaseResponse
<
BasePageVO
<
HongqiLiveIncentiveVO
>>
getLiveData
(
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
=
"publish_date_start"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateStart
,
@RequestParam
(
name
=
"publish_date_end"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
Date
publishDateEnd
,
@RequestParam
(
name
=
"type"
)
String
type
)
{
BaseResponse
check
=
baseService
.
baseValidator
(
request
,
client
,
dataType
,
limit
,
limitPeriod
);
if
(
check
!=
null
)
{
return
check
;
@NotNull
(
message
=
"publish_date_start不能为空"
)
@RequestParam
(
name
=
"publish_date_start"
,
required
=
false
)
String
publishDateStartStr
,
@NotNull
(
message
=
"publish_date_end不能为空"
)
@RequestParam
(
name
=
"publish_date_end"
,
required
=
false
)
String
publishDateEndStr
,
@NotNull
(
message
=
"type不能为空"
)
@RequestParam
(
name
=
"type"
,
required
=
false
)
String
type
)
{
Date
publishDateEnd
=
parseDate
(
publishDateEndStr
),
publishDateStart
=
parseDate
(
publishDateStartStr
);
if
(
publishDateEnd
==
null
||
publishDateStart
==
null
)
{
return
error
(
"90001"
,
"publish_date_end或者publish_date_start时间格式不合法"
);
}
publishDateEnd
=
endTime
(
publishDateEnd
);
if
(!
type
.
equals
(
quarter
)
&&
!
type
.
equals
(
monthly
))
{
return
error
(
"90001"
,
"type传参异常,未开放数据类型!"
);
}
return
success
(
fawOpenService
.
lives
(
publishDateStart
,
publishDateEnd
,
type
,
pageNum
,
pageSize
));
}
private
static
Date
parseDate
(
String
publishDateStr
)
{
Date
publishDate
=
null
;
try
{
publishDate
=
DateUtil
.
parse
(
publishDateStr
,
"yyyy-MM-dd"
);
}
catch
(
DateException
ignore
)
{
}
return
publishDate
;
}
private
Date
endTime
(
Date
endDate
)
{
return
DateUtil
.
endOfDay
(
endDate
);
}
}
src/main/java/com/afanticar/afantiopenapi/service/FawOpenService.java
View file @
0559a604
...
...
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
* @author chin
...
...
@@ -49,6 +50,10 @@ public class FawOpenService {
static
String
quarter
=
"quarter"
;
public
BasePageVO
<
HongqiAwemeIncentiveVO
>
awemes
(
Date
publishDateStart
,
Date
publishDateEnd
,
String
type
,
Integer
pageNum
,
Integer
pageSize
)
{
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
500L
);
}
catch
(
InterruptedException
ignored
)
{
}
PageHelper
.
orderBy
(
" publish_time DESC "
);
if
(
monthly
.
equals
(
type
))
{
IPage
<
HongqiAwemeIncentiveMonthly
>
page
=
new
Page
<>(
pageNum
,
pageSize
);
...
...
@@ -72,6 +77,10 @@ public class FawOpenService {
}
public
BasePageVO
<
HongqiLiveIncentiveVO
>
lives
(
Date
publishDateStart
,
Date
publishDateEnd
,
String
type
,
Integer
pageNum
,
Integer
pageSize
)
{
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
500L
);
}
catch
(
InterruptedException
ignored
)
{
}
PageHelper
.
orderBy
(
" publish_time DESC "
);
if
(
monthly
.
equals
(
type
))
{
IPage
<
HongqiLiveIncentiveMonthly
>
page
=
new
Page
<>(
pageNum
,
pageSize
);
...
...
src/main/resources/logback-spring.xml
View file @
0559a604
...
...
@@ -2,42 +2,56 @@
<configuration
debug=
"false"
>
<contextName>
Logback
</contextName>
<springProfile
name=
"local"
>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.core.encoder.LayoutWrappingEncoder"
>
<layout
class=
"org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout"
>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</layout>
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [TID: %X{trace_id}] [SPANID: %X{span_id}] [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</encoder>
<!-- <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">-->
<!-- <providers>-->
<!-- <pattern>-->
<!-- <omitEmptyFields>true</omitEmptyFields>-->
<!-- <pattern>-->
<!-- {-->
<!-- "timestamp": "%d{yyyy-MM-dd HH:mm:ss.SSS}",-->
<!-- "trace_id": "%X{trace_id}",-->
<!-- "span_id": "%X{span_id}",-->
<!-- "thread": "%thread",-->
<!-- "level": "%-5level",-->
<!-- "class": "%logger{36}",-->
<!-- "message": "%message"-->
<!-- }-->
<!-- </pattern>-->
<!-- </pattern>-->
<!-- </providers>-->
<!-- </encoder>-->
</appender>
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<discardingThreshold>
0
</discardingThreshold>
<queueSize>
1024
</queueSize>
<neverBlock>
true
</neverBlock>
<appender-ref
ref=
"STDOUT"
/>
<!-- Just wrap your logging appender, for example ConsoleAppender, with OpenTelemetryAppender -->
<appender
name=
"OTEL"
class=
"io.opentelemetry.instrumentation.logback.mdc.v1_0.OpenTelemetryAppender"
>
<appender-ref
ref=
"CONSOLE"
/>
</appender>
<!-- Use the wrapped "OTEL" appender instead of the original "CONSOLE" one -->
<root
level=
"INFO"
>
<appender-ref
ref=
"
ASYNC
"
/>
<appender-ref
ref=
"
OTEL
"
/>
</root>
</springProfile>
<!-- 配置spring使用的参数名 -->
<springProfile
name=
"dev,uat,pro,test,production"
>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.core.encoder.LayoutWrappingEncoder"
>
<!-- 引入skywalking日志,添加tid -->
<layout
class=
"org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout"
>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</layout>
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [TID:%X{trace_id}] [SpanID:%X{span_id}] [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</encoder>
</appender>
<!-- 配置异步输出 -->
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<discardingThreshold>
0
</discardingThreshold>
<queueSize>
1024
</queueSize>
<neverBlock>
true
</neverBlock>
<appender-ref
ref=
"STDOUT"
/>
<!-- Just wrap your logging appender, for example ConsoleAppender, with OpenTelemetryAppender -->
<appender
name=
"OTEL"
class=
"io.opentelemetry.instrumentation.logback.mdc.v1_0.OpenTelemetryAppender"
>
<appender-ref
ref=
"CONSOLE"
/>
</appender>
<!-- Use the wrapped "OTEL" appender instead of the original "CONSOLE" one -->
<root
level=
"INFO"
>
<appender-ref
ref=
"
ASYNC
"
/>
<appender-ref
ref=
"
OTEL
"
/>
</root>
</springProfile>
</configuration>
\ No newline at end of file
</configuration>
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