module_system_setting.go
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package allied_creation_basic
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"
)
// SystemSetting 更新系统设置
func (gateway HttplibAlliedCreationBasic) SystemSettingUpdate(param ReqSystemSettingUpdate) (*DataSystemSettingUpdate, error) {
url := gateway.baseUrL + "/system-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 DataSystemSettingUpdate
err = gateway.GetResponseData(result, &data)
return &data, err
}
// System-settingSearch 获取企业的系统设置列表
func (gateway HttplibAlliedCreationBasic) SystemSettingSearch(param ReqSystemSettingSearch) (*DataSystemSettingSearch, error) {
url := gateway.baseUrL + "/system-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 DataSystemSettingSearch
err = gateway.GetResponseData(result, &data)
return &data, err
}
// SystemSettingGet 获取企业的系统设置项
func (gateway HttplibAlliedCreationBasic) SystemSettingGet(param ReqSystemSettingGet) (*DataSystemSettingGet, error) {
url := gateway.baseUrL + "/system-setting/get"
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 DataSystemSettingGet
err = gateway.GetResponseData(result, &data)
return &data, err
}