更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+2 -22
View File
@@ -18,7 +18,6 @@ const (
oplogReqBodyKey = "__oplog_req_body"
)
// BeginOperationLog 在 BeforeRouter 采集请求信息
func BeginOperationLog(ctx *context.Context) {
url := ctx.Input.URL()
method := ctx.Input.Method()
@@ -26,7 +25,6 @@ func BeginOperationLog(ctx *context.Context) {
return
}
// 解析用户信息(直接从 header 解析,不依赖 JWT 中间件设置的 context)
var uid uint64
var tid *uint64
if auth := ctx.Request.Header.Get("Authorization"); auth != "" {
@@ -42,13 +40,10 @@ func BeginOperationLog(ctx *context.Context) {
}
}
// 匿名读请求不算操作:官网页面浏览和公开接口每次访问都落库,
// 审计表会被 uid=0/module=unknown/action=查询 的流水淹掉。写操作仍照常记录。
if method == "GET" && uid == 0 {
return
}
// 采集请求信息
reqBody := ""
if rb := ctx.Input.RequestBody; len(rb) > 0 {
reqBody = truncateString(maskSensitive(string(rb)), 5000)
@@ -61,9 +56,8 @@ func BeginOperationLog(ctx *context.Context) {
ip := truncateString(ctx.Input.IP(), 50)
userAgent := truncateString(ctx.Request.Header.Get("User-Agent"), 500)
// 异步写入数据库
go func() {
time.Sleep(100 * time.Millisecond) // 等待响应完成
time.Sleep(100 * time.Millisecond)
logRow := &models.SystemOperationLog{
Tid: tid,
UserID: uid,
@@ -90,15 +84,11 @@ func strPtr(s string) *string {
return &s
}
// isMobileAppPath 判断是否属于移动端(/api/)功能接口前缀集合。
// 登录器公开接口(/api/getcard、/api/cursor/*、/api/softwareupgrade/*、
// /api/schedule/reminder/ack 等)不在此集合内。
func isMobileAppPath(url string) bool {
mobilePrefixes := []string{
"/api/oa/", "/api/notebook/", "/api/currentUser",
"/api/activity/", "/api/home", "/api/quick-menus",
}
// /api/schedule 需区分:/api/schedule/reminder/ack 属登录器,排除
if strings.HasPrefix(url, "/api/schedule") {
return !strings.HasPrefix(url, "/api/schedule/reminder/ack")
}
@@ -110,7 +100,6 @@ func isMobileAppPath(url string) bool {
return false
}
// WriteDeleteLog 控制器删除后直接写操作日志(带标题)
func WriteDeleteLog(userID uint64, tid int, module, title string) {
moduleCN := oplogModuleLabel(module)
desc := fmt.Sprintf("您删除了%s:【%s】", moduleCN, truncateString(title, 20))
@@ -140,7 +129,6 @@ func oplogModuleLabel(m string) string {
}
}
// FinishOperationLog 在 FinishRouter 统一落库到 yz_system_operation_log
func FinishOperationLog(ctx *context.Context) {
url := ctx.Input.URL()
method := ctx.Input.Method()
@@ -159,7 +147,6 @@ func FinishOperationLog(ctx *context.Context) {
uid := parseUint64FromCtx(ctx.Input.GetData("userId"))
tidVal := parseUint64FromCtx(ctx.Input.GetData("tenantId"))
// 如果 context 中没有用户信息,尝试从 Authorization header 解析
if uid == 0 {
if auth := ctx.Request.Header.Get("Authorization"); auth != "" {
parts := strings.SplitN(auth, " ", 2)
@@ -291,33 +278,27 @@ func shouldSkipLogging(method, url string) bool {
}
}
// 高频噪声接口:默认跳过(可按需再扩充)
if method == "GET" {
noisyExact := map[string]bool{
"/platform/currentUser": true,
"/platform/allmenu": true,
"/platform/getOpenVerify": true, // 若未来改名/迁移可再调整
"/platform/getOpenVerify": true,
}
if noisyExact[url] {
return true
}
// 菜单详情/列表类:频率高且多为前端路由加载
if strings.HasPrefix(url, "/platform/menu/") {
return true
}
// 登录页极验配置轮询/获取(不影响关键业务)
if strings.HasPrefix(url, "/platform/login/getGeetest") || strings.HasPrefix(url, "/platform/login/getOpenVerify") {
return true
}
// 客户端高频版本检查
if strings.HasPrefix(url, "/api/softwareupgrade/check") {
return true
}
// 工作台天气实况(代理外部数据源,非业务写操作)
if strings.HasPrefix(url, "/backend/weather/") {
return true
}
// 移动端(已并入 /api/)读接口跳过(只记录写操作:POST/PUT/DELETE)
if isMobileAppPath(url) {
return true
}
@@ -353,7 +334,6 @@ func truncateString(s string, maxLen int) string {
}
func maskSensitive(s string) string {
// 尝试 JSON 脱敏(失败则返回原文)
var obj interface{}
if err := json.Unmarshal([]byte(s), &obj); err != nil {
return s