Skip to content

Commit

Permalink
fix: #6 地下城与勇士 账号显示乱码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjie committed Feb 2, 2024
1 parent e17d037 commit fa83a8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions console/biz/gm/model/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ type CharacInfo struct {
Lev int `json:"lev"`
CreateTime time.Time `json:"create_time"`
}

type CharacInfoV2 struct {
MId int `json:"m_id"`
CharacNo int `json:"charac_no"`
ConvertedCharacName string `json:"converted_charac_name"`
Lev int `json:"lev"`
CreateTime time.Time `json:"create_time"`
}
19 changes: 13 additions & 6 deletions console/biz/gm/service/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,27 @@ func GetRoles(uid int) ([]RoleResult, error) {
return nil, errors.New("该账号不存在")
}

var data = make([]model.CharacInfo, 0)
var data = make([]model.CharacInfoV2, 0)
dbx := game_db.DBPools.Get(model.TaiwanCain)
// 乱码 角色,每次执行一次,无所谓了不搞优化!!!
//dbx.Exec("UPDATE charac_info SET charac_name = CONVERT(BINARY(CONVERT(charac_name USING latin1)) USING utf8);")
//
dbx.Table("charac_info").Where("m_id = ? AND delete_flag = ?", uid, 0).Find(&data)
dbx.Debug().Table("charac_info").Select("CONVERT(charac_name USING utf8) AS converted_charac_name, m_id, charac_no, lev, create_time").Where("m_id = ? AND delete_flag = ?", uid, 0).Find(&data)
//dbx.Table("charac_info").Where("m_id = ? AND delete_flag = ?", uid, 0).Find(&data)

var result = make([]RoleResult, 0)
for _, info := range data {
result = append(result, RoleResult{
CharacInfo: info,
Money: getMoneyByRole(info.CharacNo),
QP: getQpByRole(info.CharacNo),
Pvp: getPvpByRole(info.CharacNo),
CharacInfo: model.CharacInfo{
MId: info.MId,
CharacNo: info.CharacNo,
CharacName: info.ConvertedCharacName,
Lev: info.Lev,
CreateTime: info.CreateTime,
},
Money: getMoneyByRole(info.CharacNo),
QP: getQpByRole(info.CharacNo),
Pvp: getPvpByRole(info.CharacNo),
})
}

Expand Down

0 comments on commit fa83a8b

Please sign in to comment.