This commit is contained in:
昔念
2026-04-25 23:05:41 +08:00
parent 415315c288
commit 4906197c77
18 changed files with 1009 additions and 31 deletions

View File

@@ -2,10 +2,12 @@ package admin
import (
"blazing/cool"
configService "blazing/modules/config/service"
"blazing/modules/player/service"
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
type PVPController struct {
@@ -30,14 +32,71 @@ type GetPVPReq struct {
func (c *PVPController) Get(ctx context.Context, req *GetPVPReq) (res *cool.BaseRes, err error) {
res = &cool.BaseRes{}
//var ret []TitleRes
var (
admin = cool.GetAdmin(ctx)
//r = g.RequestFromCtx(ctx)
admin = cool.GetAdmin(ctx)
pvpInfo = service.NewPVPService(uint32(admin.UserId)).Get(uint32(admin.UserId))
tianxuanSv = configService.NewPeakTianxuanService()
votePool []g.Map
currentPool []g.Map
prevWeekPool []g.Map
weekIndex uint32
prevWeekIndex uint32
)
alltitile := service.NewPVPService(uint32(admin.UserId)).Get(uint32(admin.UserId))
if votePool, weekIndex, prevWeekIndex, err = tianxuanSv.BuildVoteCandidatePoolPayload(); err != nil {
return
}
if currentPool, _, err = tianxuanSv.BuildCurrentTianxuanPayload(); err != nil {
return
}
if prevWeekPool, err = tianxuanSv.BuildWeekTianxuanPayload(prevWeekIndex); err != nil {
return
}
res.Data = alltitile
res.Data = g.Map{
"id": pvpInfo.ID,
"player_id": pvpInfo.PlayerID,
"season": pvpInfo.Season,
"rank_info": pvpInfo.RankInfo,
"required_tianxuan_vote_count": 1,
"tianxuan_week_index": weekIndex,
"tianxuan_prev_week_index": prevWeekIndex,
"tianxuan_vote_pool": votePool,
"tianxuan_prev_week_pool": prevWeekPool,
"current_tianxuan_pool": currentPool,
}
return
}
type SaveTianxuanVoteReq struct {
g.Meta `path:"/save_tianxuan_vote" method:"POST"`
PetIDs []uint32 `json:"pet_ids"`
}
func (c *PVPController) SaveTianxuanVote(ctx context.Context, req *SaveTianxuanVoteReq) (res *cool.BaseRes, err error) {
res = &cool.BaseRes{}
var (
admin = cool.GetAdmin(ctx)
petID uint32
saved uint32
)
for _, item := range req.PetIDs {
if item == 0 {
continue
}
petID = gconv.Uint32(item)
break
}
if saved, err = configService.NewPeakTianxuanService().SaveVote(uint32(admin.UserId), petID); err != nil {
return
}
res.Data = g.Map{
"saved_pet_id": saved,
"required_tianxuan_vote_count": 1,
}
return
}