feat: 添加租户ID字段并重构文件上传逻辑
This commit is contained in:
@@ -173,12 +173,25 @@ func insertHook(ctx context.Context, in *gdb.HookInsertInput) (result sql.Result
|
||||
if _, ok := in.Data[i]["id"]; ok {
|
||||
in.Data[i]["id"] = node.Generate().Int64()
|
||||
}
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
if _, ok := in.Data[i]["creator"]; ok {
|
||||
in.Data[i]["creator"] = userInfo.UserName
|
||||
if _, ok := in.Data[i]["tenant_id"]; ok {
|
||||
if !g.IsEmpty(userInfo.TenantId) {
|
||||
in.Data[i]["tenant_id"] = userInfo.TenantId
|
||||
} else {
|
||||
return nil, fmt.Errorf("tenantId cannot be empty")
|
||||
}
|
||||
if _, ok := in.Data[i]["updater"]; ok {
|
||||
}
|
||||
if _, ok := in.Data[i]["creator"]; ok {
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
in.Data[i]["creator"] = userInfo.UserName
|
||||
} else {
|
||||
return nil, fmt.Errorf("user info cannot be empty")
|
||||
}
|
||||
}
|
||||
if _, ok := in.Data[i]["updater"]; ok {
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
in.Data[i]["updater"] = userInfo.UserName
|
||||
} else {
|
||||
return nil, fmt.Errorf("user info cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,16 +220,22 @@ func updateHook(ctx context.Context, in *gdb.HookUpdateInput) (result sql.Result
|
||||
|
||||
switch data := in.Data.(type) {
|
||||
case gdb.Map:
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
if _, ok := data["updater"]; ok {
|
||||
if _, ok := data["updater"]; ok {
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
data["updater"] = userInfo.UserName
|
||||
} else {
|
||||
return nil, fmt.Errorf("user info cannot be empty")
|
||||
}
|
||||
}
|
||||
case gdb.List:
|
||||
for i := range data {
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
if _, ok := data[i]["updater"]; ok {
|
||||
data[i]["updater"] = userInfo.UserName
|
||||
if !g.IsEmpty(userInfo.UserName) {
|
||||
data[i]["updater"] = userInfo.UserName
|
||||
} else {
|
||||
return nil, fmt.Errorf("user info cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user