|
|
package allied_creation_basic
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
)
|
|
|
|
|
|
// NoticeSettingUpdate 更新消息模板
|
|
|
func (gateway HttplibAlliedCreationBasic) NoticeSettingUpdate(param ReqNoticeSettingUpdate) (*DataNoticeSettingUpdate, error) {
|
|
|
url := gateway.baseUrL + "/notice-setting"
|
|
|
method := "PUT"
|
|
|
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 DataNoticeSettingUpdate
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// NoticeSettingAdd 添加化消息模板
|
|
|
func (gateway HttplibAlliedCreationBasic) NoticeSettingAdd(param ReqNoticeSettingAdd) (*DataNoticeSettingAdd, error) {
|
|
|
url := gateway.baseUrL + "/notice-setting"
|
|
|
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 DataNoticeSettingAdd
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// NoticeSettingGet 返回编排消息通知内容
|
|
|
func (gateway HttplibAlliedCreationBasic) NoticeSettingGet(param ReqNoticeSettingGet) (*DataNoticeSettingGet, error) {
|
|
|
url := gateway.baseUrL + "/notice-setting/" + strconv.Itoa(param.SettingId)
|
|
|
method := "GET"
|
|
|
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 DataNoticeSettingGet
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
}
|
|
|
|
|
|
// NoticeSettingSearch 返回编排消息通知内容列表
|
|
|
func (gateway HttplibAlliedCreationBasic) NoticeSettingSearch(param ReqNoticeSettingSearch) (*DataNoticeSettingSearch, error) {
|
|
|
url := gateway.baseUrL + "/notice-setting/search"
|
|
|
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 DataNoticeSettingSearch
|
|
|
err = gateway.GetResponseData(result, &data)
|
|
|
return &data, err
|
|
|
} |
...
|
...
|
|