module_notice.go
2.3 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
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"
)
// NoticeSettingUpdate 获取消息列表
func (gateway HttplibAlliedCreationBasic) NoticePersonal(param ReqNoticePersonal) (*DataNoticePersonal, error) {
url := gateway.baseUrL + "/notice-personal"
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 DataNoticePersonal
err = gateway.GetResponseData(result, &data)
return &data, err
}
// NoticeSettingAdd 消息标记已读
func (gateway HttplibAlliedCreationBasic) ReadNotice(param ReqReadNotice) (*DataReadNotice, error) {
url := gateway.baseUrL + "/notice-personal/read"
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 DataReadNotice
err = gateway.GetResponseData(result, &data)
return &data, err
}