image: 模拟素材

This commit is contained in:
zerosaturation 2026-05-08 11:31:57 +08:00
parent 37b9652006
commit 47c556abc0
5 changed files with 16 additions and 4 deletions

View File

@ -218,12 +218,24 @@ func (r *galleryRepository) GetExhibitionsByUser(userID, starID int64) ([]*model
return exhibitions, err
}
// CreateExhibition 创建展品展示记录
// CreateExhibition 创建展品展示记录(支持软删除后重新展出)
// asset_id 唯一索引冲突时:若旧记录已软删除则物理删除后重新插入;否则报错
func (r *galleryRepository) CreateExhibition(exhibition *models.Exhibition) error {
now := time.Now().UnixMilli()
exhibition.CreatedAt = now
exhibition.UpdatedAt = now
return r.db.Create(exhibition).Error
exhibition.DeletedAt = nil
// 在事务中:先物理删除已软删除的旧记录,再插入新记录
return r.db.Transaction(func(tx *gorm.DB) error {
if err := tx.Exec(`
DELETE FROM exhibitions
WHERE asset_id = ? AND deleted_at IS NOT NULL
`, exhibition.AssetID).Error; err != nil {
return err
}
return tx.Create(exhibition).Error
})
}
// DeleteExhibition 软删除展品展示记录根据ID

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

View File

@ -1,7 +1,7 @@
// API 基础配置
const baseURL = 'http://101.132.250.62:8080'
// const baseURL = 'http://101.132.250.62:8080'
// const baseURL = 'http://192.168.110.60:8080'
// const baseURL = 'http://localhost:8080'
const baseURL = 'http://localhost:8080'
// 是否使用模拟数据(开发调试时设为 true后端API准备好后改为 false
const USE_MOCK_API = false