This commit is contained in:
@@ -28,7 +28,6 @@ type CDKConfig struct {
|
||||
ValidEndTime time.Time `gorm:"not null;comment:'CDK有效结束时间'" json:"valid_end_time" description:"有效结束时间"`
|
||||
|
||||
Remark string `gorm:"size:512;default:'';comment:'CDK备注'" json:"remark" description:"备注信息"`
|
||||
//ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
|
||||
@@ -8,9 +8,30 @@ const (
|
||||
TableNameEgg = "config_egg" // 性别配置表(替换原宠物融合表名)
|
||||
)
|
||||
|
||||
type BaseConfig struct {
|
||||
*cool.Model // 保留通用Model(ID/创建时间/更新时间等)
|
||||
IsEnable int32 `gorm:"not null;default:0;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"` // 保留原有逻辑
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释
|
||||
}
|
||||
|
||||
func (m *BaseConfig) TableName() string {
|
||||
return "this_table_should_not_exist"
|
||||
}
|
||||
|
||||
// 返回分组名
|
||||
func (m *BaseConfig) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
func NewBaseConfig() *BaseConfig {
|
||||
return &BaseConfig{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// Egg 性别配置模型(替换原宠物融合配方模型)
|
||||
type Egg struct {
|
||||
*cool.Model // 保留通用Model(ID/创建时间/更新时间等)
|
||||
*BaseConfig
|
||||
//雌性
|
||||
MalePetIDs []int32 `gorm:"type:int[];comment:'雄性宠物ID列表(如:[1001,1002])'" json:"male_pet_ids"`
|
||||
//雄性
|
||||
@@ -18,9 +39,6 @@ type Egg struct {
|
||||
//子代指定性别配置表名
|
||||
OutputMons []int32 `gorm:"type:int[];not null;comment:'宠物类型ID'" json:"pet_type_id"`
|
||||
Probs []int32 `gorm:"type:int[];not null;comment:'对应子代宠物类型的概率(如:[50,50]表示均等概率)'" json:"probs"`
|
||||
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"` // 保留原有逻辑
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释
|
||||
}
|
||||
|
||||
// TableName 指定性别配置表名(替换原宠物融合表名)
|
||||
@@ -36,7 +54,7 @@ func (*Egg) GroupName() string {
|
||||
// NewEgg 创建性别配置实例(替换原NewPetFusion)
|
||||
func NewEgg() *Egg {
|
||||
return &Egg{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,17 @@ const (
|
||||
|
||||
// PetFusionMaterial 融合材料模型(与配方主表一对一关联)
|
||||
type PetFusionMaterial struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
*BaseConfig
|
||||
|
||||
// 4个材料ID(对应XML ItemGroup的Idx=1-4,无材料填0)
|
||||
Material1 uint32 `gorm:"not null;comment:'材料1ID(如400030)'" json:"material1"`
|
||||
Material2 uint32 `gorm:"not null;comment:'材料2ID(如400030)'" json:"material2"`
|
||||
Material3 uint32 `gorm:"not null;comment:'材料3ID(如400028)'" json:"material3"`
|
||||
Material4 uint32 `gorm:"not null;comment:'材料4ID(如400030)'" json:"material4"`
|
||||
|
||||
// 4个特性ID(对应XML MaterialGroup的特性索引,4-4对应)
|
||||
Trait1Idx uint32 `gorm:"not null;comment:'特性1索引(如1008)'" json:"trait1_idx"`
|
||||
Trait2Idx uint32 `gorm:"not null;comment:'特性2索引(如1018)'" json:"trait2_idx"`
|
||||
Trait3Idx uint32 `gorm:"not null;comment:'特性3索引(如1023)'" json:"trait3_idx"`
|
||||
Trait4Idx uint32 `gorm:"not null;comment:'特性4索引(如1031)'" json:"trait4_idx"`
|
||||
|
||||
IsEnable int32 `gorm:"not null;default:0;comment:'是否启用该组合(1:启用,0:禁用)'" json:"is_enable"`
|
||||
}
|
||||
|
||||
// TableName 指定子表名
|
||||
@@ -38,7 +34,7 @@ func (*PetFusionMaterial) GroupName() string {
|
||||
// NewPetFusionMaterial 创建材料实例
|
||||
func NewPetFusionMaterial() *PetFusionMaterial {
|
||||
return &PetFusionMaterial{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,15 @@ const (
|
||||
|
||||
// PetFusion 宠物融合配方主模型(核心配方规则)
|
||||
type PetFusion struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
*BaseConfig
|
||||
|
||||
MainPetID int32 `gorm:"not null;comment:'主宠物ID(如:尼尔)'" json:"main_pet_id"`
|
||||
//SubPetID int32 `gorm:"not null;comment:'副宠物ID(如:闪皮)'" json:"sub_pet_id"`
|
||||
|
||||
SubPetIDs []int32 `gorm:"type:int[];comment:'副宠物IDs(如:1,2,3)'" json:"sub_pet_ids"`
|
||||
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:0;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"`
|
||||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||||
|
||||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||||
|
||||
// 关联:一个配方对应多个材料(gorm 一对多关联,查询时可预加载)
|
||||
//Materials []*PetFusionMaterial `gorm:"foreignKey:PetFusionID;references:ID" json:"materials,omitempty"`
|
||||
@@ -38,7 +37,7 @@ func (*PetFusion) GroupName() string {
|
||||
// NewPetFusion 创建主表实例
|
||||
func NewPetFusion() *PetFusion {
|
||||
return &PetFusion{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,11 @@ const (
|
||||
|
||||
// ItemGift 物品奖励基础配置模型(与数据库表 item_gift 字段一一对应,核心存储结构)
|
||||
type ItemGift struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与现有模型一致性)
|
||||
|
||||
*BaseConfig
|
||||
// 核心业务字段(按需求实现:物品id、备注、是否启用、是否为扭蛋、物品数量)
|
||||
ItemID int64 `gorm:"not null;default:0;comment:'物品ID,关联物品配置表主键'" json:"item_id"`
|
||||
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"` //奖励是否为扭蛋奖励
|
||||
ItemID int64 `gorm:"not null;default:0;comment:'物品ID,关联物品配置表主键'" json:"item_id"`
|
||||
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
//ItemCount uint32 `gorm:"not null;default:1;comment:'物品奖励数量'" json:"item_count"`
|
||||
ItemMinCount int64 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// ItemMaxCount 单次采集最大产出数量
|
||||
@@ -37,9 +35,7 @@ func (*ItemGift) GroupName() string {
|
||||
// NewItemGift 创建一个新的ItemGift实例(初始化通用Model字段+默认值,与现有实例创建逻辑一致)
|
||||
func NewItemGift() *ItemGift {
|
||||
return &ItemGift{
|
||||
Model: cool.NewModel(), // 初始化通用Model字段(ID/创建时间/更新时间等)
|
||||
// 字段默认值与gorm tag中default配置保持一致
|
||||
IsEnabled: 1,
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const (
|
||||
|
||||
// MonsterRefresh 怪物刷新规则模型(对应前端配置的地图/精灵/等级/脚本配置)
|
||||
type MonsterRefresh struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||
*BaseConfig
|
||||
|
||||
MapID int32 `gorm:"not null;comment:'地图ID'" json:"map_id"`
|
||||
MonsterID string `gorm:"not null;comment:'精灵ID,填0为填充数组'" json:"monster_id"`
|
||||
@@ -21,9 +21,6 @@ type MonsterRefresh struct {
|
||||
|
||||
// 以下为原模型保留的异色相关字段(前端暂未配置,如需移除可删除)
|
||||
ShinyID string `gorm:"not null;comment:'异色唯一标识ID'" json:"shiny_id"`
|
||||
// ShinyFilter string `gorm:"type:text;not null;comment:'异色滤镜效果(文本描述或配置参数)'" json:"shiny_filter"`
|
||||
// ShinyEffect string `gorm:"type:text;not null;comment:'异色光效效果(文本描述或配置参数)'" json:"shiny_effect"`
|
||||
// TODO: 增加ruffle的显示异色效果(如需保留则完善,无需则删除)
|
||||
}
|
||||
|
||||
type MonsterRefreshEX struct {
|
||||
@@ -45,7 +42,7 @@ func (*MonsterRefresh) GroupName() string {
|
||||
// NewMonsterRefresh 创建一个新的MonsterRefresh实例(初始化通用Model)
|
||||
func NewMonsterRefresh() *MonsterRefresh {
|
||||
return &MonsterRefresh{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ const (
|
||||
|
||||
// PetReward 精灵奖励基础配置模型(核心存储结构,与数据库表字段一一对应)
|
||||
type PetReward struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与BossConfig一致)
|
||||
IsEnabled uint32 `gorm:"not null;default:0;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled"`
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
DV int32 `gorm:"not null;default:0;comment:'成长值'" json:"dv"`
|
||||
Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
Effect int32 `gorm:"not null;comment:'BOSS特性'" json:"effect"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
Desc *string `gorm:"size:512;default:'';comment:'BOSS描述'" json:"desc"`
|
||||
*BaseConfig
|
||||
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
DV int32 `gorm:"not null;default:0;comment:'成长值'" json:"dv"`
|
||||
Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
Effect int32 `gorm:"not null;comment:'BOSS特性'" json:"effect"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
IsLight uint32 `gorm:"not null;default:0;comment:'是否擦灯'" json:"is_light"` //奖励是否为光之子``
|
||||
}
|
||||
|
||||
// TableName 指定PetReward对应的数据库表名(遵循现有代码规范)
|
||||
@@ -35,9 +35,7 @@ func (*PetReward) GroupName() string {
|
||||
// NewPetReward 创建一个新的PetReward实例(初始化通用Model字段+所有字段默认值,与NewBossConfig保持一致)
|
||||
func NewPetReward() *PetReward {
|
||||
return &PetReward{
|
||||
Model: cool.NewModel(), // 初始化通用Model字段(ID/创建时间/更新时间等)
|
||||
// 可根据需要设置其他字段的默认值,此处保持与gorm tag中default一致
|
||||
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@ const (
|
||||
|
||||
// ColorfulSkin 炫彩皮肤核心配置模型(完整保留原有字段,仅更名适配)
|
||||
type ColorfulSkin struct {
|
||||
*cool.Model
|
||||
*BaseConfig
|
||||
|
||||
// 核心必填字段
|
||||
Color data.GlowFilter `gorm:"type:jsonb;not null;;comment:'炫彩皮肤颜色(唯一标识每条配置)'" json:"color" description:"炫彩皮肤颜色"`
|
||||
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Author string `gorm:"not null;size:64;default:'';comment:'炫彩皮肤配置作者(创建人/配置者名称)'" json:"author" description:"作者"`
|
||||
RefreshCount uint32 `gorm:"not null;default:0;comment:'累计刷新次数(炫彩皮肤外观刷新次数统计)'" json:"refresh_count" description:"刷新次数"`
|
||||
UsageCount uint32 `gorm:"not null;default:0;comment:'累计使用次数(炫彩皮肤使用次数统计)'" json:"usage_count" description:"使用次数"`
|
||||
@@ -26,9 +25,6 @@ type ColorfulSkin struct {
|
||||
ElfProbability uint32 `gorm:"not null;default:0;comment:'野生精灵概率(0-10000)'" json:"elf_probability" description:"野生精灵概率"`
|
||||
//投票
|
||||
VoteCount uint32 `gorm:"not null;default:0;comment:'投票次数'" json:"vote_count" description:"投票次数"`
|
||||
|
||||
// 辅助备注字段
|
||||
Remark string `gorm:"size:512;default:'';comment:'炫彩皮肤备注'" json:"remark" description:"备注信息"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(仅更名适配,逻辑不变)--------------------------
|
||||
@@ -42,7 +38,7 @@ func (*ColorfulSkin) GroupName() string {
|
||||
|
||||
func NewColorfulSkin() *ColorfulSkin {
|
||||
return &ColorfulSkin{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,14 @@ const (
|
||||
|
||||
// ShopConfig 商店商品核心配置模型
|
||||
type ShopConfig struct {
|
||||
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
||||
|
||||
*BaseConfig
|
||||
// 核心字段
|
||||
ProductName string `gorm:"not null;size:128;comment:'商品名称'" json:"product_name" description:"商品名称"`
|
||||
//商品类型
|
||||
ProductType uint32 `gorm:"not null;default:0;comment:'商品类型(0-普通商品 1-虚拟商品 2-限时商品)'" json:"product_type" description:"商品类型"`
|
||||
|
||||
//商品ID
|
||||
ProductID int64 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
Desc string `gorm:"not null;size:512;comment:'商品描述'" json:"desc" description:"商品描述"`
|
||||
ProductID int64 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
|
||||
// 价格信息 -1代表不允许购买,0表示不支持购买
|
||||
SeerdouPrice int32 `gorm:"not null;default:0;comment:'骄阳豆价格'" json:"seerdou_price" description:"骄阳豆价格"`
|
||||
@@ -29,9 +27,6 @@ type ShopConfig struct {
|
||||
// 库存信息
|
||||
Stock uint32 `gorm:"not null;default:0;comment:'商品库存数量(0表示无限库存)'" json:"stock" description:"库存数量"`
|
||||
|
||||
// 状态信息
|
||||
IsOnSale uint32 `gorm:"not null;default:1;comment:'是否上架(0-下架 1-上架)'" json:"is_on_sale" description:"是否上架"`
|
||||
|
||||
// 限购信息
|
||||
QuotaLimit uint32 `gorm:"not null;default:0;comment:'单位时间内的限购数量(0表示不限购)'" json:"quota_limit" description:"限购数量"`
|
||||
QuotaCycle uint32 `gorm:"not null;default:0;comment:'限购周期(单位:小时,0表示不限购)'" json:"quota_cycle" description:"限购周期(小时)"`
|
||||
@@ -48,7 +43,7 @@ func (*ShopConfig) GroupName() string {
|
||||
|
||||
func NewShopConfig() *ShopConfig {
|
||||
return &ShopConfig{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
/*
|
||||
* @Author: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @Date: 2025-12-31 02:42:41
|
||||
* @LastEditors: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @LastEditTime: 2026-01-18 11:37:05
|
||||
* @FilePath: \sun\modules\config\model\task.go
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
package model
|
||||
|
||||
import (
|
||||
@@ -19,7 +11,7 @@ const (
|
||||
|
||||
// TaskConfig 任务核心配置模型
|
||||
type TaskConfig struct {
|
||||
*cool.Model
|
||||
*BaseConfig
|
||||
|
||||
// 核心字段
|
||||
TaskId uint32 `gorm:"not null;comment:'任务唯一ID'" json:"task_id" description:"任务唯一ID"`
|
||||
@@ -37,10 +29,6 @@ type TaskConfig struct {
|
||||
|
||||
//绑定奖励
|
||||
TitleRewardIds uint32 `gorm:"not null;default:0;comment:'绑定奖励称号'" json:"title_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:"备注信息"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
@@ -54,7 +42,7 @@ func (*TaskConfig) GroupName() string {
|
||||
|
||||
func NewTaskConfig() *TaskConfig {
|
||||
return &TaskConfig{
|
||||
Model: cool.NewModel(),
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,24 +13,19 @@ const (
|
||||
|
||||
// -------------------------- 核心基类:所有塔配置的通用结构 --------------------------
|
||||
type BaseTowerConfig struct {
|
||||
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
||||
|
||||
*BaseConfig
|
||||
Name string `gorm:"size:32;default:'';comment:'塔层名称'" json:"name" description:"塔层名称"`
|
||||
// ItemGift []ItemGift `orm:"with:item_id=id"`
|
||||
// 核心必填字段(所有塔类型通用)
|
||||
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数(唯一标识每层配置)'" json:"tower_level" description:"塔层数"`
|
||||
BossIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定BOSS ID数组,关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"`
|
||||
TaskIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定任务ID数组,关联config_task表主键'" json:"task_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:"备注信息"`
|
||||
Name string `gorm:"size:32;default:'';comment:'塔层名称'" json:"name" description:"塔层名称"`
|
||||
// ItemGift []ItemGift `orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
// NewBaseTowerConfig 创建基础塔配置实例(所有塔类型共用)
|
||||
func NewBaseTowerConfig() BaseTowerConfig {
|
||||
return BaseTowerConfig{
|
||||
Model: cool.NewModel(),
|
||||
func NewBaseTowerConfig() *BaseTowerConfig {
|
||||
return &BaseTowerConfig{
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,17 +33,17 @@ func NewBaseTowerConfig() BaseTowerConfig {
|
||||
|
||||
// Tower110Config 勇者之塔110配置模型
|
||||
type Tower110Config struct {
|
||||
BaseTowerConfig
|
||||
*BaseTowerConfig
|
||||
}
|
||||
|
||||
// Tower500Config 试炼之塔500配置模型
|
||||
type Tower500Config struct {
|
||||
BaseTowerConfig
|
||||
*BaseTowerConfig
|
||||
}
|
||||
|
||||
// Tower600Config 勇者之塔600配置模型
|
||||
type Tower600Config struct {
|
||||
BaseTowerConfig
|
||||
*BaseTowerConfig
|
||||
}
|
||||
|
||||
// -------------------------- 各塔模型的核心配套方法(统一规范)--------------------------
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量(遵循现有命名规范:小写+下划线)
|
||||
const TableNameSignIn = "config_sign_in"
|
||||
|
||||
// SignIn 签到记录表
|
||||
// 核心字段:签到完成状态、状压签到进度、签到奖励脚本
|
||||
type SignIn struct {
|
||||
*cool.Model // 嵌入基础Model(包含主键、创建/更新时间等通用字段)
|
||||
SignInID uint32 `gorm:"not null;index:idx_sign_in_id;comment:'签到活动ID'" json:"sign_in_id"`
|
||||
Status uint32 `gorm:"not null;default:0;comment:'签到状态(0-未完成 1-已完成)'" json:"status"`
|
||||
//传入用户名,签到天数,给予奖励,这个搭配里程碑表实现
|
||||
RewardScript string `gorm:"type:varchar(512);default:'';comment:'签到奖励脚本(执行奖励发放的脚本内容)'" json:"reward_script"`
|
||||
}
|
||||
|
||||
// TableName 指定表名(遵循现有规范)
|
||||
func (*SignIn) TableName() string {
|
||||
return TableNameSignIn
|
||||
}
|
||||
|
||||
// GroupName 指定表分组(默认分组,与现有Item表/精灵特效表一致)
|
||||
func (*SignIn) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewSignIn 创建签到记录表实例(初始化基础Model)
|
||||
func NewSignIn() *SignIn {
|
||||
return &SignIn{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建表(与现有PlayerPetSpecialEffect表的初始化逻辑一致)
|
||||
func init() {
|
||||
cool.CreateTable(&SignIn{})
|
||||
}
|
||||
@@ -10,7 +10,7 @@ const TableNameMineralCollectionConfig = "config_talk"
|
||||
// MineralCollectionConfig 挖矿/采集/采摘矿产配置表Model定义
|
||||
// 字段完全匹配数据表结构,包含最小/最大产出核心字段
|
||||
type MineralCollectionConfig struct {
|
||||
*cool.Model // 嵌入基础Model,包含id(主键)、createTime、updateTime等通用字段
|
||||
*BaseConfig
|
||||
|
||||
// MapID 矿产所在地图ID
|
||||
MapID uint32 `gorm:"column:map_id;not null;index:idx_mineral_collection_config_map_id;comment:矿产所在地图ID" json:"map_id"`
|
||||
@@ -21,13 +21,6 @@ type MineralCollectionConfig struct {
|
||||
|
||||
// ItemID 物品编号(对应道具系统ID)
|
||||
ItemIDS []uint32 `gorm:"column:item_ids;type:jsonb;index:idx_mineral_collection_config_item_id;comment:物品编号(对应道具系统ID)" json:"item_ids"`
|
||||
// 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"`
|
||||
// Description 矿产描述
|
||||
Description string `gorm:"column:description;type:varchar(128); comment:矿产描述" json:"description"`
|
||||
// ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
// TableName 指定数据表名(必须匹配数据库表名,遵循项目规范)
|
||||
@@ -44,7 +37,7 @@ func (*MineralCollectionConfig) GroupName() string {
|
||||
// 保证通用字段(createTime/updateTime)被正确初始化
|
||||
func NewMineralCollectionConfig() *MineralCollectionConfig {
|
||||
return &MineralCollectionConfig{
|
||||
Model: cool.NewModel(), // 调用基础Model的初始化方法
|
||||
BaseConfig: NewBaseConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,35 @@ import (
|
||||
|
||||
// /取消redis空节点的强制缓存
|
||||
func dbm(m cool.IModel) *gdb.Model {
|
||||
return cool.DBM(m).
|
||||
Cache(gdb.CacheOption{
|
||||
Force: true,
|
||||
ret := cool.DBM(m)
|
||||
if cool.Config.ServerInfo.IsVip == 0 { //正式服启动缓存
|
||||
ret = ret.Where("is_enable", 1)
|
||||
}
|
||||
if cool.Config.ServerInfo.IsDebug == 0 {
|
||||
|
||||
ret = ret.Cache(gdb.CacheOption{
|
||||
Force: false,
|
||||
})
|
||||
}
|
||||
return ret
|
||||
}
|
||||
func dbm_fix(m cool.IModel) *gdb.Model {
|
||||
ret := cool.DBM(m).Cache(gdb.CacheOption{
|
||||
Force: false,
|
||||
})
|
||||
|
||||
return ret
|
||||
}
|
||||
func dbm_nocache(m cool.IModel) *gdb.Model {
|
||||
ret := cool.DBM(m)
|
||||
if cool.Config.ServerInfo.IsVip == 0 { //正式服启动缓存
|
||||
ret = ret.Where("is_enable", 1)
|
||||
}
|
||||
// if cool.Config.ServerInfo.IsDebug == 0 {
|
||||
|
||||
// ret = ret.Cache(gdb.CacheOption{
|
||||
// Force: false,
|
||||
// })
|
||||
// }
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (s *BossService) Get(id uint32) *model.BossConfig {
|
||||
return nil
|
||||
}
|
||||
var item *model.BossConfig
|
||||
dbm(s.Model).Where("id", id).Scan(&item)
|
||||
dbm_fix(s.Model).Where("id", id).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func NewCdkService() *CdkService {
|
||||
}
|
||||
func (s *CdkService) Get(id string) *model.CDKConfig {
|
||||
var item *model.CDKConfig
|
||||
dbm(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Scan(&item)
|
||||
dbm_fix(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ type EffectService struct {
|
||||
}
|
||||
|
||||
func (s *EffectService) Args(id uint32) (int, []int) {
|
||||
m := dbm(s.Model).Where("se_idx", id)
|
||||
m := dbm_fix(s.Model).Where("se_idx", id)
|
||||
var tt model.PlayerPetSpecialEffect
|
||||
m.Scan(&tt)
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ func (s *EggService) GetData(p1 uint32) []int32 {
|
||||
m := dbm(s.Model)
|
||||
|
||||
var pet []model.Egg //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
m.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, p1).
|
||||
Where("is_enable", 1).Scan(&pet)
|
||||
m.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, p1).Scan(&pet)
|
||||
var petIDs []int32
|
||||
for _, p := range pet {
|
||||
petIDs = append(petIDs, p.FemalePetIDs...)
|
||||
@@ -42,8 +41,7 @@ func (s *EggService) GetResult(m, f uint32) uint32 {
|
||||
|
||||
var pet *model.Egg //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m).
|
||||
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).
|
||||
Where("is_enable", 1).Scan(&pet)
|
||||
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).Scan(&pet)
|
||||
if pet != nil {
|
||||
|
||||
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
@@ -19,7 +18,7 @@ type ItemService struct {
|
||||
func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
||||
var item model.ItemGift
|
||||
var res data.ItemInfo
|
||||
dbm(s.Model).Where("id", id).Where("is_enabled", 1).Scan(&item)
|
||||
dbm(s.Model).Where("id", id).Scan(&item)
|
||||
|
||||
if item.ItemID == 0 {
|
||||
|
||||
@@ -36,11 +35,7 @@ func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
||||
}
|
||||
func (s *ItemService) GetEgg(count int64) []data.ItemInfo {
|
||||
var item []model.ItemGift
|
||||
cool.DBM(s.Model).Where("is_egg", 1).Where("is_enabled", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
dbm(s.Model).Where("is_egg", 1).Scan(&item)
|
||||
|
||||
rr := utils.RandomSlice(item, int(count))
|
||||
var res = make([]data.ItemInfo, len(rr))
|
||||
|
||||
@@ -18,7 +18,7 @@ func NewPetRewardService() *PetRewardService {
|
||||
}
|
||||
func (s *PetRewardService) GetEgg() model.PetReward {
|
||||
var item model.PetReward
|
||||
cool.DBM(s.Model).Where("is_egg", 1).Where("is_enabled", 1).OrderRandom().Limit(1).Scan(&item)
|
||||
dbm_nocache(s.Model).Where("is_egg", 1).OrderRandom().Limit(1).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
@@ -63,12 +62,9 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
|
||||
|
||||
}
|
||||
func (s *PetFusionService) getData(p1, p2 uint32) []model.PetFusion {
|
||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
m := dbm(s.Model)
|
||||
|
||||
var pet []model.PetFusion //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
m.Where("main_pet_id", p1).Wheref(`sub_pet_ids @> ARRAY[?]::integer[]`, p2).
|
||||
Where("is_enable", 1).Scan(&pet)
|
||||
dbm(s.Model).Where("main_pet_id", p1).Wheref(`sub_pet_ids @> ARRAY[?]::integer[]`, p2).Scan(&pet)
|
||||
|
||||
return pet
|
||||
|
||||
@@ -77,12 +73,7 @@ func (s *PetFusionService) getData(p1, p2 uint32) []model.PetFusion {
|
||||
func (s *PetFusionService) def() []model.PetFusion {
|
||||
|
||||
var pets []model.PetFusion
|
||||
m := cool.DBM(s.Model)
|
||||
m.Where("is_enable", 1).Where("is_default", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&pets)
|
||||
dbm(s.Model).Where("is_default", 1).Scan(&pets)
|
||||
|
||||
return pets
|
||||
// return ret.Interface().([]model.PetFusion)
|
||||
|
||||
@@ -48,8 +48,7 @@ func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin {
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").
|
||||
Where("is_enabled", 1).Scan(&ret)
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret)
|
||||
|
||||
for _, v := range ret {
|
||||
//print(v.ID)
|
||||
@@ -76,8 +75,7 @@ func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin {
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").
|
||||
Where("is_enabled", 1).Scan(&ret)
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret)
|
||||
if len(ret) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewTaskService() *TaskService {
|
||||
}
|
||||
func (s *TaskService) Get(id, os int) *model.TaskConfig {
|
||||
var item []model.TaskConfig
|
||||
dbm(s.Model).Where("task_id", id).Where("is_enabled", 1).Scan(&item)
|
||||
dbm(s.Model).Where("task_id", id).Scan(&item)
|
||||
var res *model.TaskConfig
|
||||
for _, v := range item {
|
||||
if v.OutState == os {
|
||||
|
||||
@@ -68,7 +68,7 @@ func (m *UnifiedTowerModel) GroupName() string {
|
||||
// Boss 根据塔等级获取对应的Boss配置(统一入口)
|
||||
func (s *TowerService) Boss(towerLevel uint32) *model.BaseTowerConfig {
|
||||
// 构建基础查询条件
|
||||
query := dbm(s.Model).Where("tower_level = ?", towerLevel).Where("is_enabled", 1)
|
||||
query := dbm(s.Model).Where("tower_level = ?", towerLevel)
|
||||
|
||||
// 600塔专属的缓存配置
|
||||
var config model.BaseTowerConfig
|
||||
|
||||
Reference in New Issue
Block a user