feat(user-talk): 优化聊天功能中的物品奖励逻辑
重构 Talk 方法中物品奖励的获取方式,使用新的配置服务以支持多物品 ID 奖励机制。 移除了对 github.com/gogf/gf/v2/util/grand 包的依赖,改为通过服务获取实际物品数量。 同时更新了相关模型定义: - 修改 MineralCollectionConfig 中 ItemID 为数组形式以支持多个物品配置 - 调整 ItemGift 模型字段
This commit is contained in:
@@ -25,11 +25,11 @@ type CDKConfig struct {
|
||||
ElfRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励精灵ID数组,关联config_pet_boss表主键'" json:"elf_reward_ids" description:"奖励精灵数组"`
|
||||
|
||||
// 辅助配置字段
|
||||
ValidStartTime time.Time `gorm:"not null;comment:'CDK有效开始时间'" json:"valid_start_time" description:"有效开始时间"`
|
||||
ValidEndTime time.Time `gorm:"not null;comment:'CDK有效结束时间'" json:"valid_end_time" description:"有效结束时间"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该CDK(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'CDK备注'" json:"remark" description:"备注信息"`
|
||||
ItemGift []ItemGift `orm:"with:item_id=id"`
|
||||
ValidStartTime time.Time `gorm:"not null;comment:'CDK有效开始时间'" json:"valid_start_time" description:"有效开始时间"`
|
||||
ValidEndTime time.Time `gorm:"not null;comment:'CDK有效结束时间'" json:"valid_end_time" description:"有效结束时间"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该CDK(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'CDK备注'" json:"remark" description:"备注信息"`
|
||||
//ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
|
||||
@@ -18,7 +18,10 @@ type ItemGift struct {
|
||||
Remark string `gorm:"size:512;default:'';comment:'物品奖励备注说明(如使用场景、特殊说明等)'" json:"remark"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
ItemCount uint32 `gorm:"not null;default:1;comment:'物品奖励数量'" json:"item_count"`
|
||||
//ItemCount uint32 `gorm:"not null;default:1;comment:'物品奖励数量'" json:"item_count"`
|
||||
ItemMinCount uint32 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// ItemMaxCount 单次采集最大产出数量
|
||||
ItemMaxCount uint32 `gorm:"column:item_max_count;not null;comment:单次采集最大产出数量" json:"item_max_count"`
|
||||
}
|
||||
|
||||
// TableName 指定ItemGift对应的数据库表名(遵循现有代码规范)
|
||||
@@ -37,8 +40,6 @@ func NewItemGift() *ItemGift {
|
||||
Model: cool.NewModel(), // 初始化通用Model字段(ID/创建时间/更新时间等)
|
||||
// 字段默认值与gorm tag中default配置保持一致
|
||||
IsEnabled: 1,
|
||||
|
||||
ItemCount: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,20 @@ type PetBaseConfig struct {
|
||||
// PrimaryScene int32 `gorm:"not null;default:0;comment:'首场景标识(0:非首场景地图;n>0:第n星系的星球且是首场景,默认0)'" json:"primary_scene"`
|
||||
|
||||
// ===================== 战斗核心属性(BossMon节点) =====================
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
Hp int32 `gorm:"not null;comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
Color string `gorm:"comment:'BOSS颜色'" json:"color"`
|
||||
Hp int32 `gorm:"not null;comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"`
|
||||
|
||||
// ===================== BOSS属性(Boss_prop) =====================
|
||||
Prop []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS属性'" json:"prop"`
|
||||
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
SKill []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS技能'" json:"skill"`
|
||||
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
|
||||
Color string `gorm:"comment:'BOSS颜色'" json:"color"`
|
||||
IsEnable uint32 `gorm:"not null;default:0;comment:'是否启用'" json:"is_enable"`
|
||||
Desc *string `gorm:"comment:'BOSS描述'" json:"desc"`
|
||||
Prop []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS属性'" json:"prop"`
|
||||
|
||||
SKill []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS技能'" json:"skill"`
|
||||
|
||||
IsEnable uint32 `gorm:"not null;default:0;comment:'是否启用'" json:"is_enable"`
|
||||
Desc *string `gorm:"comment:'BOSS描述'" json:"desc"`
|
||||
|
||||
// ISMELEE uint32 `gorm:"not null;default:0;comment:'是否乱斗配置'" json:"is_melee"`
|
||||
// // ===================== BOSS奖励规则(Boss_bonus) =====================
|
||||
|
||||
@@ -13,8 +13,12 @@ const (
|
||||
type PetReward struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与BossConfig一致)
|
||||
|
||||
PetBaseConfig
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
Color string `gorm:"comment:'BOSS颜色'" json:"color"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
}
|
||||
|
||||
// PetRewardEX 精灵奖励扩展配置模型(用于前端/业务层的复杂数据解析,继承基础模型)
|
||||
|
||||
@@ -21,9 +21,9 @@ type BaseTowerConfig struct {
|
||||
ElfRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励精灵ID数组,关联config_pet_boss表主键'" json:"elf_reward_ids" description:"绑定奖励精灵数组"`
|
||||
|
||||
// 通用辅助字段(与勇者之塔完全一致,无额外添加)
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该层配置(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'试炼之塔层备注'" json:"remark" description:"备注信息"`
|
||||
ItemGift []ItemGift `orm:"with:item_id=id"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该层配置(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'试炼之塔层备注'" json:"remark" description:"备注信息"`
|
||||
// ItemGift []ItemGift `orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
func NewBaseTowerConfig() BaseTowerConfig {
|
||||
|
||||
@@ -20,14 +20,14 @@ type MineralCollectionConfig struct {
|
||||
DailyCollectCount uint32 `gorm:"column:daily_collect_count;not null;comment:每日可采集次数" json:"daily_collect_count"`
|
||||
|
||||
// ItemID 物品编号(对应道具系统ID)
|
||||
ItemID uint32 `gorm:"column:item_id; not null;index:idx_mineral_collection_config_item_id;comment:物品编号(对应道具系统ID)" json:"item_id"`
|
||||
ItemID []uint32 `gorm:"column:item_id; not null;index:idx_mineral_collection_config_item_id;comment:物品编号(对应道具系统ID)" json:"item_id"`
|
||||
// ItemMinCount 单次采集最小产出数量
|
||||
ItemMinCount uint32 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// ItemMaxCount 单次采集最大产出数量
|
||||
ItemMaxCount uint32 `gorm:"column:item_max_count;not null;comment:单次采集最大产出数量" json:"item_max_count"`
|
||||
// ItemMinCount uint32 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// // ItemMaxCount 单次采集最大产出数量
|
||||
// ItemMaxCount uint32 `gorm:"column:item_max_count;not null;comment:单次采集最大产出数量" json:"item_max_count"`
|
||||
// Description 矿产描述
|
||||
Description string `gorm:"column:description;type:varchar(128); comment:矿产描述" json:"description"`
|
||||
ItemGift []*ItemGift `orm:"with:item_id=id"`
|
||||
Description string `gorm:"column:description;type:varchar(128); comment:矿产描述" json:"description"`
|
||||
// ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
// TableName 指定数据表名(必须匹配数据库表名,遵循项目规范)
|
||||
|
||||
Reference in New Issue
Block a user