```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

refactor(cool): 移除Redis监听功能和用户结构体定义

移除ListenFunc函数,该函数提供Redis PubSub监听功能,
包括自动重连和心跳保活机制。同时删除User结构体定义和
相关有序集合变量,这些功能将由rpc模块替代实现。

feat(rpc): 添加对ListenFunc的调用以处理Redis监听

在login模块中
This commit is contained in:
昔念
2026-03-04 23:38:21 +08:00
parent 4751594ee8
commit aa53001982
8 changed files with 416 additions and 188 deletions

View File

@@ -0,0 +1,32 @@
package model
import "blazing/cool"
// PVPMatchRecord PVP单场记录
// 记录每一场的详细信息,便于复盘和统计
type PVPMatchRecord struct {
*cool.Model
Noteinfo NoteReadyToFightInfo `gorm:"type:jsonb; " ` //携带信息
FightOver FightOverInfo `gorm:"type:jsonb; " ` //结束信息
//ScoreChange int32 `json:"score_change"` // 本场积分变化(+10/-5等
// WinStreak uint32 `json:"win_streak"` // 本场结束后的连胜数
}
// 表名常量
const TableNameFightinfo = "player_fight_info"
// TableName 返回表名
func (*PVPMatchRecord) TableName() string {
return TableNameFightinfo
}
// GroupName 返回表组名
func (*PVPMatchRecord) GroupName() string {
return "default"
}
// init 程序启动时自动创建表
func init() {
cool.CreateTable(&PVPMatchRecord{})
}

View File

@@ -12,42 +12,33 @@ const TableNamePlayerPVP = "player_pvp"
// PVP 对应数据库表 player_pvp用于记录用户PVP赛季数据及场次统计
type PVP struct {
Base
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_pvp_player_id;comment:'所属玩家ID'" json:"player_id"`
//SeasonID uint32 `gorm:"not null;index:idx_pvp_season_id;comment:'赛季ID如2026S1=101'" json:"season_id"`
SeasonData []PVPRankInfo `gorm:"type:jsonb;not null;comment:'赛季核心数据'" json:"season_data"`
MatchRecords []PVPMatchRecord `gorm:"type:jsonb;not null;comment:'本赛季场次记录仅存最近100场'" json:"match_records"`
RankInfo PVPRankInfo `gorm:"type:jsonb;not null;comment:'本赛季排名信息'" json:"rank_info"`
SeasonData []PVPRankInfo `gorm:"type:jsonb;not null;comment:'赛季核心数据'" json:"season_data"`
RankInfo PVPRankInfo `gorm:"type:jsonb;not null;comment:'本赛季排名信息'" json:"rank_info"`
}
func NewPVP() *PVP {
return &PVP{
Model: cool.NewModel(),
}
}
// PVPSeasonData PVP赛季核心统计数据
// 聚合维度:总场次、胜负、积分、胜率等
type PVPRankInfo struct {
Rank uint32 `json:"rank"` // 本赛季全服排名0=未上榜)
Segment uint32 `json:"segment"` // 段位ID如1=青铜 2=白银...
SegmentStar uint32 `json:"segment_star"` // 段位星级如青铜3星
NextSegmentScore int32 `json:"next_segment_score"` // 升段所需积分
TotalMatch uint32 `json:"total_match"` // 本赛季场次
WinMatch uint32 `json:"win_match"` // 本赛季胜利场次
LoseMatch uint32 `json:"lose_match"` // 本赛季失败场次
DrawMatch uint32 `json:"draw_match"` // 本赛季平局场次
TotalScore int32 `json:"total_score"` // 本赛季总积分(胜加负减)
HighestScore int32 `json:"highest_score"` // 本赛季最高积分
ContinuousWin uint32 `json:"continuous_win"` // 本赛季最高连胜次数
LastMatchTime uint64 `json:"last_match_time"` // 最后一场PVP时间时间戳
}
// PVPMatchRecord PVP单场记录
// 记录每一场的详细信息,便于复盘和统计
type PVPMatchRecord struct {
MatchID string `json:"match_id"` // 匹配局ID全局唯一
MatchTime uint64 `json:"match_time"` // 对局时间(时间戳)
NoteReadyToFightInfo
Result uint32 `json:"result"` // 对局结果0=负 1=胜 2=平
ScoreChange int32 `json:"score_change"` // 本场积分变化(+10/-5等
UsedPetIDs []uint32 `json:"used_pet_ids"` // 本场使用的精灵ID列表
WinStreak uint32 `json:"win_streak"` // 本场结束后的连胜数
Duration uint32 `json:"duration"` // 对局时长(秒)
Rank uint32 `json:"rank"` // 本赛季全服排名0=未上榜)
Score int32 `json:"score"` // 当前积分
TotalMatch uint32 `json:"total_match"` // 本赛季总场次
WinMatch uint32 `json:"win_match"` // 本赛季胜利场次
LoseMatch uint32 `json:"lose_match"` // 本赛季失败场次
DrawMatch uint32 `json:"draw_match"` // 本赛季平局场次
TotalScore int32 `json:"total_score"` // 本赛季总积分(胜加负减)
HighestScore int32 `json:"highest_score"` // 本赛季最高积分
ContinuousWin uint32 `json:"continuous_win"` // 本赛季最高连胜次数
LastMatchTime uint64 `json:"last_match_time"` // 最后一场PVP时间时间戳
}
// NoteReadyToFightInfo 战斗准备就绪消息结构体NoteReadyToFightInfo
@@ -127,6 +118,7 @@ type FightOverInfo struct {
Winpet *PetInfo `struc:"skip"`
Round uint32 `struc:"skip"`
LastAttavue AttackValue `struc:"skip"`
Duration uint32 `struc:"skip"` // 对局时长(秒)
//7 切磋结束
Reason EnumBattleOverReason // 固定值0
WinnerId uint32 // 胜者的米米号 野怪为0

View File

@@ -0,0 +1,30 @@
package service
import (
"blazing/cool"
"blazing/modules/player/model"
)
type PVPService struct {
BaseService
}
func NewPVPService(id uint32) *PVPService {
return &PVPService{
BaseService: BaseService{userid: id,
Service: &cool.Service{Model: model.NewPVP()},
},
}
}
func (s *PVPService) Get(userid uint32) (ret *model.PVP) {
//todo待测试
m := s.dbm_fix(s.Model)
m.Scan(&ret)
return
}