作者 yangfu

登录认证 IM刷新

... ... @@ -23,6 +23,13 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
result interface{}
err error
)
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err = creationUserGateway.AuthRefreshIM(allied_creation_user.ReqAuthRefreshIM{
Phone: loginCommand.Phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "系统错误")
}
switch loginCommand.GrantType {
case "signInPassword":
result, err = srv.SignInPassword(loginCommand.Phone, loginCommand.Password)
... ... @@ -347,6 +354,8 @@ func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (in
"userName": resultUser.UserInfo.UserName,
"userPhone": resultUser.UserInfo.Phone,
"userAvatar": resultUser.UserInfo.Avatar,
//"userCode": resultUser.UserInfo.UserCode,
"email": resultUser.UserInfo.Email,
},
"department": resultUser.Department,
"company": map[string]interface{}{
... ...
... ... @@ -193,3 +193,34 @@ func (gateway HttplibAlliedCreationUser) AuthResetPhone(param ReqAuthResetPhone)
err = gateway.GetResponseData(result, &data)
return &data, err
}
//RefreshIM 刷新IM信息
func (gateway HttplibAlliedCreationUser) AuthRefreshIM(param ReqAuthRefreshIM) (*DataAuthRefreshIM, error) {
url := gateway.baseUrL + "/auth/refresh-im"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向用户模块请求数据:刷新IM信息。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求刷新IM信息失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取刷新IM信息失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:刷新IM信息。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析刷新IM信息:%w", err)
}
var data DataAuthRefreshIM
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -59,3 +59,21 @@ type (
ReqAuthResetPassword struct{}
DataAuthResetPassword struct{}
)
//重置手机号
type (
ReqAuthRefreshIM struct {
// 手机号码
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 刷新标识 0:刷新IM信息,并返回 1:使用旧的im信息
RefreshFlag int `cname:"刷新标识" json:"refreshFlag"`
}
DataAuthRefreshIM struct {
// 网易云信ID
Accid string `json:"accid"`
// 网易云信Token
ImToken string `json:"imToken"`
// 系统分配客服ID
CsAccountId string `json:"csAccountId"`
}
)
... ...
... ... @@ -41,6 +41,6 @@ func (controller *baseController) GetOperator() domain.Operator {
UserId: 9,
CompanyId: 23,
OrgId: 45,
UserBaseId: 1,
UserBaseId: 5,
}
}
... ...
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/service"
"strconv"
)
type CooperationModeController struct {
baseController
}
func (controller *CooperationModeController) CreateCooperationMode() {
svr := service.CooperationModeService{}
cmd := &command.CreateCooperationModeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CreateCooperationMode(cmd)
controller.Response(data, err)
}
func (controller *CooperationModeController) UpdateCooperationMode() {
svr := service.CooperationModeService{}
cmd := &command.UpdateCooperationModeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cooperationModeId := controller.GetString(":cooperationModeId")
cmd.CooperationModeId, _ = strconv.Atoi(cooperationModeId)
cmd.Operator = controller.GetOperator()
data, err := svr.UpdateCooperationMode(cmd)
controller.Response(data, err)
}
func (controller *CooperationModeController) GetCooperationMode() {
svr := service.CooperationModeService{}
cmd := &query.GetCooperationModeQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cooperationModeId := controller.GetString(":cooperationModeId")
cmd.CooperationModeId, _ = strconv.Atoi(cooperationModeId)
cmd.Operator = controller.GetOperator()
data, err := svr.GetCooperationMode(cmd)
controller.Response(data, err)
}
func (controller *CooperationModeController) RemoveCooperationMode() {
svr := service.CooperationModeService{}
cmd := &command.RemoveCooperationModeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cooperationModeId := controller.GetString(":cooperationModeId")
cmd.CooperationModeId, _ = strconv.Atoi(cooperationModeId)
cmd.Operator = controller.GetOperator()
data, err := svr.RemoveCooperationMode(cmd)
controller.Response(data, err)
}
func (controller *CooperationModeController) SearchCooperationMode() {
svr := service.CooperationModeService{}
cmd := &query.ListCooperationModeQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
cnt, data, err := svr.ListCooperationMode(cmd)
controller.returnPageListData(cnt, data, err, cmd.PageNumber)
}
func (controller *CooperationModeController) ListCooperationMode() {
svr := service.CooperationModeService{}
cmd := &query.ListCooperationModeQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
_, data, err := svr.ListCooperationMode(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -12,7 +12,7 @@ func init() {
web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken")
web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken")
web.Router("/v1/app/auth/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/auth/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/auth/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
web.Router("/v1/app/user/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo")
web.Router("/v1/app/user/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/app/user/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg")
}
... ...
... ... @@ -11,4 +11,13 @@ func init() {
web.Router("/v1/web/cooperation-projects/:projectId", &web_client.CooperationProjectController{}, "Get:GetCooperationProject")
web.Router("/v1/web/cooperation-projects/search", &web_client.CooperationProjectController{}, "Post:ListCooperationProject")
web.Router("/v1/web/cooperation-projects/end", &web_client.CooperationProjectController{}, "Put:EndCooperationProject")
/***** 1.共创模式 *****/
web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Post:CreateCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Put:UpdateCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Get:GetCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Delete:RemoveCooperationMode")
web.Router("/v1/web/cooperation-modes/search", &web_client.CooperationModeController{}, "Post:SearchCooperationMode")
web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode")
}
... ...