Merge branch 'chat' into dev
This commit is contained in:
commit
8570541f76
@ -114,6 +114,7 @@ type System struct {
|
||||
HttpPort string
|
||||
Host string
|
||||
RedirectUri string
|
||||
Domain string
|
||||
}
|
||||
type Oss struct {
|
||||
AccessKeyId string
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"context"
|
||||
"fonchain-fiee/api/account"
|
||||
"fonchain-fiee/api/accountFiee"
|
||||
"fonchain-fiee/pkg/config"
|
||||
"fonchain-fiee/cmd/config"
|
||||
"fonchain-fiee/pkg/e"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/utils/secret"
|
||||
@ -19,7 +19,7 @@ import (
|
||||
|
||||
// ParseToChatUser 将token信息转换为聊天室用户信息
|
||||
func ParseToChatUser(c *gin.Context) (chatUserInfo *accountFiee.ChatUserData, code e.ErrorCodeType) {
|
||||
domain := config.Domain
|
||||
domain := config.AppConfig.System.Domain
|
||||
domainAny, exist := c.Get("domain")
|
||||
if exist {
|
||||
domain = domainAny.(string)
|
||||
@ -34,7 +34,7 @@ func ParseToChatUser(c *gin.Context) (chatUserInfo *accountFiee.ChatUserData, co
|
||||
ctx := context.Background()
|
||||
var originId int64 = 0
|
||||
switch domain {
|
||||
case config.Domain:
|
||||
case config.AppConfig.System.Domain:
|
||||
//fiee token校验
|
||||
token, err = secret.GetJwtFromStr(token)
|
||||
if err != nil {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"fmt"
|
||||
"fonchain-fiee/api/account"
|
||||
"fonchain-fiee/api/accountFiee"
|
||||
"fonchain-fiee/pkg/config"
|
||||
"fonchain-fiee/cmd/config"
|
||||
"fonchain-fiee/pkg/e"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/utils/secret"
|
||||
@ -33,14 +33,14 @@ func AuthorizationVerify(sourceData []byte) (userInfo *accountFiee.ChatUserData,
|
||||
var ctx = context.Background()
|
||||
var accountInfo accountFiee.ChatUserData
|
||||
switch msg.Content.Domain {
|
||||
case config.Domain:
|
||||
case config.AppConfig.System.Domain:
|
||||
//fiee token校验
|
||||
msg.Content.Auth, err = secret.GetJwtFromStr(msg.Content.Auth)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var fieeJwtInfo *accountFiee.DecryptJwtResponse
|
||||
fieeJwtInfo, err = service.AccountFieeProvider.DecryptJwt(ctx, &accountFiee.DecryptJwtRequest{Token: msg.Content.Auth, Domain: msg.Content.Domain})
|
||||
fieeJwtInfo, err = service.AccountFieeProvider.DecryptJwt(ctx, &accountFiee.DecryptJwtRequest{Token: msg.Content.Auth, Domain: config.AppConfig.System.Domain})
|
||||
if err != nil || fieeJwtInfo.IsOffline {
|
||||
return
|
||||
}
|
||||
|
@ -132,6 +132,9 @@ func NewRouter() *gin.Engine {
|
||||
v1.POST("aschat/autoReplyRuler/update", asChat.Handler.UpdateChatAutoReplyRuler)
|
||||
v1.POST("aschat/autoReplyRuler/detail", asChat.Handler.GetChatAutoReplyRulerDetail)
|
||||
v1.POST("aschat/autoReplyRuler/query", asChat.Handler.GetChatAutoReplyRulerList)
|
||||
|
||||
v1.POST("/test/user/log/erp", asChat.Handler.ErpLoginDemo)
|
||||
v1.POST("/test/user/log/fiee", asChat.Handler.FieeLoginDemo)
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1,10 +1,17 @@
|
||||
package asChat
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"fonchain-fiee/api/account"
|
||||
"fonchain-fiee/api/accountFiee"
|
||||
"fonchain-fiee/cmd/config"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/utils"
|
||||
"fonchain-fiee/pkg/utils/secret"
|
||||
"fonchain-fiee/pkg/utils/stime"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Handler = &ChatAutoReplyRulerHandler{}
|
||||
@ -88,3 +95,93 @@ func (a *ChatAutoReplyRulerHandler) GetChatAutoReplyRulerList(c *gin.Context) {
|
||||
}
|
||||
service.Success(c, resp.List)
|
||||
}
|
||||
func (a *ChatAutoReplyRulerHandler) ErpLoginDemo(c *gin.Context) {
|
||||
var req ErpLoginDemoReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
loginRes, err := service.AccountProvider.Login(c, &account.LoginRequest{
|
||||
Domain: "fontree",
|
||||
TelNum: req.TelNum,
|
||||
Password: req.Password,
|
||||
})
|
||||
if err != nil {
|
||||
if err.Error() == "没有找到数据" || err.Error() == "No data found" {
|
||||
registerRequest := account.RegistRequest{
|
||||
Domain: "fontree",
|
||||
NickName: req.TelNum,
|
||||
TelNum: req.TelNum,
|
||||
Password: req.Password,
|
||||
EnterDate: time.Now().Format(stime.Format_Normal_YMD),
|
||||
Extend: &account.Extend{JumpTo: "onsite"}, //origin-老平台 onsite 当前
|
||||
JobNum: fmt.Sprintf("%d", rand.Intn(1000)),
|
||||
}
|
||||
registerRes, errs := service.AccountProvider.Register(c, ®isterRequest)
|
||||
if errs != nil {
|
||||
service.Error(c, errs)
|
||||
return
|
||||
}
|
||||
service.Success(c, registerRes)
|
||||
} else {
|
||||
service.Error(c, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
departmentName := ""
|
||||
if loginRes.AccountInfo != nil && len(loginRes.AccountInfo.Departments) > 0 {
|
||||
departmentName = loginRes.AccountInfo.Departments[0].Name
|
||||
}
|
||||
loginRes.Token, err = secret.CombineSecret("xxx", departmentName, loginRes.Token)
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
service.Success(c, loginRes)
|
||||
}
|
||||
func (a *ChatAutoReplyRulerHandler) FieeLoginDemo(c *gin.Context) {
|
||||
var req ErpLoginDemoReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
loginRes, err := service.AccountFieeProvider.Login(c, &accountFiee.LoginRequest{
|
||||
Domain: config.AppConfig.System.Domain,
|
||||
TelNum: req.TelNum,
|
||||
Password: req.Password,
|
||||
})
|
||||
if err != nil {
|
||||
if err.Error() == "账号不存在" || err.Error() == "Account does not exist" {
|
||||
registerRequest := accountFiee.RegistRequest{
|
||||
Domain: config.AppConfig.System.Domain,
|
||||
NickName: req.TelNum,
|
||||
TelNum: req.TelNum,
|
||||
//Password: req.Password,
|
||||
//EnterDate: time.Now().Format(stime.Format_Normal_YMD),
|
||||
//Extend: &account.Extend{JumpTo: "onsite"}, //origin-老平台 onsite 当前
|
||||
//JobNum: fmt.Sprintf("%d", rand.Intn(1000)),
|
||||
}
|
||||
registerRes, errs := service.AccountFieeProvider.Register(c, ®isterRequest)
|
||||
if errs != nil {
|
||||
service.Error(c, errs)
|
||||
return
|
||||
}
|
||||
service.Success(c, registerRes)
|
||||
} else {
|
||||
service.Error(c, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
departmentName := ""
|
||||
if loginRes.AccountInfo != nil && len(loginRes.AccountInfo.Departments) > 0 {
|
||||
departmentName = loginRes.AccountInfo.Departments[0].Name
|
||||
}
|
||||
loginRes.Token, err = secret.CombineSecret("xxx", departmentName, loginRes.Token)
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
service.Success(c, loginRes)
|
||||
}
|
||||
|
@ -134,3 +134,9 @@ type GetChatAutoReplyRulerListRequest struct {
|
||||
PageSize int64 `json:"pageSize"`
|
||||
accountFiee.ChatAutoReplyRulerData
|
||||
}
|
||||
type ErpLoginDemoReq struct {
|
||||
TelNum string `json:"telNum"`
|
||||
Password string `json:"password"`
|
||||
Nickname string `json:"nickname"`
|
||||
RealName string `json:"realName"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user