修改聊天和登录信息的数据库结构

This commit is contained in:
flswld
2023-02-12 16:08:56 +08:00
parent 15199d31e8
commit 36a150c9bb
17 changed files with 171 additions and 118 deletions

View File

@@ -47,9 +47,7 @@ func NewController(dao *dao.Dao, discovery *rpc.DiscoveryClient) (r *Controller)
func (c *Controller) authorize() gin.HandlerFunc {
return func(context *gin.Context) {
// TODO auth token或其他验证方式
ok := true
if ok {
if context.Query("key") == "flswld" {
context.Next()
return
}
@@ -80,10 +78,10 @@ func (c *Controller) registerRouter() {
{
// 调度
// dispatchosglobal.yuanshen.com
engine.GET("/query_security_file", c.query_security_file)
engine.GET("/query_region_list", c.query_region_list)
engine.GET("/query_security_file", c.querySecurityFile)
engine.GET("/query_region_list", c.queryRegionList)
// osusadispatch.yuanshen.com
engine.GET("/query_cur_region", c.query_cur_region)
engine.GET("/query_cur_region", c.queryCurRegion)
}
{
// 登录

View File

@@ -18,7 +18,7 @@ import (
"github.com/gin-gonic/gin"
)
func (c *Controller) query_security_file(context *gin.Context) {
func (c *Controller) querySecurityFile(context *gin.Context) {
// 很早以前2.6.0版本的时候抓包为了完美还原写的 不清楚有没有副作用暂时不要了
return
file, err := os.ReadFile("static/security_file")
@@ -30,7 +30,7 @@ func (c *Controller) query_security_file(context *gin.Context) {
_, _ = context.Writer.WriteString(string(file))
}
func (c *Controller) query_region_list(context *gin.Context) {
func (c *Controller) queryRegionList(context *gin.Context) {
context.Header("Content-type", "text/html; charset=UTF-8")
regionListBase64 := region.GetRegionListBase64(c.ec2b)
_, _ = context.Writer.WriteString(regionListBase64)
@@ -66,7 +66,7 @@ func (c *Controller) getClientVersionByName(versionName string) (int, string) {
return version, strconv.Itoa(version)
}
func (c *Controller) query_cur_region(context *gin.Context) {
func (c *Controller) queryCurRegion(context *gin.Context) {
rspError := func() {
rspContentError := "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="
rspSignError := "TW9yZSBsb3ZlIGZvciBVQSBQYXRjaCBwbGF5ZXJz"

View File

@@ -42,29 +42,29 @@ func (c *Controller) gateTokenVerify(context *gin.Context) {
verifyFail(0)
return
}
account, err := c.dao.QueryAccountByField("accountID", accountId)
account, err := c.dao.QueryAccountByField("AccountID", accountId)
if err != nil || account == nil {
verifyFail(0)
return
}
if tokenVerifyReq.AccountToken != account.ComboToken {
verifyFail(uint32(account.PlayerID))
verifyFail(account.PlayerID)
return
}
if account.ComboTokenUsed {
verifyFail(uint32(account.PlayerID))
verifyFail(account.PlayerID)
return
}
_, err = c.dao.UpdateAccountFieldByFieldName("accountID", account.AccountID, "comboTokenUsed", true)
_, err = c.dao.UpdateAccountFieldByFieldName("AccountID", account.AccountID, "ComboTokenUsed", true)
if err != nil {
verifyFail(uint32(account.PlayerID))
verifyFail(account.PlayerID)
return
}
context.JSON(http.StatusOK, &TokenVerifyRsp{
Valid: true,
Forbid: account.Forbid,
ForbidEndTime: uint32(account.ForbidEndTime),
PlayerID: uint32(account.PlayerID),
ForbidEndTime: account.ForbidEndTime,
PlayerID: account.PlayerID,
})
}
@@ -85,7 +85,7 @@ func (c *Controller) gateTokenReset(context *gin.Context) {
})
return
}
_, err = c.dao.UpdateAccountFieldByFieldName("playerID", req.PlayerId, "comboTokenUsed", false)
_, err = c.dao.UpdateAccountFieldByFieldName("PlayerID", req.PlayerId, "ComboTokenUsed", false)
if err != nil {
context.JSON(http.StatusOK, &TokenResetRsp{
Result: false,

View File

@@ -92,8 +92,7 @@ func (c *Controller) apiLogin(context *gin.Context) {
context.JSON(http.StatusOK, responseData)
return
}
// TODO SDK账号登陆
account, err := c.dao.QueryAccountByField("username", username)
account, err := c.dao.QueryAccountByField("Username", username)
if err != nil {
logger.Error("query account from db error: %v", err)
return
@@ -141,14 +140,14 @@ func (c *Controller) apiLogin(context *gin.Context) {
}
// 生成新的token
account.Token = base64.StdEncoding.EncodeToString(random.GetRandomByte(24))
_, err = c.dao.UpdateAccountFieldByFieldName("accountID", account.AccountID, "token", account.Token)
_, err = c.dao.UpdateAccountFieldByFieldName("AccountID", account.AccountID, "Token", account.Token)
if err != nil {
responseData.Retcode = -201
responseData.Message = "服务器内部错误:-4"
context.JSON(http.StatusOK, responseData)
return
}
_, err = c.dao.UpdateAccountFieldByFieldName("accountID", account.AccountID, "tokenCreateTime", time.Now().UnixMilli())
_, err = c.dao.UpdateAccountFieldByFieldName("AccountID", account.AccountID, "TokenCreateTime", time.Now().UnixMilli())
if err != nil {
responseData.Retcode = -201
responseData.Message = "服务器内部错误:-5"
@@ -174,7 +173,7 @@ func (c *Controller) apiVerify(context *gin.Context) {
logger.Error("parse uid error: %v", err)
return
}
account, err := c.dao.QueryAccountByField("accountID", uid)
account, err := c.dao.QueryAccountByField("AccountID", uid)
if err != nil {
logger.Error("query account from db error: %v", err)
return
@@ -223,7 +222,7 @@ func (c *Controller) v2Login(context *gin.Context) {
return
}
responseData := api.NewComboTokenRsp()
account, err := c.dao.QueryAccountByField("accountID", uid)
account, err := c.dao.QueryAccountByField("AccountID", uid)
if account == nil || account.Token != loginData.Token {
responseData.Retcode = -201
responseData.Message = "token错误"
@@ -232,14 +231,14 @@ func (c *Controller) v2Login(context *gin.Context) {
}
// 生成新的comboToken
account.ComboToken = random.GetRandomByteHexStr(20)
_, err = c.dao.UpdateAccountFieldByFieldName("accountID", account.AccountID, "comboToken", account.ComboToken)
_, err = c.dao.UpdateAccountFieldByFieldName("AccountID", account.AccountID, "ComboToken", account.ComboToken)
if err != nil {
responseData.Retcode = -201
responseData.Message = "服务器内部错误:-1"
context.JSON(http.StatusOK, responseData)
return
}
_, err = c.dao.UpdateAccountFieldByFieldName("accountID", account.AccountID, "comboTokenUsed", false)
_, err = c.dao.UpdateAccountFieldByFieldName("AccountID", account.AccountID, "ComboTokenUsed", false)
if err != nil {
responseData.Retcode = -201
responseData.Message = "服务器内部错误:-2"