Reorganize directory structures
Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/internal/model"
|
||||
"honoka-chan/internal/tools"
|
||||
"honoka-chan/internal/utils"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func UserInfo(ctx *gin.Context) {
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
utils.CheckErr(err)
|
||||
|
||||
pref := tools.UserPref{}
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
utils.CheckErr(err)
|
||||
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,
|
||||
}
|
||||
resp, err := json.Marshal(userResp)
|
||||
utils.CheckErr(err)
|
||||
|
||||
ctx.Header("X-Message-Sign", utils.GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
Reference in New Issue
Block a user