|
|
1
|
+package allied_creation_user
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "encoding/json"
|
|
|
5
|
+ "fmt"
|
|
|
6
|
+ "strconv"
|
|
|
7
|
+
|
|
|
8
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
|
|
|
9
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
10
|
+)
|
|
|
11
|
+
|
|
|
12
|
+// FavoriteMenusUpadate 更新我喜欢菜单列表
|
|
|
13
|
+func (gateway HttplibAlliedCreationUser) FavoriteMenusUpadate(param ReqFavoriteMenusUpdate) (*DataFavoriteMenusUpdate, error) {
|
|
|
14
|
+ url := gateway.baseUrL + "/user/" + strconv.FormatInt(param.UserId, 10) + "/favorite-menus"
|
|
|
15
|
+ method := "put"
|
|
|
16
|
+ req := gateway.CreateRequest(url, method)
|
|
|
17
|
+ log.Logger.Debug("向用户模块请求数据:更新我喜欢菜单列表。", map[string]interface{}{
|
|
|
18
|
+ "api": method + ":" + url,
|
|
|
19
|
+ "param": param,
|
|
|
20
|
+ })
|
|
|
21
|
+ req, err := req.JSONBody(param)
|
|
|
22
|
+ if err != nil {
|
|
|
23
|
+ return nil, fmt.Errorf("请求更新我喜欢菜单列表失败:%w", err)
|
|
|
24
|
+ }
|
|
|
25
|
+
|
|
|
26
|
+ byteResult, err := req.Bytes()
|
|
|
27
|
+ if err != nil {
|
|
|
28
|
+ return nil, fmt.Errorf("获取更新我喜欢菜单列表失败:%w", err)
|
|
|
29
|
+ }
|
|
|
30
|
+ log.Logger.Debug("获取用户模块请求数据:更新我喜欢菜单列表。", map[string]interface{}{
|
|
|
31
|
+ "result": string(byteResult),
|
|
|
32
|
+ })
|
|
|
33
|
+ var result service_gateway.GatewayResponse
|
|
|
34
|
+ err = json.Unmarshal(byteResult, &result)
|
|
|
35
|
+ if err != nil {
|
|
|
36
|
+ return nil, fmt.Errorf("解析更新我喜欢菜单列表:%w", err)
|
|
|
37
|
+ }
|
|
|
38
|
+ var data DataFavoriteMenusUpdate
|
|
|
39
|
+ err = gateway.GetResponseData(result, &data)
|
|
|
40
|
+ return &data, err
|
|
|
41
|
+}
|
|
|
42
|
+
|
|
|
43
|
+// FavoriteMenusRemove 移除我收藏的菜单
|
|
|
44
|
+func (gateway HttplibAlliedCreationUser) FavoriteMenusRemove(param ReqFavoriteMenusRemove) (*DataFavoriteMenusRemove, error) {
|
|
|
45
|
+ url := gateway.baseUrL + "/user/" + strconv.FormatInt(param.UserId, 10) + "/favorite-menus/" + param.MenuCode
|
|
|
46
|
+ method := "delete"
|
|
|
47
|
+ req := gateway.CreateRequest(url, method)
|
|
|
48
|
+ log.Logger.Debug("向用户模块请求数据:移除我收藏的菜单。", map[string]interface{}{
|
|
|
49
|
+ "api": method + ":" + url,
|
|
|
50
|
+ "param": param,
|
|
|
51
|
+ })
|
|
|
52
|
+ req, err := req.JSONBody(param)
|
|
|
53
|
+ if err != nil {
|
|
|
54
|
+ return nil, fmt.Errorf("请求移除我收藏的菜单失败:%w", err)
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ byteResult, err := req.Bytes()
|
|
|
58
|
+ if err != nil {
|
|
|
59
|
+ return nil, fmt.Errorf("获取移除我收藏的菜单失败:%w", err)
|
|
|
60
|
+ }
|
|
|
61
|
+ log.Logger.Debug("获取用户模块请求数据:移除我收藏的菜单。", map[string]interface{}{
|
|
|
62
|
+ "result": string(byteResult),
|
|
|
63
|
+ })
|
|
|
64
|
+ var result service_gateway.GatewayResponse
|
|
|
65
|
+ err = json.Unmarshal(byteResult, &result)
|
|
|
66
|
+ if err != nil {
|
|
|
67
|
+ return nil, fmt.Errorf("解析移除我收藏的菜单:%w", err)
|
|
|
68
|
+ }
|
|
|
69
|
+ var data DataFavoriteMenusRemove
|
|
|
70
|
+ err = gateway.GetResponseData(result, &data)
|
|
|
71
|
+ return &data, err
|
|
|
72
|
+}
|
|
|
73
|
+
|
|
|
74
|
+// FavoriteMenusGet 获取我收藏的菜单
|
|
|
75
|
+func (gateway HttplibAlliedCreationUser) FavoriteMenusGet(param ReqFavoriteMenusGet) (*DataFavoriteMenusGet, error) {
|
|
|
76
|
+ url := gateway.baseUrL + "/user/" + strconv.FormatInt(param.UserId, 10) + "/favorite-menus"
|
|
|
77
|
+ method := "get"
|
|
|
78
|
+ req := gateway.CreateRequest(url, method)
|
|
|
79
|
+ log.Logger.Debug("向用户模块请求数据:获取我收藏的菜单。", map[string]interface{}{
|
|
|
80
|
+ "api": method + ":" + url,
|
|
|
81
|
+ "param": param,
|
|
|
82
|
+ })
|
|
|
83
|
+ req, err := req.JSONBody(param)
|
|
|
84
|
+ if err != nil {
|
|
|
85
|
+ return nil, fmt.Errorf("请求获取我收藏的菜单失败:%w", err)
|
|
|
86
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ byteResult, err := req.Bytes()
|
|
|
89
|
+ if err != nil {
|
|
|
90
|
+ return nil, fmt.Errorf("获取获取我收藏的菜单失败:%w", err)
|
|
|
91
|
+ }
|
|
|
92
|
+ log.Logger.Debug("获取用户模块请求数据:获取我收藏的菜单。", map[string]interface{}{
|
|
|
93
|
+ "result": string(byteResult),
|
|
|
94
|
+ })
|
|
|
95
|
+ var result service_gateway.GatewayResponse
|
|
|
96
|
+ err = json.Unmarshal(byteResult, &result)
|
|
|
97
|
+ if err != nil {
|
|
|
98
|
+ return nil, fmt.Errorf("解析获取我收藏的菜单:%w", err)
|
|
|
99
|
+ }
|
|
|
100
|
+ var data DataFavoriteMenusGet
|
|
|
101
|
+ err = gateway.GetResponseData(result, &data)
|
|
|
102
|
+ return &data, err
|
|
|
103
|
+} |