批量优化
This commit is contained in:
1 parent
438145cae7
commit
c925b198d1
50 files changed
+5716
-291
No files matched your search
@@ -21,17 +21,20 @@ import (
|
||||
)
|
||||
|
||||
// syncTenantUserToAuth 把租户用户同步到统一认证中心(双写)。
|
||||
// updatePassword:身份已存在时是否允许同步密码(仅改密场景传 true;
|
||||
// 新增/编辑/绑定场景传 false,避免把身份层密码覆盖回旧值)。
|
||||
// 同步失败只记日志,不影响平台端主流程(认证中心为新增能力)。
|
||||
func syncTenantUserToAuth(row *models.SystemTenantUser) {
|
||||
func syncTenantUserToAuth(row *models.SystemTenantUser, updatePassword bool) {
|
||||
if row == nil {
|
||||
return
|
||||
}
|
||||
in := authsvc.SyncTenantUserInput{
|
||||
Tid: row.Tid,
|
||||
GroupID: row.GroupID,
|
||||
OrgID: row.OrgID,
|
||||
Status: row.Status,
|
||||
IsDefault: row.IsDefault,
|
||||
Tid: row.Tid,
|
||||
GroupID: row.GroupID,
|
||||
OrgID: row.OrgID,
|
||||
Status: row.Status,
|
||||
IsDefault: row.IsDefault,
|
||||
UpdatePassword: updatePassword,
|
||||
}
|
||||
if row.Account != nil {
|
||||
in.Account = strings.TrimSpace(*row.Account)
|
||||
@@ -293,10 +296,11 @@ func (c *PlatformTenantUserController) CreateTenantUser() {
|
||||
}
|
||||
}
|
||||
|
||||
// 双写:同步到统一认证中心(读回最新记录,确保 group_id/org_id 已落库)
|
||||
// 双写:同步到统一认证中心(读回最新记录,确保 group_id/org_id 已落库);
|
||||
// 新建身份时密码已随身份创建写入;已存在身份不覆盖密码
|
||||
var created models.SystemTenantUser
|
||||
if err := models.Orm.QueryTable(new(models.SystemTenantUser)).Filter("id", id).One(&created); err == nil {
|
||||
syncTenantUserToAuth(&created)
|
||||
if e := models.Orm.QueryTable(new(models.SystemTenantUser)).Filter("id", id).One(&created); e == nil {
|
||||
syncTenantUserToAuth(&created, false)
|
||||
}
|
||||
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "success", "data": map[string]interface{}{"id": id}}
|
||||
@@ -376,10 +380,10 @@ func (c *PlatformTenantUserController) EditTenantUser() {
|
||||
_ = services.SetDefaultTenant(p.Uid, p.Tid)
|
||||
}
|
||||
|
||||
// 双写:同步到统一认证中心
|
||||
// 双写:同步到统一认证中心(仅本次显式修改了密码时才同步密码字段)
|
||||
var updated models.SystemTenantUser
|
||||
if err := models.Orm.QueryTable(new(models.SystemTenantUser)).Filter("id", id).One(&updated); err == nil {
|
||||
syncTenantUserToAuth(&updated)
|
||||
syncTenantUserToAuth(&updated, p.Password != nil)
|
||||
}
|
||||
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "success"}
|
||||
|
||||
Reference in new issue
Block a user