做双端审批流
This commit is contained in:
1 parent
5b4dbb2b46
commit
ffaadc26ae
69 files changed
+6662
-1071
No files matched your search
@@ -60,16 +60,16 @@ func BeginOperationLog(ctx *context.Context) {
|
||||
go func() {
|
||||
time.Sleep(100 * time.Millisecond) // 等待响应完成
|
||||
logRow := &models.SystemOperationLog{
|
||||
Tid: tid,
|
||||
UserID: uid,
|
||||
Module: module,
|
||||
Action: action,
|
||||
Method: method,
|
||||
URL: truncateString(url, 255),
|
||||
IP: ip,
|
||||
UserAgent: userAgent,
|
||||
RequestData: strPtr(reqBody),
|
||||
Status: 1,
|
||||
Tid: tid,
|
||||
UserID: uid,
|
||||
Module: module,
|
||||
Action: action,
|
||||
Method: method,
|
||||
URL: truncateString(url, 255),
|
||||
IP: ip,
|
||||
UserAgent: userAgent,
|
||||
RequestData: strPtr(reqBody),
|
||||
Status: 1,
|
||||
ExecutionTime: 0,
|
||||
}
|
||||
_, err := models.Orm.Insert(logRow)
|
||||
@@ -88,20 +88,40 @@ 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")
|
||||
}
|
||||
for _, p := range mobilePrefixes {
|
||||
if strings.HasPrefix(url, p) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// WriteDeleteLog 控制器删除后直接写操作日志(带标题)
|
||||
func WriteDeleteLog(userID uint64, tid int, module, title string) {
|
||||
moduleCN := oplogModuleLabel(module)
|
||||
desc := fmt.Sprintf("您删除了%s:【%s】", moduleCN, truncateString(title, 20))
|
||||
tidVal := uint64(tid)
|
||||
logRow := &models.SystemOperationLog{
|
||||
UserID: userID,
|
||||
Tid: &tidVal,
|
||||
Module: module,
|
||||
Action: "删除",
|
||||
Method: "DELETE",
|
||||
URL: fmt.Sprintf("/app/%s", module),
|
||||
Status: 1,
|
||||
RequestData: &desc,
|
||||
UserID: userID,
|
||||
Tid: &tidVal,
|
||||
Module: module,
|
||||
Action: "删除",
|
||||
Method: "DELETE",
|
||||
URL: fmt.Sprintf("/api/%s", module),
|
||||
Status: 1,
|
||||
RequestData: &desc,
|
||||
ExecutionTime: 0,
|
||||
}
|
||||
models.Orm.Insert(logRow)
|
||||
@@ -291,12 +311,8 @@ func shouldSkipLogging(method, url string) bool {
|
||||
if strings.HasPrefix(url, "/api/softwareupgrade/check") {
|
||||
return true
|
||||
}
|
||||
// App 端读接口跳过(只记录写操作:POST/PUT/DELETE)
|
||||
if strings.HasPrefix(url, "/app/") && method == "GET" {
|
||||
return true
|
||||
}
|
||||
// App 端 DELETE 由控制器自行记录(需要标题信息)
|
||||
if strings.HasPrefix(url, "/app/") && method == "DELETE" {
|
||||
// 移动端(已并入 /api/)读接口跳过(只记录写操作:POST/PUT/DELETE)
|
||||
if isMobileAppPath(url) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user