fix(kbbinding): 生产保存重排待入库并按环境配对
build / build (push) Successful in 2m20s

- 生产页保存对内/对外库时,在同一事务内把还没上传、原本瞄准旧生产库的待入库项改指向新库,并在保存提示里回报迁移条数;执行已开始的项目标保持冻结。
- 重排改为「上一次生效目标 → 新目标」成对过滤:测试与生产共用 test_publications,测试侧保存不再带走瞄准生产库的待入库(验收附带发现)。
- 用例补生产重排、测试侧保存不误搬生产作业、生产保存不动测试作业三组断言。
This commit is contained in:
狐友 GXXP & LEN
2026-11-22 23:31:41 +08:00
committed by 姚章浩
parent 768ad53fe2
commit e892bfdd48
7 changed files with 201 additions and 59 deletions
+10 -2
View File
@@ -17,7 +17,7 @@ type RoutingBindingStore interface {
SaveRoutingKBBindings(context.Context, string, string, string) error
// SaveRoutingKBBindingsWithReplan also re-points 待入库 publications that
// were still waiting for the previous knowledge base (same transaction).
SaveRoutingKBBindingsWithReplan(ctx context.Context, internalID, externalID, effectiveInternal, effectiveExternal, updatedBy string, now time.Time) (postgresstore.RoutingBindingReplanResult, error)
SaveRoutingKBBindingsWithReplan(ctx context.Context, save postgresstore.RoutingBindingSave, now time.Time) (postgresstore.RoutingBindingReplanResult, error)
}
// KnowledgeBaseLister enumerates candidate knowledge bases in the connected
@@ -196,6 +196,9 @@ func (config Config) handleSaveRoutingBindings(w http.ResponseWriter, r *http.Re
// The saved binding re-routes FUTURE annotations; pending 待入库 items that
// have never been uploaded are re-pointed in the same transaction, otherwise
// they would keep aiming at the previous (possibly removed) knowledge base.
// Only items aimed at the PREVIOUS effective target of this side move, so a
// test-side save cannot carry off production-side pending work.
previousInternal, previousExternal := config.effectiveRoutingTargets(r.Context())
effectiveInternal := internal
if effectiveInternal == "" {
effectiveInternal = config.InternalRoutingKnowledgeBaseID
@@ -204,7 +207,12 @@ func (config Config) handleSaveRoutingBindings(w http.ResponseWriter, r *http.Re
if effectiveExternal == "" {
effectiveExternal = config.ExternalRoutingKnowledgeBaseID
}
replan, err := config.RoutingBindings.SaveRoutingKBBindingsWithReplan(r.Context(), internal, external, effectiveInternal, effectiveExternal, actorFor(r), config.Now().UTC())
replan, err := config.RoutingBindings.SaveRoutingKBBindingsWithReplan(r.Context(), postgresstore.RoutingBindingSave{
InternalID: internal, ExternalID: external,
Previous: postgresstore.EffectiveKBIDs{Internal: previousInternal, External: previousExternal},
Effective: postgresstore.EffectiveKBIDs{Internal: effectiveInternal, External: effectiveExternal},
UpdatedBy: actorFor(r),
}, config.Now().UTC())
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": "could not save routing bindings"})
return