fix: Z35 map Chinese display names to stable physical DB names
Keep Chinese on Binding for UI; Agents use user_{id} or db{hash}; sanitize on attach/heal/publish.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"aijianzhan/platform/internal/agentstore"
|
||||
"aijianzhan/platform/internal/dbsync"
|
||||
"aijianzhan/platform/internal/schema"
|
||||
"aijianzhan/platform/internal/svc"
|
||||
"aijianzhan/platform/internal/types"
|
||||
"aijianzhan/platform/internal/userstore"
|
||||
@@ -19,6 +20,9 @@ func fillAgentSyncOnToken(resp *types.TokenResp, acc *agentstore.Account) {
|
||||
resp.ChannelID = strings.TrimSpace(acc.ChannelID)
|
||||
resp.OnlineDBID = strings.TrimSpace(acc.OnlineDBID)
|
||||
resp.DatabaseName = strings.TrimSpace(acc.DatabaseName)
|
||||
if resp.DatabaseName != "" && !schema.ValidDBName(resp.DatabaseName) {
|
||||
resp.DatabaseName = ""
|
||||
}
|
||||
resp.SyncBound = resp.ChannelID != "" && resp.OnlineDBID != ""
|
||||
}
|
||||
|
||||
@@ -40,9 +44,10 @@ func fillUserSyncOnToken(svcCtx *svc.ServiceContext, resp *types.TokenResp, u *u
|
||||
}
|
||||
resp.ChannelID = strings.TrimSpace(b.ChannelID)
|
||||
resp.OnlineDBID = strings.TrimSpace(b.OnlineDBID)
|
||||
// Z35:database_name 仅物理库名;勿把中文 DisplayName 填进该字段
|
||||
resp.DatabaseName = strings.TrimSpace(b.DatabaseName)
|
||||
if resp.DatabaseName == "" {
|
||||
resp.DatabaseName = strings.TrimSpace(b.DisplayName)
|
||||
if resp.DatabaseName != "" && !schema.ValidDBName(resp.DatabaseName) {
|
||||
resp.DatabaseName = ""
|
||||
}
|
||||
resp.SyncBound = resp.ChannelID != "" && resp.OnlineDBID != ""
|
||||
}
|
||||
@@ -92,10 +97,7 @@ func (l *AgentAdminLogic) ensureAgentSyncBind(acc *agentstore.Account) (*agentst
|
||||
if online == "" {
|
||||
online = dbsync.ResolveOnlineDBID("", ch.ID)
|
||||
}
|
||||
dbName := strings.TrimSpace(updated.DatabaseName)
|
||||
if dbName == "" {
|
||||
dbName = fmt.Sprintf("agent_%d", updated.AgentID)
|
||||
}
|
||||
dbName := schema.SafeSyncDatabaseName(updated.DatabaseName, updated.AgentID, 0)
|
||||
updated, err = st.AttachSyncBind(l.ctx, updated.AgentID, updated.TenantID, ch.ID, online, dbName, updated.Status == agentstore.StatusActive || updated.Status == "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user