feat(*): 分镜与资产 - 完善五类资产、候选去重、搜索、中文镜头编号与分类整理

This commit is contained in:
ddCat committed 2026-08-31 13:16:10 +08:00
1 parent ce6e20f749
commit f548681787
53 files changed
+816 -188

No files matched your search

@@ -175,7 +175,7 @@ func (r *Repository) ProjectCanvasUnitLinksForCanvases(projectID string, canvasI
return links, err
}
func (r *Repository) ProjectAssetCandidatesPage(projectID string, page int, pageSize int, unitID string, status string, category string) ([]model.ProjectAssetCandidate, int64, error) {
func (r *Repository) ProjectAssetCandidatesPage(projectID string, page int, pageSize int, unitID string, status string, category string, queryText string) ([]model.ProjectAssetCandidate, int64, error) {
var candidates []model.ProjectAssetCandidate
var total int64
query := r.db.Model(&model.ProjectAssetCandidate{}).Where("project_id = ?", projectID)
@@ -188,6 +188,9 @@ func (r *Repository) ProjectAssetCandidatesPage(projectID string, page int, page
if value := strings.TrimSpace(category); value != "" {
query = query.Where("category = ?", value)
}
if value := strings.TrimSpace(queryText); value != "" {
query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(value)+"%")
}
if err := query.Count(&total).Error; err != nil {
return nil, 0, err
}
@@ -2041,6 +2041,11 @@ func (r *Repository) CreateProjectAssetCandidates(candidates []model.ProjectAsse
return r.db.Create(&candidates).Error
}
func (r *Repository) CreateProjectAssetCandidate(candidate *model.ProjectAssetCandidate) (bool, error) {
result := r.db.Clauses(clause.OnConflict{DoNothing: true}).Create(candidate)
return result.RowsAffected == 1, result.Error
}
// ConfirmProjectAssetCandidate 将正式资产身份、首版本、项目引用和候选状态放在同一事务中,避免出现半确认数据。
func (r *Repository) ConfirmProjectAssetCandidate(candidate *model.ProjectAssetCandidate, asset *model.Asset, version *model.AssetVersion, link *model.ProjectAssetLink, createAsset bool) error {
return r.db.Transaction(func(tx *gorm.DB) error {