修复需要从前端传新增人修改人的问题

This commit is contained in:
2026-06-12 09:51:09 +08:00
parent 9dc12634f5
commit e5133eea34
8 changed files with 74 additions and 37 deletions

16
utils/context_utils.go Normal file
View File

@@ -0,0 +1,16 @@
package utils
import (
"context"
"gitea.redpowerfuture.com/red-future/common/beans"
)
// GetCurrentUser 从 context 中获取当前登录用户
// 如果未找到用户信息,返回默认 "unknown" 用户名
func GetCurrentUser(ctx context.Context) string {
if user, ok := ctx.Value("user").(*beans.User); ok && user != nil && user.UserName != "" {
return user.UserName
}
return "unknown"
}