package schema import "gorm.io/gorm" // BlocksIndex 板块索引(采用 dataset/stock 的 code 唯一约束)。 type BlocksIndex struct { gorm.Model Code string `gorm:"type:varchar(50);not null;default:'';comment:板块代码;uniqueIndex:uq_blocks_index_code" json:"code"` Name string `gorm:"type:varchar(50);not null;default:'';comment:板块名称" json:"name"` IsRecommend bool `gorm:"type:bool;not null;default:false;comment:是否推荐" json:"is_recommend"` } func (BlocksIndex) TableName() string { return "blocks_index" } // Key 板块业务主键:code。 func (b *BlocksIndex) Key() string { return b.Code } // DisplayName 展示名称:非空 name,否则回退 code。 func (b *BlocksIndex) DisplayName() string { if b.Name != "" { return b.Name } return b.Code }