All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor(common/utils): 重构concurrent_swiss_map使用官方sync.Map实现 - 替换原有的第三方并发map实现,改为基于标准库sync.Map的封装 - 保持完全的API兼容性,原有配置方法变为无实际作用的占位符 - 优化Range方法实现,移除goroutine/channel开销,避免潜在的死锁风险 - 移除依赖的外部库和
96 lines
2.5 KiB
Go
96 lines
2.5 KiB
Go
package model
|
|
|
|
import (
|
|
"blazing/cool"
|
|
)
|
|
|
|
// -------------------------- 表名常量定义(统一管理所有塔配置表名)--------------------------
|
|
const (
|
|
TableNamedARKTowerConfig = "config_tower_110" // 勇者之塔110配置表
|
|
TableNameTrialTowerConfig = "config_tower_500" // 试炼之塔500配置表
|
|
TableNameBraveTowerConfig = "config_tower_600" // 勇者之塔600配置表
|
|
)
|
|
|
|
type BaseTowerConfig struct {
|
|
*BaseConfig
|
|
Name string `gorm:"type:varchar(100);default:'';comment:'塔名称'" json:"name" description:"塔名称"`
|
|
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数'" json:"tower_level" `
|
|
BossIds []uint32 `gorm:"not null;type:jsonb;default:'[]';comment:'绑定BOSS ID数组'" json:"boss_ids" `
|
|
}
|
|
|
|
// NewBaseTowerConfig 创建基础塔配置实例(所有塔类型共用)
|
|
func NewBaseTowerConfig() *BaseTowerConfig {
|
|
return &BaseTowerConfig{
|
|
BaseConfig: NewBaseConfig(),
|
|
}
|
|
}
|
|
|
|
type Tower110Config struct {
|
|
*BaseTowerConfig
|
|
}
|
|
|
|
// Tower500Config 试炼之塔500配置模型
|
|
type Tower500Config struct {
|
|
*BaseTowerConfig
|
|
}
|
|
|
|
// Tower600Config 勇者之塔600配置模型
|
|
type Tower600Config struct {
|
|
*BaseTowerConfig
|
|
}
|
|
|
|
// -------------------------- 各塔模型的核心配套方法(统一规范)--------------------------
|
|
|
|
// ===== Tower110Config 专属方法 =====
|
|
func (*Tower110Config) TableName() string {
|
|
return TableNamedARKTowerConfig
|
|
}
|
|
|
|
func (*Tower110Config) GroupName() string {
|
|
return "default"
|
|
}
|
|
|
|
func New110TowerConfig() *Tower110Config {
|
|
return &Tower110Config{
|
|
BaseTowerConfig: NewBaseTowerConfig(),
|
|
}
|
|
}
|
|
|
|
// ===== Tower500Config 专属方法 =====
|
|
func (*Tower500Config) TableName() string {
|
|
return TableNameTrialTowerConfig
|
|
}
|
|
|
|
func (*Tower500Config) GroupName() string {
|
|
return "default"
|
|
}
|
|
|
|
func New500TowerConfig() *Tower500Config {
|
|
return &Tower500Config{
|
|
BaseTowerConfig: NewBaseTowerConfig(),
|
|
}
|
|
}
|
|
|
|
// ===== Tower600Config 专属方法 =====
|
|
func (*Tower600Config) TableName() string {
|
|
return TableNameBraveTowerConfig
|
|
}
|
|
|
|
func (*Tower600Config) GroupName() string {
|
|
return "default"
|
|
}
|
|
|
|
func New600TowerConfig() *Tower600Config {
|
|
return &Tower600Config{
|
|
BaseTowerConfig: NewBaseTowerConfig(),
|
|
}
|
|
}
|
|
|
|
// -------------------------- 表结构自动同步(初始化所有塔配置表)--------------------------
|
|
func init() {
|
|
// 依次创建所有塔配置表,保持原有自动同步逻辑
|
|
cool.CreateTable(&Tower110Config{})
|
|
cool.CreateTable(&Tower500Config{})
|
|
cool.CreateTable(&Tower600Config{})
|
|
}
|