feat(login): 重构登录逻辑并迁移每日重置功能到 Personself 方法

将原本在 Controller.Login 中处理的每日重置逻辑(如电池、任务等)迁移到
service.Info.Personself 方法中,并移除对 gtime.Now().Time 的旧引用。同时更新了
相关的时间判断函数 IsToday,使其支持 *gtime.Time 类型。

此外,清理无用导入包,优化日志打印方式,并修复部分结构体字段定义与使用问题。
This commit is contained in:
2025-12-07 19:23:44 +08:00
parent eef702e25a
commit 294cb2e3fd
9 changed files with 64 additions and 38 deletions

View File

@@ -3,17 +3,18 @@ package model
import (
"blazing/cool"
"math"
"time"
"github.com/creasty/defaults"
"github.com/gogf/gf/v2/os/gtime"
)
const TableNamePlayerInfo = "player_info"
type Player struct {
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
Data string `gorm:"type:jsonb;not null;comment:'全部数据'" json:"data"`
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
LastResetTime *gtime.Time `struc:"skip" json:"last_reset_time"` // 重置时间,比如电池和每日任务
Data string `gorm:"type:jsonb;not null;comment:'全部数据'" json:"data"`
}
type PlayerEX struct {
Player
@@ -67,9 +68,9 @@ func NewPlayerInfo() PlayerInfo {
}
type PlayerInfo struct {
ExpPool uint32 `struc:"skip" json:"exp_pool"` // 累计经验池
LastResetTime time.Time `struc:"skip" json:"last_reset_time"` // 重置时间,比如电池和每日任务
OnlineTime uint32 `struc:"skip" json:"online_time"` //在线分钟数
ExpPool uint32 `struc:"skip" json:"exp_pool"` // 累计经验池
//LastResetTime time.Time `struc:"skip" json:"last_reset_time"` // 重置时间,比如电池和每日任务
OnlineTime uint32 `struc:"skip" json:"online_time"` //在线分钟数
// OutInfo 字段
UserID uint32 `struc:"uint32" json:"user_id"` // 米米号 通过sid拿到
RegisterTime uint32 `struc:"uint32" json:"register_time"` // 注册时间(秒时间戳)