mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
大量优化
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package api
|
||||
|
||||
type ComboTokenReq struct {
|
||||
AppID int `json:"app_id"`
|
||||
ChannelID int `json:"channel_id"`
|
||||
AppID any `json:"app_id"`
|
||||
ChannelID any `json:"channel_id"`
|
||||
Data string `json:"data"`
|
||||
Device string `json:"device"`
|
||||
Sign string `json:"sign"`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package api
|
||||
|
||||
type ComboTokenRes struct {
|
||||
type ComboTokenRsp struct {
|
||||
Message string `json:"message"`
|
||||
Retcode int `json:"retcode"`
|
||||
Data LoginData `json:"data"`
|
||||
@@ -16,8 +16,8 @@ type LoginData struct {
|
||||
FatigueRemind any `json:"fatigue_remind"`
|
||||
}
|
||||
|
||||
func NewComboTokenRes() (r *ComboTokenRes) {
|
||||
r = &ComboTokenRes{
|
||||
func NewComboTokenRsp() (r *ComboTokenRsp) {
|
||||
r = &ComboTokenRsp{
|
||||
Message: "",
|
||||
Retcode: 0,
|
||||
Data: LoginData{
|
||||
@@ -44,21 +44,25 @@ func (c *Controller) getClientVersionByName(versionName string) (int, string) {
|
||||
}
|
||||
versionSlice := reg.FindAllString(versionName, -1)
|
||||
version := 0
|
||||
for index := 0; index < len(versionSlice); index++ {
|
||||
v, err := strconv.Atoi(versionSlice[index])
|
||||
for index, value := range versionSlice {
|
||||
v, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
logger.Error("parse client version error: %v", err)
|
||||
return 0, ""
|
||||
}
|
||||
for i := 0; i < len(versionSlice)-1-index; i++ {
|
||||
if v >= 10 {
|
||||
// 测试版本
|
||||
if index != 2 {
|
||||
logger.Error("invalid client version")
|
||||
return 0, ""
|
||||
}
|
||||
v /= 10
|
||||
}
|
||||
for i := 0; i < 2-index; i++ {
|
||||
v *= 10
|
||||
}
|
||||
version += v
|
||||
}
|
||||
if version >= 1000 {
|
||||
// 测试版本
|
||||
version /= 10
|
||||
}
|
||||
return version, strconv.Itoa(version)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ func (c *Controller) v2Login(context *gin.Context) {
|
||||
logger.Error("ParseInt uid error: %v", err)
|
||||
return
|
||||
}
|
||||
responseData := api.NewComboTokenRes()
|
||||
responseData := api.NewComboTokenRsp()
|
||||
account, err := c.dao.QueryAccountByField("accountID", uid)
|
||||
if account == nil || account.Token != loginData.Token {
|
||||
responseData.Retcode = -201
|
||||
|
||||
Reference in New Issue
Block a user