feat(publish): 实体键唯一索引,保证一个实体一行
This commit is contained in:
@ -294,7 +294,7 @@ func (r *ingestRepository) ReuseRejectedRunway(ctx context.Context, id uint32, r
|
||||
// WHERE 带 status=rejected 守卫:状态是读阶段拿到的,而写库发生在整批图片下载/上传之后
|
||||
// (可能数十秒窗口)。若无条件覆盖,期间已被改成 published 的行会被置回 pending,
|
||||
// 等于把已发布内容从公开视图上撤下。
|
||||
upd := tx.Model(&model.BrandRunway{}).Where("id = ? AND status = ?", id, model.StatusRejected)
|
||||
upd := tx.Model(&model.BrandRunway{}).Where("id = ? AND status = ? AND is_deleted = 0", id, model.StatusRejected)
|
||||
if uErr := upd.Updates(map[string]any{
|
||||
"title_en": rw.TitleEn,
|
||||
"title_cn": rw.TitleCn,
|
||||
@ -382,7 +382,7 @@ func (r *ingestRepository) ReuseRejectedStreetSnap(ctx context.Context, id uint3
|
||||
now := uint32(time.Now().Unix())
|
||||
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
// 同 runway:带 status=rejected 守卫 + 行数校验,避免把期间已发布的记录撤下公开视图。
|
||||
upd := tx.Model(&model.StreetSnap{}).Where("id = ? AND status = ?", id, model.StatusRejected)
|
||||
upd := tx.Model(&model.StreetSnap{}).Where("id = ? AND status = ? AND is_deleted = 0", id, model.StatusRejected)
|
||||
if uErr := upd.Updates(map[string]any{
|
||||
"title": snap.Title,
|
||||
"year": snap.Year,
|
||||
|
||||
Reference in New Issue
Block a user