chore: init bj_power monorepo (dashboard/mes/wms/wms_client/workstation), clear subproject git metadata and align naming to folder names

This commit is contained in:
SunYF
2026-08-27 10:09:54 +08:00
commit 1f0ee844a4
408 changed files with 102201 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package audit
// 管����作审计公共能力�
//
// �责�
// 1. OperatorFromCtx �HTTP 请求 context ��当�登录�作人(uid �用户�)�
// �logic 层记录人工�作时�带�
//
// �作人缺失兜底:"系统"(自动化触�,�人工�作)�
import (
"context"
"fmt"
xhttp "bj_power_mes/common/httpx"
"bj_power_mes/ent"
"bj_power_mes/ent/user"
)
// OperatorFromCtx 从请�context ���作人用户��
// 无登录上下文(自动触�)返回 "系统";查库失败兜�"用户#<id>",��审计�丢�作人�
func OperatorFromCtx(ctx context.Context, entClient *ent.Client) string {
if entClient == nil {
return "系统"
}
uid := xhttp.GetUidFromCtx(ctx)
if uid <= 0 {
return "系统"
}
u, err := entClient.User.Query().
Where(user.IDEQ(int(uid))).
Only(ctx)
if err != nil {
return fmt.Sprintf("用户#%d", uid)
}
return u.Username
}