refactor(controller): 重构服务模块命名,统一使用小写包名并优化模型结构

This commit is contained in:
1
2025-07-26 02:06:08 +00:00
parent 492d3a1207
commit 99318f6674
14 changed files with 149 additions and 155 deletions

View File

@@ -2,15 +2,15 @@ package controller
import (
"blazing/logic/service"
"blazing/logic/service/CommendSvr"
"blazing/logic/service/commendsvr"
"github.com/panjf2000/gnet/v2"
)
// 处理命令: 105
func (h Controller) GetServer(data *CommendSvr.SidInfo, c gnet.Conn) (result *CommendSvr.CommendSvrInfo, err service.OutInfo) { //这个时候player应该是空的
result = CommendSvr.NewInInfo()
result.ServerList = CommendSvr.GetServerInfoList()
func (h Controller) GetServer(data *commendsvr.SidInfo, c gnet.Conn) (result *commendsvr.CommendSvrInfo, err service.OutInfo) { //这个时候player应该是空的
result = commendsvr.NewInInfo()
result.ServerList = commendsvr.GetServerInfoList()
return
//return //TODO 这里待实现改成接口调用Ret方法

View File

@@ -3,16 +3,15 @@ package controller
import (
"blazing/common/data/entity"
"blazing/logic/service"
"blazing/logic/service/MapHot"
maps "blazing/logic/service/MapHot"
"blazing/logic/service/maphot"
)
func (h Controller) MapHot(data *MapHot.InInfo, c *entity.Player) (result *MapHot.OutInfo, err service.OutInfo) {
func (h Controller) MapHot(data *maphot.InInfo, c *entity.Player) (result *maphot.OutInfo, err service.OutInfo) {
data.Def()
result = &maps.OutInfo{
result = &maphot.OutInfo{
HotInfos: make([]maps.MapHotInfo, 0),
HotInfos: make([]maphot.MapHotInfo, 0),
}
return

View File

@@ -3,11 +3,11 @@ package controller
import (
"blazing/common/data/entity"
"blazing/logic/service"
"blazing/logic/service/SystemTime"
"blazing/logic/service/systemtime"
)
func (h Controller) SystemTimeInfo(data *SystemTime.InInfo, c *entity.Player) (result *SystemTime.OutInfo, err service.OutInfo) {
result = SystemTime.NewOutInfo()
func (h Controller) SystemTimeInfo(data *systemtime.InInfo, c *entity.Player) (result *systemtime.OutInfo, err service.OutInfo) {
result = systemtime.NewOutInfo()
return
}

View File

@@ -1,4 +1,4 @@
package CommendSvr
package commendsvr
import (
"blazing/common/socket/handler"

View File

@@ -2,6 +2,7 @@ package login
import (
"blazing/common/socket/handler"
"blazing/modules/blazing/model"
)
// LoginUserInfo 对应Java版本的登录用户信息结构
@@ -67,16 +68,16 @@ type OutInfo struct {
NonoState uint32 `struc:"uint32" default:"4294967295"` // 默认值-1
NonoColor uint32 `struc:"uint32"` // nono的颜色
NonoNick [16]byte `struc:"[16]byte" default:"nono"` // nono的名字 必须要补齐到16位
TeamInfo TeamInfo `struc:"struct"` // 猜测为战队信息24字节
TeamPkInfo TeamPKInfo `struc:"struct"` // 8字节
TeamInfo model.TeamInfo `struc:"struct"` // 猜测为战队信息24字节
TeamPkInfo model.TeamPKInfo `struc:"struct"` // 8字节
Reserved byte `struc:"byte"` // 1字节 无内容
Badge uint32 `struc:"uint32" default:"0"` // 默认值为0
Reserved1 [27]byte `struc:"[27]byte" default:"3"` // 未知(27字节默认值为3)
TaskList [500]byte `struc:"[500]byte" default:"3"` // 任务状态数组(500字节3为已经完成建议默认值为3)
PetListCount uint16 `struc:"sizeof=PetList"` // 精灵列表长度
PetList PetInfo `struc:"-"` // 精灵背包内的信息
PetList model.PetInfo `struc:"-"` // 精灵背包内的信息
ClothesCount uint8 `struc:"sizeof=Clothes"` // 穿戴装备数量
Clothes []PeopleItemInfo `struc:"-"` // 穿戴装备
Clothes []model.PeopleItemInfo `struc:"-"` // 穿戴装备
}
// 初始化默认值

View File

@@ -1,54 +0,0 @@
package login
// PetInfo 精灵信息结构对应Java的PetInfo包含新增的皮肤和闪光字段
type PetInfo struct {
ID uint32 `struc:"uint32"` // 精灵编号
Name [16]byte `struc:"[16]byte"` // 名字16字节固定长度默认全0
DV uint32 `struc:"uint32"` // 个体值
Nature uint32 `struc:"uint32"` // 性格
Level uint32 `struc:"uint32"` // 等级
Exp uint32 `struc:"uint32"` // 当前等级已获得的经验
LvExp uint32 `struc:"uint32"` // 当前等级所需的经验
NextLvExp uint32 `struc:"uint32"` // 升到下一级的经验
HP uint32 `struc:"uint32"` // 当前生命
MaxHP uint32 `struc:"uint32"` // 最大生命
Attack uint32 `struc:"uint32"` // 攻击
Defence uint32 `struc:"uint32"` // 防御
SpecialAttack uint32 `struc:"uint32"` // 特攻
SpecialDefence uint32 `struc:"uint32"` // 特防
Speed uint32 `struc:"uint32"` // 速度
EvHP uint32 `struc:"uint32"` // 生命学习力
EvAttack uint32 `struc:"uint32"` // 攻击学习力
EvDefence uint32 `struc:"uint32"` // 防御学习力
EvSpecialAttack uint32 `struc:"uint32"` // 特攻学习力
EvSpecialDefense uint32 `struc:"uint32"` // 特防学习力
EvSpeed uint32 `struc:"uint32"` // 速度学习力
SkillSize uint32 `struc:"uint32"` // 技能个数
SkillList [4]SkillInfo
CatchTime uint32 `struc:"uint32"` // 捕捉时间
CatchMap uint32 `struc:"uint32"` // 捕捉地图
CatchRect uint32 `struc:"uint32" default:"0"` // 未知默认0
CatchLevel uint32 `struc:"uint32" default:"0"` // 捕获等级默认0
SkinID uint32 `struc:"uint32" default:"0"` // 皮肤id默认0新增字段
Shiny uint32 `struc:"uint32"` // 是不是闪(新增字段)
EffectInfoLen uint16 `struc:"sizeof=EffectInfo"` // 特性列表长度(无符号短整型)
EffectInfo []PetEffectInfo
}
// PetEffectInfo 精灵特性信息结构对应Java的PetEffectInfo
type PetEffectInfo struct {
ItemID uint32 `struc:"uint32"` // 特性晶片对应的物品id对应Java的@UInt long
Status byte `struc:"byte" default:"1"` // 状态默认1对应Java的@Builder.Default
LeftCount byte `struc:"byte"` // 未知默认0
EffectID uint16 `struc:"uint16"` // 特性id对应Java的@UShort int
Reserve1 byte `struc:"byte"` // 保留字段1
Reserve2 byte `struc:"byte"` // 保留字段2
Reserve3 byte `struc:"byte"` // 保留字段3
Reserve4 [13]byte `struc:"[13]byte"` // 保留字段4固定13字节默认全0
}
// SkillInfo 精灵技能信息结构对应Java的SkillInfo
type SkillInfo struct {
ID uint32 `struc:"uint32"` // 技能id对应Java的@UInt long
Pp uint32 `struc:"uint32"` // 剩余pp对应Java的@UInt long
}

View File

@@ -1,4 +1,4 @@
package MapHot
package maphot
import "blazing/common/socket/handler"

View File

@@ -1,4 +1,4 @@
package SystemTime
package systemtime
import (
"blazing/common/socket/handler"

View File

@@ -1,4 +1,4 @@
package SystemTime
package systemtime
import "blazing/common/socket/errorcode"

View File

@@ -1,4 +1,4 @@
package login
package model
// PeopleItemInfo 穿戴装备信息结构对应Java的PeopleItemInfo
type PeopleItemInfo struct {

View File

@@ -1,78 +1,119 @@
package model
import (
"blazing/cool"
)
const TableNamePet = "pet"
// Pet mapped from table <pet>
type Pet struct {
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
}
type PetInfo struct {
CapturePlayerID uint64 `gorm:"not null;comment:'捕获者ID'" json:"capture_player_id"`
CaptureTime int64 `gorm:"not null;comment:'捕获时间(时间戳)'" json:"capture_time"`
CaptureMap int32 `gorm:"not null;comment:'捕获地图ID'" json:"capture_map"`
CaptureRect int16 `gorm:"not null;default:0;comment:'捕获区域(未知用途默认为0)'" json:"capture_rect"`
CaptureLevel int16 `gorm:"not null;default:0;comment:'捕获时的等级'" json:"capture_level"`
PetTypeID int32 `gorm:"not null;comment:'精灵类型ID/精灵图鉴ID'" json:"pet_type_id"`
IndividualValue int16 `gorm:"not null;comment:'个体值(DV)'" json:"individual_value"`
Nature int16 `gorm:"not null;comment:'性格类型'" json:"nature"`
AbilityTypeEnum int16 `gorm:"comment:'特性枚举'" json:"ability_type_enum"`
Shiny int32 `gorm:"not null;default:0;comment:'闪光ID(异色!=0非异色=0)'" json:"shiny"`
Level int16 `gorm:"not null;default:1;comment:'当前等级'" json:"level"`
CurrentExp int32 `gorm:"not null;default:0;comment:'当前等级已获得经验值'" json:"current_exp"`
CurrentHP int32 `gorm:"not null;comment:'当前生命值'" json:"current_hp"`
MaxHP int32 `gorm:"not null;comment:'实际最大生命值'" json:"max_hp"`
Attack int32 `gorm:"not null;comment:'实际攻击力'" json:"attack"`
Defense int32 `gorm:"not null;comment:'实际防御力'" json:"defense"`
SpecialAttack int32 `gorm:"not null;comment:'实际特殊攻击力'" json:"special_attack"`
SpecialDefense int32 `gorm:"not null;comment:'实际特殊防御力'" json:"special_defense"`
Speed int32 `gorm:"not null;comment:'实际速度'" json:"speed"`
EvHP int16 `gorm:"not null;default:0;comment:'生命值学习力'" json:"ev_hp"`
EvAttack int16 `gorm:"not null;default:0;comment:'攻击学习力'" json:"ev_attack"`
EvDefense int16 `gorm:"not null;default:0;comment:'防御学习力'" json:"ev_defense"`
EvSpecialAttack int16 `gorm:"not null;default:0;comment:'特殊攻击学习力'" json:"ev_special_attack"`
EvSpecialDefense int16 `gorm:"not null;default:0;comment:'特殊防御学习力'" json:"ev_special_defense"`
EvSpeed int16 `gorm:"not null;default:0;comment:'速度学习力'" json:"ev_speed"`
PetSkill []PetSkillInfo //技能组
ElementalOrbID int32 `gorm:"not null;default:0;comment:'属性能量珠ID'" json:"elemental_orb_id"`
SpecialOrbID int32 `gorm:"not null;default:0;comment:'平衡/暴击能量珠ID'" json:"special_orb_id"`
ElementalOrbCount int16 `gorm:"not null;default:0;comment:'属性能量珠剩余使用次数'" json:"elemental_orb_count"`
SpecialOrbCount int16 `gorm:"not null;default:0;comment:'平衡/暴击能量珠剩余使用次数'" json:"special_orb_count"`
IndividualGuarantee int64 `gorm:"not null;default:0;comment:'个体值保底(0=无保底)'" json:"individual_guarantee"`
NatureGuarantee int64 `gorm:"not null;default:0;comment:'性格保底(0=无保底)'" json:"nature_guarantee"`
Freed bool `gorm:"default:false;not null;comment:'是否已放生(0=未放生,1=已放生)'" json:"freed"`
FreedTime string `gorm:"comment:'放生时间'" json:"freed_time"`
}
type PetSkillInfo struct {
skill int32 `gorm:"not null;default:0;comment:'技能1'" json:"skill_1_id"`
pp int16 `gorm:"not null;default:0;comment:'技能1PP'" json:"skill_1_pp"`
}
// TableName Pet's table name
func (*Pet) TableName() string {
return TableNamePet
}
// GroupName Pet's table group
func (*Pet) GroupName() string {
return "default"
}
// NewPet create a new Pet
func NewPet() *Pet {
return &Pet{
Model: cool.NewModel(),
}
}
// init 创建表
func init() {
_ = cool.CreateTable(&Pet{})
// fmt.Println(err)
}
package model
import (
"blazing/cool"
)
const TableNamePet = "pet"
// Pet mapped from table <pet>
type Pet struct {
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
}
// PetInfo 精灵信息结构,合并了两个版本的字段
type PetInfo struct {
// 第一个版本中的字段
CapturePlayerID uint64 `gorm:"not null;comment:'捕获者ID'" json:"capture_player_id"`
CaptureTime int64 `gorm:"not null;comment:'捕获时间(时间戳)'" json:"capture_time"`
CaptureMap int32 `gorm:"not null;comment:'捕获地图ID'" json:"capture_map"`
CaptureRect int16 `gorm:"not null;default:0;comment:'捕获区域(未知用途默认为0)'" json:"capture_rect"`
CaptureLevel int16 `gorm:"not null;default:0;comment:'捕获时的等级'" json:"capture_level"`
PetTypeID int32 `gorm:"not null;comment:'精灵类型ID/精灵图鉴ID'" json:"pet_type_id"`
IndividualValue int16 `gorm:"not null;comment:'个体值(DV)'" json:"individual_value"`
Nature int16 `gorm:"not null;comment:'性格类型'" json:"nature"`
AbilityTypeEnum int16 `gorm:"comment:'特性枚举'" json:"ability_type_enum"`
Shiny int32 `gorm:"not null;default:0;comment:'闪光ID(异色!=0非异色=0)'" json:"shiny"`
Level int16 `gorm:"not null;default:1;comment:'当前等级'" json:"level"`
CurrentExp int32 `gorm:"not null;default:0;comment:'当前等级已获得经验值'" json:"current_exp"`
CurrentHP int32 `gorm:"not null;comment:'当前生命值'" json:"current_hp"`
MaxHP int32 `gorm:"not null;comment:'实际最大生命值'" json:"max_hp"`
Attack int32 `gorm:"not null;comment:'实际攻击力'" json:"attack"`
Defense int32 `gorm:"not null;comment:'实际防御力'" json:"defense"`
SpecialAttack int32 `gorm:"not null;comment:'实际特殊攻击力'" json:"special_attack"`
SpecialDefense int32 `gorm:"not null;comment:'实际特殊防御力'" json:"special_defense"`
Speed int32 `gorm:"not null;comment:'实际速度'" json:"speed"`
EvHP int16 `gorm:"not null;default:0;comment:'生命值学习力'" json:"ev_hp"`
EvAttack int16 `gorm:"not null;default:0;comment:'攻击学习力'" json:"ev_attack"`
EvDefense int16 `gorm:"not null;default:0;comment:'防御学习力'" json:"ev_defense"`
EvSpecialAttack int16 `gorm:"not null;default:0;comment:'特殊攻击学习力'" json:"ev_special_attack"`
EvSpecialDefense int16 `gorm:"not null;default:0;comment:'特殊防御学习力'" json:"ev_special_defense"`
EvSpeed int16 `gorm:"not null;default:0;comment:'速度学习力'" json:"ev_speed"`
PetSkill []PetSkillInfo // 技能组
ElementalOrbID int32 `gorm:"not null;default:0;comment:'属性能量珠ID'" json:"elemental_orb_id"`
SpecialOrbID int32 `gorm:"not null;default:0;comment:'平衡/暴击能量珠ID'" json:"special_orb_id"`
ElementalOrbCount int16 `gorm:"not null;default:0;comment:'属性能量珠剩余使用次数'" json:"elemental_orb_count"`
SpecialOrbCount int16 `gorm:"not null;default:0;comment:'平衡/暴击能量珠剩余使用次数'" json:"special_orb_count"`
IndividualGuarantee int64 `gorm:"not null;default:0;comment:'个体值保底(0=无保底)'" json:"individual_guarantee"`
NatureGuarantee int64 `gorm:"not null;default:0;comment:'性格保底(0=无保底)'" json:"nature_guarantee"`
Freed bool `gorm:"default:false;not null;comment:'是否已放生(0=未放生,1=已放生)'" json:"freed"`
FreedTime string `gorm:"comment:'放生时间'" json:"freed_time"`
// 第二个版本中的字段
ID uint32 `struc:"uint32" gorm:"not null;comment:'精灵编号'" json:"id"`
Name [16]byte `struc:"[16]byte" gorm:"type:char(16);comment:'名字'" json:"name"`
DV uint32 `struc:"uint32" gorm:"not null;comment:'个体值'" json:"dv"`
LvExp uint32 `struc:"uint32" gorm:"not null;comment:'当前等级所需的经验'" json:"lv_exp"`
NextLvExp uint32 `struc:"uint32" gorm:"not null;comment:'升到下一级的经验'" json:"next_lv_exp"`
Defence uint32 `struc:"uint32" gorm:"not null;comment:'防御'" json:"defence"`
//EvSpecialDefense uint32 `struc:"uint32" gorm:"not null;comment:'特防学习力'" json:"ev_special_defense"`
SkillSize uint32 `struc:"uint32" gorm:"not null;comment:'技能个数'" json:"skill_size"`
SkillList [4]SkillInfo `gorm:"embedded;embeddedPrefix:skill_list_" json:"skill_list"`
CatchTime uint32 `struc:"uint32" gorm:"not null;comment:'捕捉时间'" json:"catch_time"`
CatchRect uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'未知默认0'" json:"catch_rect"`
CatchLevel uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'捕获等级默认0'" json:"catch_level"`
SkinID uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'皮肤id默认0'" json:"skin_id"`
EffectInfoLen uint16 `struc:"sizeof=EffectInfo" gorm:"comment:'特性列表长度'" json:"effect_info_len"`
EffectInfo []PetEffectInfo `gorm:"embedded;embeddedPrefix:effect_info_" json:"effect_info"`
}
// PetSkillInfo 精灵技能信息结构,合并了两个版本
type PetSkillInfo struct {
SkillID1 int32 `gorm:"not null;default:0;comment:'技能1ID'" json:"skill_1_id"`
PP1 int16 `gorm:"not null;default:0;comment:'技能1PP'" json:"skill_1_pp"`
SkillID2 int32 `gorm:"default:0;comment:'技能2ID'" json:"skill_2_id"`
PP2 int16 `gorm:"default:0;comment:'技能2PP'" json:"skill_2_pp"`
SkillID3 int32 `gorm:"default:0;comment:'技能3ID'" json:"skill_3_id"`
PP3 int16 `gorm:"default:0;comment:'技能3PP'" json:"skill_3_pp"`
SkillID4 int32 `gorm:"default:0;comment:'技能4ID'" json:"skill_4_id"`
PP4 int16 `gorm:"default:0;comment:'技能4PP'" json:"skill_4_pp"`
}
// PetEffectInfo 精灵特性信息结构(第二个版本中的定义)
type PetEffectInfo struct {
ItemID uint32 `struc:"uint32" gorm:"not null;comment:'特性晶片对应的物品id'" json:"item_id"`
Status byte `struc:"byte" default:"1" gorm:"default:1;comment:'状态'" json:"status"`
LeftCount byte `struc:"byte" gorm:"comment:'未知'" json:"left_count"`
EffectID uint16 `struc:"uint16" gorm:"not null;comment:'特性id'" json:"effect_id"`
Reserve1 byte `struc:"byte" gorm:"comment:'保留字段1'" json:"reserve1"`
Reserve2 byte `struc:"byte" gorm:"comment:'保留字段2'" json:"reserve2"`
Reserve3 byte `struc:"byte" gorm:"comment:'保留字段3'" json:"reserve3"`
Reserve4 [13]byte `struc:"[13]byte" gorm:"type:char(13);comment:'保留字段4'" json:"reserve4"`
}
// TableName Pet's table name
func (*Pet) TableName() string {
return TableNamePet
}
// GroupName Pet's table group
func (*Pet) GroupName() string {
return "default"
}
// NewPet create a new Pet
func NewPet() *Pet {
return &Pet{
Model: cool.NewModel(),
}
}
// init 创建表
func init() {
_ = cool.CreateTable(&Pet{})
// fmt.Println(err)
}

View File

@@ -0,0 +1,7 @@
package model
// SkillInfo 精灵技能信息结构对应Java的SkillInfo
type SkillInfo struct {
ID uint32 `struc:"uint32"` // 技能id对应Java的@UInt long
Pp uint32 `struc:"uint32"` // 剩余pp对应Java的@UInt long
}

View File

@@ -1,4 +1,4 @@
package login
package model
import "blazing/common/socket/handler"

View File

@@ -1,4 +1,4 @@
package login
package model
// TeamPKInfo 战队PK相关信息结构
type TeamPKInfo struct {