Files
qsdk/schema/blocks_index.go
2026-05-01 11:03:19 +08:00

29 lines
815 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}