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

+28
View File
@@ -0,0 +1,28 @@
package model
import "strings"
// NormalizeAssetCategory keeps persisted and synced assets inside the current
// five-category contract while preserving the intended meaning of legacy data.
func NormalizeAssetCategory(value AssetCategory, kind string) AssetCategory {
switch strings.ToLower(strings.TrimSpace(string(value))) {
case string(AssetCategoryCharacter):
return AssetCategoryCharacter
case string(AssetCategoryEnvironment):
return AssetCategoryEnvironment
case string(AssetCategoryProp), "wardrobe", "weapon", "accessory":
return AssetCategoryProp
case string(AssetCategoryMaterial), "style":
return AssetCategoryMaterial
case string(AssetCategoryOther):
return AssetCategoryOther
}
switch strings.ToLower(strings.TrimSpace(kind)) {
case "entity":
return AssetCategoryCharacter
case "image", "video", "audio", "model":
return AssetCategoryMaterial
default:
return AssetCategoryOther
}
}
+1 -3
View File
@@ -144,10 +144,8 @@ const (
AssetCategoryCharacter AssetCategory = "character"
AssetCategoryEnvironment AssetCategory = "environment"
AssetCategoryWardrobe AssetCategory = "wardrobe"
AssetCategoryProp AssetCategory = "prop"
AssetCategoryWeapon AssetCategory = "weapon"
AssetCategoryStyle AssetCategory = "style"
AssetCategoryMaterial AssetCategory = "material"
AssetCategoryOther AssetCategory = "other"
AssetVersionStatusDraft AssetVersionStatus = "draft"
+2
View File
@@ -112,8 +112,10 @@ type ProjectAssetCandidate struct {
UnitID string `json:"unitId,omitempty" gorm:"index;size:36;index:idx_project_asset_candidates_project_unit_status,priority:2"`
ShotID string `json:"shotId,omitempty" gorm:"index;size:36"`
Name string `json:"name" gorm:"size:240"`
NameKey string `json:"-" gorm:"index;size:240"`
Category AssetCategory `json:"category" gorm:"index;size:32;index:idx_project_asset_candidates_project_status_category,priority:3"`
Status string `json:"status" gorm:"index;size:32;index:idx_project_asset_candidates_project_unit_status,priority:3;index:idx_project_asset_candidates_project_status_category,priority:2"`
Source string `json:"source,omitempty" gorm:"index;size:48"`
DetailsJSON string `json:"detailsJson" gorm:"type:text"`
ResolvedAssetID string `json:"resolvedAssetId,omitempty" gorm:"index;size:80"`
CreatedAt time.Time `json:"createdAt"`
@@ -0,0 +1,17 @@
package model
import (
"strings"
"unicode"
)
// AssetCandidateNameKey removes presentation differences from a candidate name.
// The key is only an identity guard; the original name remains the display value.
func AssetCandidateNameKey(value string) string {
return strings.Map(func(r rune) rune {
if unicode.IsLetter(r) || unicode.IsNumber(r) {
return unicode.ToLower(r)
}
return -1
}, strings.TrimSpace(value))
}