Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 76acda87
authored
May 14, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:埋点
1 parent
0b8781c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
aus-api/src/main/java/com/glsx/usedcar/web/api/event/EventTrackingController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/event/EventTrackingController.java
0 → 100644
View file @
76acda8
package
com
.
glsx
.
usedcar
.
web
.
api
.
event
;
import
cn.hutool.core.util.StrUtil
;
import
com.glsx.usedcar.enums.event.EventSourceEnum
;
import
com.glsx.usedcar.module.event.service.EventTrackingService
;
import
com.glsx.usedcar.module.event.vo.EventTrackingBatchSaveVO
;
import
com.glsx.usedcar.module.security.entity.User
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.summerframework.core.exception.BusinessCodeException
;
/**
* 埋点事件控制器
*
* @author yangwei
* @version 1.0
* @since 2026/04/07 21:12
*/
@Slf4j
@RestController
@RequestMapping
(
"/rest/eventTracking"
)
@RequiredArgsConstructor
@Tag
(
name
=
"埋点事件控制器"
,
description
=
"埋点事件控制器"
)
public
class
EventTrackingController
{
private
final
EventTrackingService
eventTrackingService
;
/**
* 批量保存埋点事件
*
* @param vo 请求体(包含事件列表、业务主键、扩展参数)
* @param authentication 当前登录用户
* @return 操作结果
*/
@PostMapping
(
"/batchSave"
)
@Operation
(
summary
=
"批量保存埋点事件"
,
description
=
"前端批量上报用户行为埋点事件,支持同时携带业务主键和扩展参数"
)
public
BaseResp
<
Void
>
batchSave
(
@Valid
@RequestBody
EventTrackingBatchSaveVO
vo
,
Authentication
authentication
)
{
log
.
info
(
"【接口请求】批量保存埋点事件,操作人={},事件数量={}"
,
getUserName
(
authentication
),
vo
.
getEvents
()
==
null
?
0
:
vo
.
getEvents
().
size
());
try
{
User
user
=
(
User
)
authentication
.
getPrincipal
();
eventTrackingService
.
batchSave
(
vo
,
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
EventSourceEnum
.
API
.
getSource
());
return
BaseResp
.
success
();
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】批量保存埋点事件失败!操作人={},业务异常!"
,
getUserName
(
authentication
),
be
);
return
BaseResp
.
fail
(
StrUtil
.
toString
(
be
.
getCode
()),
be
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】批量保存埋点事件失败!操作人={},系统异常!"
,
getUserName
(
authentication
),
e
);
return
BaseResp
.
fail
(
"系统异常: "
+
e
.
getMessage
());
}
}
private
String
getUserName
(
Authentication
authentication
)
{
try
{
return
authentication
!=
null
?
((
User
)
authentication
.
getPrincipal
()).
getUserName
()
:
"未知用户"
;
}
catch
(
Exception
e
)
{
return
"未知用户"
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment