package handler import ( "honoka-chan/config" "honoka-chan/internal/model" "honoka-chan/internal/session" "honoka-chan/internal/tools" "net/http" "strconv" "time" "github.com/gin-gonic/gin" ) func UserInfo(ctx *gin.Context) { ss := session.New(ctx) defer ss.Finalize() userId, err := strconv.Atoi(ctx.GetString("userid")) if ss.CheckErr(err) { return } pref := tools.UserPref{} exists, err := ss.UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref) if ss.CheckErr(err) { return } if !exists { ctx.String(http.StatusForbidden, ErrorMsg) return } userResp := model.UserInfoResp{ ResponseData: model.UserInfoRes{ User: model.UserInfo{ UserID: userId, Name: pref.UserName, Level: config.Conf.UserPrefs.Level, Exp: config.Conf.UserPrefs.ExpNumerator, PreviousExp: 0, NextExp: config.Conf.UserPrefs.ExpDenominator, GameCoin: config.Conf.UserPrefs.GameCoin, SnsCoin: config.Conf.UserPrefs.SnsCoin, FreeSnsCoin: config.Conf.UserPrefs.SnsCoin, PaidSnsCoin: 0, SocialPoint: 1438395, UnitMax: 5000, WaitingUnitMax: 1000, EnergyMax: config.Conf.UserPrefs.EnergyMax, EnergyFullTime: "2023-03-20 03:58:55", LicenseLiveEnergyRecoverlyTime: 60, EnergyFullNeedTime: 0, OverMaxEnergy: config.Conf.UserPrefs.OverMaxEnergy, TrainingEnergy: 100, TrainingEnergyMax: 100, FriendMax: 99, InviteCode: config.Conf.UserPrefs.InviteCode, InsertDate: "2015-08-10 18:58:30", UpdateDate: "2018-08-09 18:13:12", TutorialState: -1, DiamondCoin: 0, CrystalCoin: 0, LpRecoveryItem: []model.LpRecoveryItem{}, }, Birth: model.Birth{ BirthMonth: 10, BirthDay: 18, }, ServerTimestamp: time.Now().Unix(), }, ReleaseInfo: []any{}, StatusCode: 200, } ss.Respond(userResp) }