fix: 添加分类名称唯一约束,防止重复名称

This commit is contained in:
2026-05-25 17:38:11 +08:00
parent 4b03e593bc
commit 2cb86d1b38
6 changed files with 249 additions and 47 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ import (
type Category struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100;not null" json:"name"`
Name string `gorm:"size:100;not null;uniqueIndex" json:"name"`
Description string `json:"description"`
ParentID *uint `json:"parent_id"`
MinAmount *float64 `json:"min_amount"`