|
|
package allied_creation_user
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
)
|
|
|
|
|
|
// AuthCompanySignUp 企业注册
|
|
|
func (gateway HttplibAlliedCreationUser) AuthCompanySignUp(param ReqAuthCompanySignUp) (*DataAuthCompanySignUp, error) {
|
|
|
url := gateway.baseUrL + "/auth/company-sign-up"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:企业注册。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求企业注册失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取企业注册失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:企业注册。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析企业注册:%w", err)
|
|
|
}
|
|
|
var data DataAuthCompanySignUp
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
//AuthChangePassword 修改密码
|
|
|
func (gateway HttplibAlliedCreationUser) AuthChangePassword(param ReqAuthChangePassword) (*DataAuthChangePassword, error) {
|
|
|
url := gateway.baseUrL + "/auth/change-password"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:修改密码。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求修改密码失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取修改密码失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:修改密码。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析修改密码:%w", err)
|
|
|
}
|
|
|
var data DataAuthChangePassword
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// AuthCheckPassword 手机账号密码检查
|
|
|
func (gateway HttplibAlliedCreationUser) AuthCheckPassword(param ReqAuthCheckPassword) (*DataAuthCheckPassword, error) {
|
|
|
url := gateway.baseUrL + "/auth/check-password"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:手机账号密码检查。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求手机账号密码检查失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取手机账号密码检查失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:手机账号密码检查。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析手机账号密码检查:%w", err)
|
|
|
}
|
|
|
var data DataAuthCheckPassword
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// AuthDestroyAccount 注销账号 (添加用户时重新激活)
|
|
|
func (gateway HttplibAlliedCreationUser) AuthDestroyAccount(param ReqAuthDestroyAccount) (*DataAuthDestroyAccount, error) {
|
|
|
url := gateway.baseUrL + "/auth/destroy-account"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:注销账号 (添加用户时重新激活)。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求注销账号 (添加用户时重新激活)失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取注销账号 (添加用户时重新激活)失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:注销账号 (添加用户时重新激活)。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析注销账号 (添加用户时重新激活):%w", err)
|
|
|
}
|
|
|
var data DataAuthDestroyAccount
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// AuthResetPassword 重置密码(忘记密码)
|
|
|
func (gateway HttplibAlliedCreationUser) AuthResetPassword(param ReqAuthResetPassword) (*DataAuthResetPassword, error) {
|
|
|
url := gateway.baseUrL + "/auth/reset-password"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:重置密码(忘记密码)。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求重置密码(忘记密码)失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取重置密码(忘记密码)失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:重置密码(忘记密码)。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析重置密码(忘记密码):%w", err)
|
|
|
}
|
|
|
var data DataAuthResetPassword
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
//AuthResetPhone 重置手机号
|
|
|
func (gateway HttplibAlliedCreationUser) AuthResetPhone(param ReqAuthResetPhone) (*DataAuthResetPhone, error) {
|
|
|
url := gateway.baseUrL + "/auth/reset-phone"
|
|
|
method := "POST"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
log.Logger.Debug("向用户模块请求数据:重置手机号。", map[string]interface{}{
|
|
|
"api": method + ":" + url,
|
|
|
"param": param,
|
|
|
})
|
|
|
req, err := req.JSONBody(param)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("请求重置手机号失败:%w", err)
|
|
|
}
|
|
|
|
|
|
byteResult, err := req.Bytes()
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("获取重置手机号失败:%w", err)
|
|
|
}
|
|
|
log.Logger.Debug("获取用户模块请求数据:重置手机号。", map[string]interface{}{
|
|
|
"result": string(byteResult),
|
|
|
})
|
|
|
var result service_gateway.GatewayResponse
|
|
|
err = json.Unmarshal(byteResult, &result)
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("解析重置手机号:%w", err)
|
|
|
}
|
|
|
var data DataAuthResetPhone
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
} |
...
|
...
|
|