53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package model
|
||
|
||
import (
|
||
"blazing/cool"
|
||
)
|
||
|
||
// 表名常量定义:egg配置表
|
||
const (
|
||
TableNameeggConfig = "config_pet_egg" // egg配置表(记录egg编号、可兑换次数、奖励配置等核心信息)
|
||
)
|
||
|
||
// EggConfig egg核心配置模型(含可兑换次数,满足查询`where 可兑换次数 != 0`需求)
|
||
type EggConfig struct {
|
||
*cool.Model
|
||
|
||
//雄性
|
||
|
||
MalePet int32 `gorm:"not null;comment:'雄性宠物ID'" json:"male_pet"`
|
||
//雌性
|
||
FemalePet int32 `gorm:"not null;comment:'雌性宠物ID'" json:"female_pet"`
|
||
|
||
// 生成的精灵ID及对应概率
|
||
GeneratedPetIDs []GeneratedPetID `gorm:"type:jsonb;comment:'生成的精灵ID及概率配置'" json:"generated_pet_ids"`
|
||
|
||
Remark string `gorm:"size:512;default:'';comment:'egg备注'" json:"remark" description:"备注信息"`
|
||
//ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||
}
|
||
type GeneratedPetID struct {
|
||
PetID int32 `json:"pet_id" comment:"生成的精灵ID"`
|
||
Prob float64 `json:"prob" comment:"该精灵生成概率"`
|
||
}
|
||
|
||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||
func (*EggConfig) TableName() string {
|
||
return TableNameeggConfig
|
||
}
|
||
|
||
func (*EggConfig) GroupName() string {
|
||
return "default"
|
||
}
|
||
|
||
func NeweggConfig() *EggConfig {
|
||
return &EggConfig{
|
||
Model: cool.NewModel(),
|
||
}
|
||
}
|
||
|
||
// -------------------------- 表结构自动同步 --------------------------
|
||
func init() {
|
||
|
||
cool.CreateTable(&EggConfig{})
|
||
}
|