|
|
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"
|
|
|
)
|
|
|
|
|
|
//RoleSearch 搜索角色列表
|
|
|
func (gateway HttplibAlliedCreationUser) RoleSearch(param ReqRoleSearch) (*DataRoleSearch, error) {
|
|
|
url := gateway.baseUrL + "/role/search"
|
|
|
method := "post"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
//TODO traceID
|
|
|
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 DataRoleSearch
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
//RoleGet 获取角色
|
|
|
func (gateway HttplibAlliedCreationUser) RoleGet(param ReqRoleGet) (*DataRoleGet, error) {
|
|
|
url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/role/", param.RoleId)
|
|
|
method := "get"
|
|
|
req := gateway.CreateRequest(url, method)
|
|
|
//TODO traceID
|
|
|
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 DataRoleGet
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
} |
...
|
...
|
|