refactor(blazing): 重构项目并优化数据结构
- 更新 LoginUserInfo 结构体,将 uint64 类型改为 uint32 - 调整 ServerInfo 结构体,将 IP 字段从 []byte 改为 string - 移除未使用的 ArraySerialize 结构体 - 更新 ByteArray 类,修改相关方法名 - 删除未使用的 serialize 相关代码 - 优化模块导入,移除冗余依赖
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package info
|
||||
|
||||
import "blazing/common/core/info/pet"
|
||||
|
||||
// Point 表示坐标结构
|
||||
type Point struct {
|
||||
X uint32
|
||||
@@ -24,18 +26,12 @@ type PeopleItemInfo struct {
|
||||
// 请根据实际需求补充
|
||||
}
|
||||
|
||||
// PetInfo 精灵信息
|
||||
type PetInfo struct {
|
||||
// 此处应包含PetInfo的具体字段,原Java代码中未给出详细定义
|
||||
// 请根据实际需求补充
|
||||
}
|
||||
|
||||
// LoginUserInfo 登录用户信息结构体
|
||||
type LoginUserInfo struct {
|
||||
// 米米号 通过sid拿到
|
||||
UserId uint64
|
||||
UserId uint32
|
||||
// 注册时间(按秒的时间戳)
|
||||
RegisterTime uint64
|
||||
RegisterTime uint32
|
||||
// 16字节昵称
|
||||
Nick [16]byte `array_serialize:"fixed_length,16"`
|
||||
// 暂时不明建议先给固定值0
|
||||
@@ -43,25 +39,25 @@ type LoginUserInfo struct {
|
||||
// 暂时不明建议先给固定值15
|
||||
Viped uint16 `ushort:"true"`
|
||||
// 暂时不明建议先给固定值0
|
||||
DsFlag uint64
|
||||
DsFlag uint32
|
||||
// 机器人人物颜色 00 rgb
|
||||
Color uint64
|
||||
Color uint32
|
||||
// 暂时不明建议先给固定值0
|
||||
Texture uint64
|
||||
Texture uint32
|
||||
// 暂时不明建议先给固定值3000
|
||||
Energy uint64 `default:"3000"`
|
||||
Energy uint32 `default:"3000"`
|
||||
// 赛尔豆
|
||||
Coins uint64
|
||||
Coins uint32
|
||||
// 暂时不明建议先给固定值0
|
||||
FightBadge uint64
|
||||
FightBadge uint32
|
||||
// 上线的地图id
|
||||
MapID uint64
|
||||
MapID uint32
|
||||
// 上线的坐标 2个uint
|
||||
Pos Point `array_serialize:"fixed_length,8"`
|
||||
// 已经消耗掉的时间(秒为单位)
|
||||
TimeToday uint64
|
||||
TimeToday uint32
|
||||
// 总电池限制(秒为单位)
|
||||
TimeLimit uint64
|
||||
TimeLimit uint32
|
||||
// 暂时不明感觉是某种活动建议先给固定值0(只能0或1)
|
||||
IsClothHalfDay byte
|
||||
// 暂时不明感觉是某种活动建议先给固定值0(只能0或1)
|
||||
@@ -71,83 +67,83 @@ type LoginUserInfo struct {
|
||||
// 暂时不明感觉是某种活动建议先给固定值0(只能0或1)
|
||||
IsHQHalfDay byte
|
||||
// 暂时不明建议先给固定值0
|
||||
LoginCount uint64
|
||||
LoginCount uint32
|
||||
// 邀请活动建议先给固定值0
|
||||
Inviter uint64
|
||||
Inviter uint32
|
||||
// 邀请活动建议先给固定值0
|
||||
NewInviteeCount uint64
|
||||
NewInviteeCount uint32
|
||||
// 超no等级建议固定8
|
||||
VipLevel uint64 `default:"8"`
|
||||
VipLevel uint32 `default:"8"`
|
||||
// 超no的vip值建议固定80000
|
||||
VipValue uint64 `default:"80000"`
|
||||
VipValue uint32 `default:"80000"`
|
||||
// 超no的外形等级建议固定1(暂定)
|
||||
VipStage uint64 `default:"1"`
|
||||
VipStage uint32 `default:"1"`
|
||||
// nono是否自动充电 建议固定1
|
||||
AutoCharge uint64 `default:"1"`
|
||||
AutoCharge uint32 `default:"1"`
|
||||
// 超no的结束时间建议尽可能大
|
||||
VipEndTime uint64 `default:"4294967295"`
|
||||
VipEndTime uint32 `default:"4294967295"`
|
||||
// 邀请活动建议先给固定值0
|
||||
FreshManBonus uint64
|
||||
FreshManBonus uint32
|
||||
// 超no芯片列表*(80字节)
|
||||
NonoChipList [80]byte `array_serialize:"fixed_length,80"`
|
||||
// 50字节,默认值为3
|
||||
DailyResArr [50]byte `array_serialize:"fixed_length,50"`
|
||||
// 教官id
|
||||
TeacherID uint64
|
||||
TeacherID uint32
|
||||
// 学员id
|
||||
StudentID uint64
|
||||
StudentID uint32
|
||||
// 毕业人数
|
||||
GraduationCount uint64
|
||||
GraduationCount uint32
|
||||
// 默认值为0
|
||||
MaxPuniLv uint64 `default:"0"`
|
||||
MaxPuniLv uint32 `default:"0"`
|
||||
// 精灵的最高等级
|
||||
PetMaxLevel uint64
|
||||
PetMaxLevel uint32
|
||||
// 所有的精灵的数量
|
||||
AllPetNumber uint64
|
||||
AllPetNumber uint32
|
||||
// 精灵王之战胜场
|
||||
MonKingWin uint64
|
||||
MonKingWin uint32
|
||||
// 勇者之塔当前到达的层数
|
||||
CurrentStage uint64
|
||||
CurrentStage uint32
|
||||
// 试炼之塔最大胜利的层数
|
||||
MaxStage uint64
|
||||
MaxStage uint32
|
||||
// 试炼之塔当前到达的层数
|
||||
CurrentFreshStage uint64
|
||||
CurrentFreshStage uint32
|
||||
// 试炼之塔最大胜利的层数
|
||||
MaxFreshStage uint64
|
||||
MaxFreshStage uint32
|
||||
// 星际擂台连胜
|
||||
MaxArenaWins uint64
|
||||
MaxArenaWins uint32
|
||||
// 未知默认0
|
||||
TwoTimes uint64 `default:"0"`
|
||||
TwoTimes uint32 `default:"0"`
|
||||
// 未知默认0
|
||||
ThreeTimes uint64 `default:"0"`
|
||||
ThreeTimes uint32 `default:"0"`
|
||||
// 是否自动战斗(未知默认值0)
|
||||
AutoFight uint64 `default:"0"`
|
||||
AutoFight uint32 `default:"0"`
|
||||
// 自动战斗剩余的场次(未知默认值0)
|
||||
AutoFightTime uint64 `default:"0"`
|
||||
AutoFightTime uint32 `default:"0"`
|
||||
// 能量吸收仪剩余次数(未知待定默认值0)
|
||||
EnergyTime uint64 `default:"0"`
|
||||
EnergyTime uint32 `default:"0"`
|
||||
// 学习力吸收仪剩余次数(未知待定默认值0)
|
||||
LearnTimes uint64 `default:"0"`
|
||||
LearnTimes uint32 `default:"0"`
|
||||
// 未知默认0
|
||||
MonBattleMedal uint64 `default:"0"`
|
||||
MonBattleMedal uint32 `default:"0"`
|
||||
// 未知默认0
|
||||
RecordCount uint64 `default:"0"`
|
||||
RecordCount uint32 `default:"0"`
|
||||
// 未知默认0
|
||||
ObtainTm uint64 `default:"0"`
|
||||
ObtainTm uint32 `default:"0"`
|
||||
// 当前在孵化的元神珠id
|
||||
SoulBeadItemID uint64
|
||||
SoulBeadItemID uint32
|
||||
// 未知默认0
|
||||
ExpireTm uint64 `default:"0"`
|
||||
ExpireTm uint32 `default:"0"`
|
||||
// 未知默认0
|
||||
FuseTimes uint64 `default:"0"`
|
||||
FuseTimes uint32 `default:"0"`
|
||||
// 玩家有没有nono
|
||||
HasNono uint64 `default:"1"`
|
||||
HasNono uint32 `default:"1"`
|
||||
// 玩家有没有超能nono
|
||||
SuperNono uint64 `default:"1"`
|
||||
SuperNono uint32 `default:"1"`
|
||||
// 默认值-1
|
||||
NonoState uint64 `default:"4294967295"`
|
||||
NonoState uint32 `default:"4294967295"`
|
||||
// nono的颜色
|
||||
NonoColor uint64
|
||||
NonoColor uint32
|
||||
// nono的名字 必须要补齐到16位
|
||||
NonoNick [16]byte `array_serialize:"fixed_length,16"`
|
||||
// 猜测为战队信息24字节
|
||||
@@ -157,13 +153,13 @@ type LoginUserInfo struct {
|
||||
// 1字节 无内容
|
||||
Reserved byte
|
||||
// 默认值为0
|
||||
Badge uint64 `default:"0"`
|
||||
Badge uint32 `default:"0"`
|
||||
// 未知(27字节,默认值为3)
|
||||
Reserved1 [27]byte `array_serialize:"fixed_length,27"`
|
||||
// 任务状态数组(500字节,3为已经完成,建议默认值为3)
|
||||
TaskList [500]byte `array_serialize:"fixed_length,500"`
|
||||
// 精灵背包内的信息由于特性精灵的存在精灵背包不定长 如果有特性占199字节 如果没特性 一个精灵占175字节
|
||||
PetList []PetInfo
|
||||
PetList []pet.PetInfo
|
||||
// 穿戴装备 8字节
|
||||
Clothes []PeopleItemInfo
|
||||
}
|
||||
@@ -178,7 +174,7 @@ func NewLoginUserInfo() *LoginUserInfo {
|
||||
VipValue: 80000,
|
||||
VipStage: 1,
|
||||
AutoCharge: 1,
|
||||
VipEndTime: uint64(^uint32(0)),
|
||||
VipEndTime: uint32(^uint32(0)),
|
||||
TwoTimes: 0,
|
||||
ThreeTimes: 0,
|
||||
AutoFight: 0,
|
||||
@@ -192,7 +188,7 @@ func NewLoginUserInfo() *LoginUserInfo {
|
||||
FuseTimes: 0,
|
||||
HasNono: 1,
|
||||
SuperNono: 1,
|
||||
NonoState: uint64(^uint32(0)),
|
||||
NonoState: uint32(^uint32(0)),
|
||||
Badge: 0,
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ type ServerInfo struct {
|
||||
// 当前服务器玩家在线数量, 供SWF显示
|
||||
UserCnt uint32
|
||||
// 服务器IP, 16字节UTF-8, 不足16补齐到16
|
||||
IP []byte `v:"FIXED_LENGTH|length:16"`
|
||||
IP string `serialize:"fixed:16"` // 定长模式:16字节
|
||||
// 端口
|
||||
Port uint16
|
||||
// 好友在线的个数
|
||||
@@ -19,7 +19,7 @@ func NewServerInfo() *ServerInfo {
|
||||
return &ServerInfo{
|
||||
OnlineID: 0,
|
||||
UserCnt: 0,
|
||||
IP: []byte{},
|
||||
IP: "",
|
||||
Port: 0,
|
||||
Friends: 0,
|
||||
}
|
||||
|
||||
21
common/core/info/pet/PetEffectInfo.go
Normal file
21
common/core/info/pet/PetEffectInfo.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package pet
|
||||
|
||||
// PetEffectInfo 精灵特性信息结构体
|
||||
type PetEffectInfo struct {
|
||||
ItemID uint32 // 特性晶片对应的物品id
|
||||
Status byte // 默认为1
|
||||
LeftCount byte // 未知默认为0
|
||||
EffectID uint16 // 特性id
|
||||
Reserve1 byte // 保留字段1
|
||||
Reserve2 byte // 保留字段2无作用
|
||||
Reserve3 byte // 保留字段3
|
||||
Reserve4 [13]byte // 保留字段4 占13字节
|
||||
}
|
||||
|
||||
// NewPetEffectInfo 创建一个新的精灵特性信息实例
|
||||
func NewPetEffectInfo() *PetEffectInfo {
|
||||
return &PetEffectInfo{
|
||||
Status: 1,
|
||||
Reserve4: [13]byte{},
|
||||
}
|
||||
}
|
||||
54
common/core/info/pet/PetInfo.go
Normal file
54
common/core/info/pet/PetInfo.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package pet
|
||||
|
||||
import (
|
||||
"blazing/common/core/info/pet/skill"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PetInfo 精灵信息结构体
|
||||
type PetInfo struct {
|
||||
ID uint32 // 精灵编号
|
||||
Name string `serialize:"fixed:16"` // 定长模式:16字节 // 名字 默认为全0 但要补齐到16字节
|
||||
DV uint32 // 个体值
|
||||
Nature uint32 // 性格
|
||||
Level uint32 // 等级
|
||||
Exp uint32 // 当前等级已经获得的经验
|
||||
LvExp uint32 // 当前等级所需的经验
|
||||
NextLvExp uint32 // 升到下一级的经验
|
||||
HP uint32 // 当前生命
|
||||
MaxHP uint32 // 最大生命
|
||||
Attack uint32 // 攻击
|
||||
Defence uint32 // 防御
|
||||
SpecialAttack uint32 // 特攻
|
||||
SpecialDefence uint32 // 特防
|
||||
Speed uint32 // 速度
|
||||
EVHP uint32 // 生命学习力
|
||||
EVAttack uint32 // 攻击学习力
|
||||
EVDefence uint32 // 防御学习力
|
||||
EVSpecialAttack uint32 // 特攻学习力
|
||||
EVSpecialDefense uint32 // 特防学习力
|
||||
EVSpeed uint32 // 速度学习力
|
||||
SkillSize uint32 // 技能个数
|
||||
SkillList [4]skill.SkillInfo `serialize:"fixed:8"` // 32字节 技能信息 必须插入4条skillInfo,若技能信息为空则要赋值成0
|
||||
CatchTime uint32 // 捕捉时间
|
||||
CatchMap uint32 // 捕捉地图
|
||||
CatchRect uint32 // 未知默认为0
|
||||
CatchLevel uint32 // 捕获等级 默认为0
|
||||
EffectInfo []PetEffectInfo `serialize:"varlen:2"` // 特性列表, 长度在头部以UShort存储
|
||||
SkinID uint32 // 皮肤id默认为0
|
||||
Shiny uint32 // 是不是闪
|
||||
}
|
||||
|
||||
// NewPetInfo 创建一个新的精灵信息实例
|
||||
func NewPetInfo() *PetInfo {
|
||||
return &PetInfo{
|
||||
Name: "",
|
||||
SkillList: [4]skill.SkillInfo{},
|
||||
EffectInfo: make([]PetEffectInfo, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// GetCatchTimeAsTime 将捕捉时间转换为time.Time类型
|
||||
func (p *PetInfo) GetCatchTimeAsTime() time.Time {
|
||||
return time.Unix(int64(p.CatchTime), 0)
|
||||
}
|
||||
18
common/core/info/pet/skill/ChangeSkillInfo.go
Normal file
18
common/core/info/pet/skill/ChangeSkillInfo.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package skill
|
||||
|
||||
// ChangeSkillInfo 精灵技能变更信息结构体
|
||||
type ChangeSkillInfo struct {
|
||||
CatchTime uint32 // 精灵生成时间
|
||||
Reserved uint32 // 填充字段,默认为1
|
||||
Reserved1 uint32 // 填充字段,默认为1
|
||||
HasSkill uint32 // 拥有的技能id
|
||||
ReplaceSkill uint32 // 替换技能的id
|
||||
}
|
||||
|
||||
// NewChangeSkillInfo 创建一个新的技能变更信息实例
|
||||
func NewChangeSkillInfo() *ChangeSkillInfo {
|
||||
return &ChangeSkillInfo{
|
||||
Reserved: 1,
|
||||
Reserved1: 1,
|
||||
}
|
||||
}
|
||||
15
common/core/info/pet/skill/SkillInfo.go
Normal file
15
common/core/info/pet/skill/SkillInfo.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package skill
|
||||
|
||||
// SkillInfo 技能信息结构体
|
||||
type SkillInfo struct {
|
||||
ID uint32 // 技能id
|
||||
PP uint32 // 剩余pp
|
||||
}
|
||||
|
||||
// NewSkillInfo 创建一个新的技能信息实例
|
||||
func NewSkillInfo(id, pp uint32) *SkillInfo {
|
||||
return &SkillInfo{
|
||||
ID: id,
|
||||
PP: pp,
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package serialize
|
||||
|
||||
type ArraySerialize struct {
|
||||
OrderId int64 `v:"order-exist"`
|
||||
ProductName string
|
||||
Amount int64
|
||||
// ...
|
||||
}
|
||||
var paddedContent byte=0//长度不足时填充的内容, 默认填充0
|
||||
|
||||
380
common/serialize/Serialize.go
Normal file
380
common/serialize/Serialize.go
Normal file
@@ -0,0 +1,380 @@
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
// DefaultPacketSerializer 默认序列化实现,使用大端序写入数据
|
||||
func DefaultPacketSerializer[T any]() PacketSerializer[T] {
|
||||
return func(data T) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
if err := binary.Write(&buf, binary.BigEndian, data); err != nil {
|
||||
return nil, errors.New("binary.Write failed: " + err.Error())
|
||||
}
|
||||
// 使用大端序写入数据
|
||||
// 1. 使用reflect获取结构体类型
|
||||
// typ := reflect.TypeOf(data)
|
||||
// fmt.Println("结构体类型名称:", typ.Name())
|
||||
// fmt.Println("字段数量:", typ.NumField())
|
||||
|
||||
// for i := 0; i < typ.NumField(); i++ {
|
||||
// field := typ.Field(i)
|
||||
// fmt.Printf("字段名: %s, 类型: %s",
|
||||
// field.Name, field.Type)
|
||||
// fmt.Println("字段值:", reflect.ValueOf(data).Field(i).Interface())
|
||||
|
||||
// // writedata := reflect.ValueOf(data).Field(i).Interface()
|
||||
// fmt.Println(field.Type.Kind())
|
||||
|
||||
// // serializebase[T](field, &buf, writedata)
|
||||
|
||||
// }
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultPacketDeserializer 默认反序列化实现,使用大端序读取数据
|
||||
func DefaultPacketDeserializer[T any]() PacketDeserializer[T] {
|
||||
return func(data []byte) (T, error) {
|
||||
var result T
|
||||
reader := bytes.NewReader(data)
|
||||
// 使用大端序读取数据
|
||||
if err := binary.Read(reader, binary.BigEndian, &result); err != nil {
|
||||
var zero T
|
||||
return zero, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewDefaultPacketHandler 创建默认的数据包处理句柄
|
||||
func NewDefaultPacketHandler[T any]() *PacketHandler[T] {
|
||||
return &PacketHandler[T]{
|
||||
Serialize: DefaultPacketSerializer[T](),
|
||||
Deserialize: DefaultPacketDeserializer[T](),
|
||||
}
|
||||
}
|
||||
|
||||
type SerializeMode int
|
||||
|
||||
var lengthtype = enum.New[struct {
|
||||
LENGTH_FIRST SerializeMode
|
||||
FIXED_LENGTH SerializeMode
|
||||
}]()
|
||||
|
||||
// PacketSerializer 定义序列化函数类型,将数据转换为字节切片
|
||||
type PacketSerializer[T any] func(data T) ([]byte, error)
|
||||
|
||||
// PacketDeserializer 定义反序列化函数类型,将字节切片转换为数据
|
||||
type PacketDeserializer[T any] func(data []byte) (T, error)
|
||||
|
||||
// PacketHandler 封装序列化和反序列化处理函数
|
||||
type PacketHandler[T any] struct {
|
||||
Serialize PacketSerializer[T] // 序列化函数
|
||||
Deserialize PacketDeserializer[T] // 反序列化函数
|
||||
}
|
||||
|
||||
// 定长序列化器
|
||||
type FixedVarSerializer struct {
|
||||
byteOrder binary.ByteOrder
|
||||
}
|
||||
|
||||
// 新建序列化器
|
||||
func NewFixedVarSerializer(order binary.ByteOrder) *FixedVarSerializer {
|
||||
if order == nil {
|
||||
order = binary.BigEndian
|
||||
}
|
||||
return &FixedVarSerializer{byteOrder: order}
|
||||
}
|
||||
|
||||
// 序列化任意结构体
|
||||
func (s *FixedVarSerializer) Serialize(obj interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := s.serializeValue(reflect.ValueOf(obj), &buf)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("序列化失败: %w", err)
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// 递归序列化值
|
||||
func (s *FixedVarSerializer) serializeValue(val reflect.Value, buf *bytes.Buffer) error {
|
||||
kind := val.Kind()
|
||||
|
||||
switch kind {
|
||||
case reflect.Struct:
|
||||
return s.serializeStruct(val, buf)
|
||||
case reflect.Slice, reflect.Array:
|
||||
return s.serializeSlice(val, buf)
|
||||
default:
|
||||
if err := binary.Write(buf, s.byteOrder, val.Interface()); err != nil {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化结构体
|
||||
func (s *FixedVarSerializer) serializeStruct(val reflect.Value, buf *bytes.Buffer) error {
|
||||
typ := val.Type()
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
field := typ.Field(i)
|
||||
fieldVal := val.Field(i)
|
||||
|
||||
if !field.IsExported() {
|
||||
continue
|
||||
}
|
||||
|
||||
// 解析标签(格式:mode,params 如 fixed:16 或 varlen)
|
||||
tag := field.Tag.Get("serialize")
|
||||
if tag == "" {
|
||||
// 未指定标签:按原生类型序列化
|
||||
err := s.serializeValue(fieldVal, buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// 解析模式和参数
|
||||
mode, params, err := parseTag(tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 根据模式序列化
|
||||
switch mode {
|
||||
case lengthtype.FIXED_LENGTH:
|
||||
err = s.serializeFixedField(fieldVal, params, buf)
|
||||
case lengthtype.LENGTH_FIRST:
|
||||
err = s.serializeVarWithLenField(fieldVal, params, buf)
|
||||
default:
|
||||
return fmt.Errorf("无效的序列化模式: %s", tag)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 解析标签(格式:fixed:N 或 varlen 或 varlen:N)
|
||||
func parseTag(tag string) (SerializeMode, string, error) {
|
||||
parts := splitTag(tag)
|
||||
if len(parts) == 0 {
|
||||
return 0, "", fmt.Errorf("空标签")
|
||||
}
|
||||
|
||||
modeStr := parts[0]
|
||||
params := ""
|
||||
if len(parts) > 1 {
|
||||
params = parts[1]
|
||||
}
|
||||
|
||||
switch modeStr {
|
||||
case "fixed":
|
||||
if params == "" {
|
||||
return 0, "", fmt.Errorf("fixed模式需指定长度")
|
||||
}
|
||||
return lengthtype.FIXED_LENGTH, params, nil
|
||||
case "varlen":
|
||||
// varlen模式:可指定长度字段字节数(如varlen:2表示用2字节存长度)
|
||||
if params == "" {
|
||||
params = "4" // 默认用4字节存长度
|
||||
}
|
||||
return lengthtype.LENGTH_FIRST, params, nil
|
||||
default:
|
||||
return 0, "", fmt.Errorf("未知模式: %s", modeStr)
|
||||
}
|
||||
}
|
||||
|
||||
// 定长模式序列化字段
|
||||
func (s *FixedVarSerializer) serializeFixedField(val reflect.Value, lengthStr string, buf *bytes.Buffer) error {
|
||||
length, err := strconv.Atoi(lengthStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("无效的定长参数: %s", lengthStr)
|
||||
}
|
||||
return s.serializeFixedLengthValue(val, length, buf)
|
||||
}
|
||||
|
||||
// 不定长+长度模式序列化字段
|
||||
func (s *FixedVarSerializer) serializeVarWithLenField(val reflect.Value, lenBytesStr string, buf *bytes.Buffer) error {
|
||||
lenBytes, err := strconv.Atoi(lenBytesStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("无效的长度字节数: %s", lenBytesStr)
|
||||
}
|
||||
if lenBytes < 1 || lenBytes > 8 {
|
||||
return fmt.Errorf("长度字节数需在1-8之间")
|
||||
}
|
||||
|
||||
// 先序列化内容到临时缓冲区
|
||||
var contentBuf bytes.Buffer
|
||||
err = s.serializeValue(val, &contentBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content := contentBuf.Bytes()
|
||||
|
||||
// 写入长度(用指定字节数)
|
||||
|
||||
lenBuf := make([]byte, lenBytes)
|
||||
switch lenBytesStr {
|
||||
case "4":
|
||||
s.byteOrder.PutUint32(lenBuf, uint32(len(content)))
|
||||
case "2":
|
||||
s.byteOrder.PutUint16(lenBuf, uint16(len(content)))
|
||||
}
|
||||
//s.byteOrder.PutUint32(lenBuf, uint32(len(content)))
|
||||
buf.Write(lenBuf[:lenBytes])
|
||||
|
||||
// 写入内容
|
||||
buf.Write(content)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 序列化定长值
|
||||
func (s *FixedVarSerializer) serializeFixedLengthValue(val reflect.Value, length int, buf *bytes.Buffer) error {
|
||||
kind := val.Kind()
|
||||
|
||||
if kind == reflect.String {
|
||||
str := val.String()
|
||||
if len(str) > length {
|
||||
str = str[:length]
|
||||
}
|
||||
buf.WriteString(str)
|
||||
buf.Write(make([]byte, length-len(str)))
|
||||
return nil
|
||||
}
|
||||
|
||||
var tmpBuf bytes.Buffer
|
||||
fmt.Println(val)
|
||||
err := s.serializeValue(val, &tmpBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmpData := tmpBuf.Bytes()
|
||||
|
||||
if len(tmpData) > length {
|
||||
buf.Write(tmpData[:length])
|
||||
} else {
|
||||
buf.Write(tmpData)
|
||||
buf.Write(make([]byte, length-len(tmpData)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 序列化slice
|
||||
func (s *FixedVarSerializer) serializeSlice(val reflect.Value, buf *bytes.Buffer) error {
|
||||
tempslice := gconv.SliceAny(val)
|
||||
fmt.Println(val)
|
||||
//binary.Write(buf, s.byteOrder, val.Bytes())
|
||||
for i := 0; i < len(tempslice); i++ {
|
||||
err := s.serializeValue(val.Index(i), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// for i := 0; i < len(tempslice); i++ {
|
||||
// kind := val.Type().Elem().Field(i)
|
||||
|
||||
// tag := kind.Tag.Get("serialize")
|
||||
|
||||
// // 检查元素是否有标签
|
||||
// if tag != "" {
|
||||
// // 元素有标签:按定长模式处理
|
||||
// mode, params, err := parseTag(tag)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// if mode == lengthtype.FIXED_LENGTH {
|
||||
// // 定长slice:解析maxItems和itemLen
|
||||
// parts := splitTag(params)
|
||||
// if len(parts) != 2 {
|
||||
// return fmt.Errorf("定长slice标签需格式为 fixed:N,M")
|
||||
// }
|
||||
// maxItems, _ := strconv.Atoi(parts[0])
|
||||
// itemLen, _ := strconv.Atoi(parts[1])
|
||||
// return s.serializeFixedSlice(val, maxItems, itemLen, buf)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 无标签或不定长模式:按原生slice处理(先写长度,再写元素)
|
||||
|
||||
// count := val.Len()
|
||||
// binary.Write(buf, s.byteOrder, int32(len(tempslice)))
|
||||
// for i := 0; i < count; i++ {
|
||||
// err := s.serializeValue(val.Index(i), buf)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
return nil
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 序列化定长slice
|
||||
func (s *FixedVarSerializer) serializeFixedSlice(val reflect.Value, maxItems, itemLen int, buf *bytes.Buffer) error {
|
||||
count := val.Len()
|
||||
if count > maxItems {
|
||||
count = maxItems
|
||||
}
|
||||
|
||||
buf.WriteByte(byte(count))
|
||||
|
||||
for i := 0; i < maxItems; i++ {
|
||||
if i < count {
|
||||
item := val.Index(i)
|
||||
tmpBuf := &bytes.Buffer{}
|
||||
err := s.serializeValue(item, tmpBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmpData := tmpBuf.Bytes()
|
||||
|
||||
if len(tmpData) > itemLen {
|
||||
buf.Write(tmpData[:itemLen])
|
||||
} else {
|
||||
buf.Write(tmpData)
|
||||
buf.Write(make([]byte, itemLen-len(tmpData)))
|
||||
}
|
||||
} else {
|
||||
buf.Write(make([]byte, itemLen))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 辅助函数:分割标签参数
|
||||
func splitTag(tag string) []string {
|
||||
if tag == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(tag, ":")
|
||||
}
|
||||
|
||||
// 示例结构体(混合模式)
|
||||
type Address struct {
|
||||
City string `serialize:"fixed:20"` // 定长模式:20字节
|
||||
Country string `serialize:"varlen"` // 不定长模式:先写4字节长度,再写内容
|
||||
}
|
||||
|
||||
type Person struct {
|
||||
Name string `serialize:"fixed:16"` // 定长姓名
|
||||
Age uint8 // 原生类型
|
||||
Address Address // 嵌套结构体
|
||||
Hobbies []string `serialize:"fixed:5,20"` // 定长slice:5个元素,每个20字节
|
||||
Friends []Person `serialize:"varlen"` // 不定长slice:先写长度,再写内容
|
||||
Metadata []float64 `serialize:"varlen:2"` // 不定长slice:用2字节存长度
|
||||
}
|
||||
42
common/serialize/Serialize_test.go
Normal file
42
common/serialize/Serialize_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"blazing/common/core/info"
|
||||
"blazing/common/core/info/pet"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDefaultPacketSerializer(t *testing.T) {
|
||||
serializer := NewFixedVarSerializer(nil)
|
||||
|
||||
tt := info.NewServerInfo()
|
||||
tt.OnlineID = 99
|
||||
tt.IP = "127.0.0.1"
|
||||
// tt1 := serialize.NewDefaultPacketHandler[info.ServerInfo]()
|
||||
// tg, _ := tt1.Serialize(*tt)
|
||||
// 序列化
|
||||
data, err := serializer.Serialize(*tt)
|
||||
if err != nil {
|
||||
fmt.Println("错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("序列化数据(长度: %d字节):\n%x\n", len(data), data)
|
||||
}
|
||||
func TestDefaultPacketSerializerPet(t *testing.T) {
|
||||
serializer := NewFixedVarSerializer(nil)
|
||||
|
||||
tt := pet.NewPetInfo()
|
||||
|
||||
// tt1 := serialize.NewDefaultPacketHandler[info.ServerInfo]()
|
||||
// tg, _ := tt1.Serialize(*tt)
|
||||
// 序列化
|
||||
data, err := serializer.Serialize(*tt)
|
||||
if err != nil {
|
||||
fmt.Println("错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("序列化数据(长度: %d字节):\n%x\n", len(data), data)
|
||||
}
|
||||
@@ -29,16 +29,16 @@ var bufferpool = &sync.Pool{
|
||||
// CreateByteArray 创建一个新的ByteArray实例,使用指定的字节数组
|
||||
func CreateByteArray(bytes ...[]byte) *ByteArray {
|
||||
var ba *ByteArray
|
||||
if len(bytes) == 0 {//如果是0,则为新创建
|
||||
if len(bytes) == 0 { //如果是0,则为新创建
|
||||
ba = bufferpool.Get().(*ByteArray)
|
||||
}else{//读序列
|
||||
ba =&ByteArray{endian: defaultEndian}
|
||||
} else { //读序列
|
||||
ba = &ByteArray{endian: defaultEndian}
|
||||
}
|
||||
|
||||
|
||||
for _, num := range bytes {
|
||||
ba.buf=append(ba.buf, num...)
|
||||
}
|
||||
|
||||
ba.buf = append(ba.buf, num...)
|
||||
}
|
||||
|
||||
ba.ResetPos()
|
||||
return ba
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func (ba *ByteArray) Reset() {
|
||||
|
||||
// Bytes 返回完整的字节数组
|
||||
func (ba *ByteArray) Bytes() []byte {
|
||||
defer releaseByteArray(ba)//这里是写数组,写完后退出时释放线程池
|
||||
defer releaseByteArray(ba) //这里是写数组,写完后退出时释放线程池
|
||||
return ba.buf
|
||||
}
|
||||
|
||||
@@ -201,8 +201,8 @@ func (ba *ByteArray) WriteInt64(value int64) error {
|
||||
return ba.writeNumber(value)
|
||||
}
|
||||
|
||||
// WriteUInt64 写入uint64,根据当前字节序处理
|
||||
func (ba *ByteArray) WriteUInt64(value uint64) error {
|
||||
// Writeuint32 写入uint32,根据当前字节序处理
|
||||
func (ba *ByteArray) Writeuint32(value uint32) error {
|
||||
return ba.writeNumber(value)
|
||||
}
|
||||
|
||||
@@ -413,16 +413,16 @@ func (ba *ByteArray) ReadUInt32() (uint32, error) {
|
||||
|
||||
// ReadInt64 读取int64,根据当前字节序处理
|
||||
func (ba *ByteArray) ReadInt64() (int64, error) {
|
||||
var v uint64
|
||||
var v uint32
|
||||
if err := ba.readNumber(&v); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int64(v), nil
|
||||
}
|
||||
|
||||
// ReadUInt64 读取uint64,根据当前字节序处理
|
||||
func (ba *ByteArray) ReadUInt64() (uint64, error) {
|
||||
var v uint64
|
||||
// Readuint32 读取uint32,根据当前字节序处理
|
||||
func (ba *ByteArray) Readuint32() (uint32, error) {
|
||||
var v uint32
|
||||
if err := ba.readNumber(&v); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gvalid"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
OrderId int64 `v:"order-exist"`
|
||||
ProductName string `v:"order-exist"`
|
||||
Amount int64
|
||||
// ...
|
||||
}
|
||||
|
||||
func RuleOrderExist(ctx context.Context, in gvalid.RuleFuncInput) error {
|
||||
fmt.Println(in)
|
||||
return nil
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func Test_main(t *testing.T) {
|
||||
var (
|
||||
ctx = gctx.New()
|
||||
req = &Request{
|
||||
OrderId: 65535,
|
||||
ProductName: "HikingShoe",
|
||||
Amount: 10000,
|
||||
}
|
||||
)
|
||||
err := g.Validator().RuleFunc("order-exist", RuleOrderExist).Data(req).Run(ctx)
|
||||
fmt.Println(err)
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
package serialize
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/gvalid"
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
var lengthtype = enum.New[struct {
|
||||
LENGTH_FIRST int
|
||||
FIXED_LENGTH int
|
||||
}]()
|
||||
|
||||
// PacketSerializer 定义序列化函数类型,将数据转换为字节切片
|
||||
type PacketSerializer[T any] func(data T) ([]byte, error)
|
||||
|
||||
// PacketDeserializer 定义反序列化函数类型,将字节切片转换为数据
|
||||
type PacketDeserializer[T any] func(data []byte) (T, error)
|
||||
|
||||
// PacketHandler 封装序列化和反序列化处理函数
|
||||
type PacketHandler[T any] struct {
|
||||
Serialize PacketSerializer[T] // 序列化函数
|
||||
Deserialize PacketDeserializer[T] // 反序列化函数
|
||||
}
|
||||
|
||||
|
||||
|
||||
func serializebase[T any](field reflect.StructField, buf *bytes.Buffer, writedata any) error {
|
||||
|
||||
|
||||
if field.Type.Kind() == reflect.Slice { //|| field.Type.Kind() == reflect.Array}
|
||||
|
||||
datatype := make(chan int, 1)
|
||||
FIXED_LENGTH := func(ctx context.Context, in gvalid.RuleFuncInput) error {
|
||||
if in.Field == field.Name { //判断相同
|
||||
datatype <- lengthtype.FIXED_LENGTH
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
LENGTH_FIRST := func(ctx context.Context, in gvalid.RuleFuncInput) error {
|
||||
datatype <- lengthtype.FIXED_LENGTH
|
||||
// fmt.Println(in)
|
||||
return nil
|
||||
}
|
||||
length := func(ctx context.Context, in gvalid.RuleFuncInput) error {
|
||||
tem := <-datatype
|
||||
close(datatype)
|
||||
writelen := 0
|
||||
if parts := strings.Split(in.Rule, ":"); len(parts) > 1 {
|
||||
writelen = gconv.Int(strings.TrimSpace(parts[1]))
|
||||
|
||||
}
|
||||
switch tem {
|
||||
case lengthtype.FIXED_LENGTH: //in.value
|
||||
tempslice := gconv.SliceAny(writedata)
|
||||
temp := make([]byte, writelen-len(tempslice))
|
||||
|
||||
for i := 0; i < len(tempslice); i++ {
|
||||
tempdata := tempslice[i]
|
||||
fmt.Println(i)
|
||||
serializebase[T]( field, buf, tempdata) //todo递归序列化
|
||||
// copy(temp, date1)
|
||||
// if err := binary.Write(buf, binary.BigEndian, temp); err != nil {
|
||||
// return nil
|
||||
// }
|
||||
}
|
||||
|
||||
if err := binary.Write(buf, binary.BigEndian, temp); err != nil {
|
||||
return nil
|
||||
}
|
||||
case lengthtype.LENGTH_FIRST:
|
||||
// temp := make([]byte, writelen)
|
||||
// date1 := []byte(writedata.(string))
|
||||
// copy(temp, date1)
|
||||
// if err := binary.Write(buf, binary.BigEndian, temp); err != nil {
|
||||
// return nil
|
||||
// }
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
rules := make(map[string]gvalid.RuleFunc, 3)
|
||||
rules["LENGTH_FIRST"] = LENGTH_FIRST
|
||||
rules["FIXED_LENGTH"] = FIXED_LENGTH
|
||||
rules["length"] = length
|
||||
g.Validator().RuleFuncMap(rules).Data(writedata).Run(gctx.New())
|
||||
// serializeslice[T](field, buf, writedata)
|
||||
} else {
|
||||
if err := binary.Write(buf, binary.BigEndian, writedata); err != nil {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultPacketSerializer 默认序列化实现,使用大端序写入数据
|
||||
func DefaultPacketSerializer[T any]() PacketSerializer[T] {
|
||||
return func(data T) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
// 使用大端序写入数据
|
||||
// 1. 使用reflect获取结构体类型
|
||||
typ := reflect.TypeOf(data)
|
||||
fmt.Println("结构体类型名称:", typ.Name())
|
||||
fmt.Println("字段数量:", typ.NumField())
|
||||
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
field := typ.Field(i)
|
||||
fmt.Printf("字段名: %s, 类型: %s",
|
||||
field.Name, field.Type)
|
||||
fmt.Println("字段值:", reflect.ValueOf(data).Field(i).Interface())
|
||||
|
||||
writedata := reflect.ValueOf(data).Field(i).Interface()
|
||||
fmt.Println(field.Type.Kind())
|
||||
|
||||
serializebase[T]( field, &buf, writedata)
|
||||
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultPacketDeserializer 默认反序列化实现,使用大端序读取数据
|
||||
func DefaultPacketDeserializer[T any]() PacketDeserializer[T] {
|
||||
return func(data []byte) (T, error) {
|
||||
var result T
|
||||
reader := bytes.NewReader(data)
|
||||
// 使用大端序读取数据
|
||||
if err := binary.Read(reader, binary.BigEndian, &result); err != nil {
|
||||
var zero T
|
||||
return zero, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewDefaultPacketHandler 创建默认的数据包处理句柄
|
||||
func NewDefaultPacketHandler[T any]() *PacketHandler[T] {
|
||||
return &PacketHandler[T]{
|
||||
Serialize: DefaultPacketSerializer[T](),
|
||||
Deserialize: DefaultPacketDeserializer[T](),
|
||||
}
|
||||
}
|
||||
|
||||
// 示例:使用自定义类型演示序列化与反序列化
|
||||
type ExampleData struct {
|
||||
ID int32
|
||||
Name string
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// 自定义序列化函数(处理结构体类型)
|
||||
func CustomSerializer() PacketSerializer[ExampleData] {
|
||||
return func(data ExampleData) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
// 先序列化基本类型字段
|
||||
if err := binary.Write(&buf, binary.BigEndian, data.ID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 序列化字符串长度和内容
|
||||
lenName := int32(len(data.Name))
|
||||
if err := binary.Write(&buf, binary.BigEndian, lenName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := buf.Write([]byte(data.Name)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 序列化字节数组长度和内容
|
||||
lenData := int32(len(data.Data))
|
||||
if err := binary.Write(&buf, binary.BigEndian, lenData); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := buf.Write(data.Data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义反序列化函数(处理结构体类型)
|
||||
func CustomDeserializer() PacketDeserializer[ExampleData] {
|
||||
return func(data []byte) (ExampleData, error) {
|
||||
var result ExampleData
|
||||
reader := bytes.NewReader(data)
|
||||
|
||||
// 读取基本类型字段
|
||||
if err := binary.Read(reader, binary.BigEndian, &result.ID); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
// 读取字符串长度和内容
|
||||
var lenName int32
|
||||
if err := binary.Read(reader, binary.BigEndian, &lenName); err != nil {
|
||||
return result, err
|
||||
}
|
||||
if lenName > int32(reader.Len()) {
|
||||
return result, errors.New("invalid name length")
|
||||
}
|
||||
nameBuf := make([]byte, lenName)
|
||||
if _, err := reader.Read(nameBuf); err != nil {
|
||||
return result, err
|
||||
}
|
||||
result.Name = string(nameBuf)
|
||||
|
||||
// 读取字节数组长度和内容
|
||||
var lenData int32
|
||||
if err := binary.Read(reader, binary.BigEndian, &lenData); err != nil {
|
||||
return result, err
|
||||
}
|
||||
if lenData > int32(reader.Len()) {
|
||||
return result, errors.New("invalid data length")
|
||||
}
|
||||
result.Data = make([]byte, lenData)
|
||||
if _, err := reader.Read(result.Data); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"blazing/common/core/info"
|
||||
"blazing/common/serialize"
|
||||
"blazing/common/socket"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
tt := info.NewServerInfo()
|
||||
tt.OnlineID = 99
|
||||
tt.IP = []byte("127.0.0.1")
|
||||
tt1 := serialize.NewDefaultPacketHandler[info.ServerInfo]()
|
||||
tg, _ := tt1.Serialize(*tt)
|
||||
|
||||
fmt.Println(tg)
|
||||
//fmt.Println(tt)
|
||||
socket.NewServer(socket.WithPort("9999")).Start()
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ func (s *BaseSysDepartmentService) Order(ctx g.Ctx) (err error) {
|
||||
r := g.RequestFromCtx(ctx).GetMap()
|
||||
|
||||
type item struct {
|
||||
Id uint64 `json:"id"`
|
||||
ParentId *uint64 `json:"parentId,omitempty"`
|
||||
Id uint32 `json:"id"`
|
||||
ParentId *uint32 `json:"parentId,omitempty"`
|
||||
OrderNum int32 `json:"orderNum"`
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ module blazing/modules/demo
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
)
|
||||
require github.com/gogf/gf/v2 v2.6.3
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
@@ -18,6 +16,7 @@ require (
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
@@ -33,6 +32,7 @@ require (
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/gorm v1.25.7 // indirect
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
@@ -28,6 +28,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -70,6 +71,7 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
|
||||
@@ -2,10 +2,7 @@ module blazing/modules/dict
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
)
|
||||
require github.com/gogf/gf/v2 v2.6.3
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
@@ -19,6 +16,7 @@ require (
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
@@ -34,6 +32,7 @@ require (
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/gorm v1.25.7 // indirect
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
@@ -28,6 +28,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -70,6 +71,7 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
|
||||
@@ -2,10 +2,7 @@ module blazing/modules/space
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
)
|
||||
require github.com/gogf/gf/v2 v2.6.3
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
@@ -19,6 +16,7 @@ require (
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
@@ -34,6 +32,7 @@ require (
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/gorm v1.25.7 // indirect
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
@@ -28,6 +28,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -70,6 +71,7 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
|
||||
@@ -3,7 +3,6 @@ module blazing/modules/task
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/robfig/cron v1.2.0
|
||||
)
|
||||
@@ -20,6 +19,7 @@ require (
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
@@ -35,6 +35,7 @@ require (
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/gorm v1.25.7 // indirect
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
blazing/cool v1.5.9 h1:mvZkckumdnhkr8BGRbB+FKmUeP3tbxmyvSxfNyZAlhE=
|
||||
blazing/cool v1.5.9/go.mod h1:kle9oSJM+yl8ZtQwZFL8PWbz7ByI8Glj1431njGbWPo=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
@@ -28,6 +28,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -72,6 +73,7 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
|
||||
@@ -9,7 +9,7 @@ const TableNameTaskLog = "task_log"
|
||||
// TaskLog mapped from table <task_log>
|
||||
type TaskLog struct {
|
||||
*cool.Model
|
||||
TaskId uint64 `gorm:"column:taskId;comment:任务ID" json:"taskId"`
|
||||
TaskId uint32 `gorm:"column:taskId;comment:任务ID" json:"taskId"`
|
||||
Status uint8 `gorm:"column:status;not null;comment:状态 0:失败 1:成功" json:"status"`
|
||||
Detail string `gorm:"column:detail;comment:详情" json:"detail"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user