This commit is contained in:
徐俊杰 2025-06-12 18:10:07 +08:00
parent 47c77fcdbb
commit cc328eee8d
2 changed files with 30 additions and 8 deletions

24
pkg/common/jwt/common.go Normal file
View File

@ -0,0 +1,24 @@
// Package jwt -----------------------------
// @file : common.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2025/6/12 18:07
// -------------------------------------------
package jwt
import (
"fonchain-fiee/pkg/config"
"github.com/gin-gonic/gin"
)
func ParseCommonTokenInfo(c *gin.Context) {
domain, exist := c.Get("domain")
if !exist {
domain = config.Domain
}
switch domain {
case config.Domain:
case "fontree":
}
}

View File

@ -17,7 +17,6 @@ import (
"fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/common/ws"
"fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/logic"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/upload"
"fonchain-fiee/pkg/utils"
@ -104,22 +103,22 @@ func (cr ChatHandler) Connection(c *gin.Context) {
func (cr ChatHandler) NewMessage(c *gin.Context) {
var request NewMessageRequest
if err := c.ShouldBindJSON(&request); err != nil {
service.ErrorMsgI18n(c, e.InvalidParams, err.Error(), e.I18N_INVALID_PARAM)
service.Error(c, err)
return
}
if request.SessionId == "" {
service.ErrorMsgI18n(c, e.InvalidParams, "sessionId不能为空", e.I18N_INVALID_PARAM)
service.Error(c, errors.New("sessionId不能为空"))
return
}
if request.MsgType == 0 {
service.ErrorMsgI18n(c, e.InvalidParams, "msgType不能为空", e.I18N_INVALID_PARAM)
service.Error(c, errors.New("msgType不能为空"))
return
}
fmt.Println("NewMessage 1111111111111111111111111111111")
//获取用户信息
tokenResult := asAccount.GetUserInfoWithTokenV2(c)
if tokenResult.Err != nil {
service.ErrorMsgI18n(c, e.NotLogin, tokenResult.Err.Error(), e.I18N_NOTLOGIN)
service.Error(c, errors.New("未登录"))
return
}
fmt.Println("NewMessage 22222222222222222222222222222222222")
@ -127,9 +126,8 @@ func (cr ChatHandler) NewMessage(c *gin.Context) {
var userName = "未知"
if request.Waiter {
accountDetail, err := service.AccountProvider.Info(c, &account.InfoRequest{ID: uint64(tokenResult.UserInfo.MgmtAccId), Domain: config.Domain})
trace.AddTrace(c, "AccountProvider.Info", err)
if err != nil {
service.ErrorMsgI18n(c, e.Failed, err.Error(), e.I18N_USER_FOUND_FAILED)
service.Error(c, errors.New("用户信息获取失败"))
return
}
userName = accountDetail.Info.NickName
@ -449,7 +447,7 @@ func (cr ChatHandler) UserMessageStat(c *gin.Context) {
//获取用户信息
tokenResult := asAccount.GetUserInfoWithTokenV2(c)
if tokenResult.Err != nil {
service.ErrorMsgI18n(c, e.NotLogin, tokenResult.Err.Error(), e.I18N_NOTLOGIN)
service.Error(c, errors.New("未登录"))
return
}
result := cr.cache.GetNewMessageStat(c, tokenResult.UserInfo.ID)