29 lines
865 B
Go
29 lines
865 B
Go
|
|
package schema
|
|||
|
|
|
|||
|
|
import "gorm.io/gorm"
|
|||
|
|
|
|||
|
|
// DatasetBlocksIndex 板块索引(采用 dataset/stock 的 code 唯一约束)。
|
|||
|
|
type DatasetBlocksIndex struct {
|
|||
|
|
gorm.Model
|
|||
|
|
TiCode string `gorm:"type:varchar(50);not null;default:'';comment:指数代码;uniqueIndex:uq_blocks_index_code" json:"ti_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 (DatasetBlocksIndex) TableName() string {
|
|||
|
|
return "dataset_blocks_index"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Key 板块业务主键:code。
|
|||
|
|
func (b *DatasetBlocksIndex) Key() string {
|
|||
|
|
return b.TiCode
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// DisplayName 展示名称:非空 name,否则回退 code。
|
|||
|
|
func (b *DatasetBlocksIndex) DisplayName() string {
|
|||
|
|
if b.Name != "" {
|
|||
|
|
return b.Name
|
|||
|
|
}
|
|||
|
|
return b.TiCode
|
|||
|
|
}
|