修复需要从前端传新增人修改人的问题
This commit is contained in:
16
utils/context_utils.go
Normal file
16
utils/context_utils.go
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user