feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package model
|
||
|
||
import (
|
||
"blazing/cool"
|
||
)
|
||
|
||
const (
|
||
TableNamePetFusion = "config_fusion_pet" // 宠物融合配方表(主表)
|
||
)
|
||
|
||
// PetFusion 宠物融合配方主模型(核心配方规则)
|
||
type PetFusion struct {
|
||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||
|
||
MainPetID int32 `gorm:"not null;comment:'主宠物ID(如:尼尔)'" json:"main_pet_id"`
|
||
SubPetID int32 `gorm:"not null;comment:'副宠物ID(如:闪皮)'" json:"sub_pet_id"`
|
||
Probability int32 `gorm:"not null;comment:'融合成功率(百分比,如80代表80%)'" json:"probability"`
|
||
ResultPetID int32 `gorm:"not null;comment:'融合结果宠物ID(如:卡鲁、闪尼)'" json:"result_pet_id"`
|
||
Remark string `gorm:"type:varchar(255);default:'';comment:'融合配方备注(如:尼尔+闪皮=闪尼)'" json:"remark"`
|
||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"`
|
||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||
|
||
// 关联:一个配方对应多个材料(gorm 一对多关联,查询时可预加载)
|
||
//Materials []*PetFusionMaterial `gorm:"foreignKey:PetFusionID;references:ID" json:"materials,omitempty"`
|
||
}
|
||
|
||
// TableName 指定主表名
|
||
func (*PetFusion) TableName() string {
|
||
return TableNamePetFusion
|
||
}
|
||
|
||
// GroupName 表分组(与原逻辑一致)
|
||
func (*PetFusion) GroupName() string {
|
||
return "default"
|
||
}
|
||
|
||
// NewPetFusion 创建主表实例
|
||
func NewPetFusion() *PetFusion {
|
||
return &PetFusion{
|
||
Model: cool.NewModel(),
|
||
}
|
||
}
|
||
|
||
// init 初始化主表结构
|
||
func init() {
|
||
cool.CreateTable(&PetFusion{})
|
||
}
|