|
@@ -7,6 +7,7 @@ import (
|
7
|
7
|
"wechat-conf/models/model"
|
8
|
8
|
"wechat-conf/service/keyvalue"
|
9
|
9
|
"wechat-conf/service/sysuser"
|
|
10
|
+ "wechat-conf/service/wechatimg"
|
10
|
11
|
"wechat-conf/service/wechatmenu"
|
11
|
12
|
"wechat-conf/utils"
|
12
|
13
|
|
|
@@ -18,6 +19,7 @@ type MenuController struct {
|
18
|
19
|
dao *wechatmenu.WechatmenuServ
|
19
|
20
|
sdao *sysuser.SysuserServ
|
20
|
21
|
kdao *keyvalue.KeyvalueServ
|
|
22
|
+ idao *wechatimg.WechatImgServ
|
21
|
23
|
controllers.BaseController
|
22
|
24
|
}
|
23
|
25
|
|
|
@@ -28,6 +30,7 @@ func (c *MenuController) Constructor() {
|
28
|
30
|
c.dao = wechatmenu.NewWechatmenuServ(c.Context)
|
29
|
31
|
c.sdao = sysuser.NewSysuserServ(c.Context)
|
30
|
32
|
c.kdao = keyvalue.NewKeyvalueServ(c.Context)
|
|
33
|
+ c.idao = wechatimg.NewWechatImgServ(c.Context)
|
31
|
34
|
}
|
32
|
35
|
|
33
|
36
|
type Wehchatmenu struct {
|
|
@@ -70,6 +73,7 @@ func (c *MenuController) GetMenuList() {
|
70
|
73
|
menu, err := client.GetMenu()
|
71
|
74
|
beego.Error(menu)
|
72
|
75
|
var keyList []*model.TaWechatKeyValue
|
|
76
|
+ var imgList []*model.TaWechatImg
|
73
|
77
|
if menu != nil {
|
74
|
78
|
menus := menu["menu"].(map[string]interface{})
|
75
|
79
|
wechatmenu := menus["button"].([]interface{})
|
|
@@ -83,7 +87,15 @@ func (c *MenuController) GetMenuList() {
|
83
|
87
|
}
|
84
|
88
|
keyList = append(keyList, key)
|
85
|
89
|
}
|
|
90
|
+ if m["type"].(string) == "media_id" {
|
|
91
|
+ img, err := c.idao.GetWechatImgById(m["media_id"].(string))
|
|
92
|
+ if err != nil {
|
|
93
|
+ c.ResponseError(err)
|
|
94
|
+ }
|
|
95
|
+ imgList = append(imgList, img)
|
|
96
|
+ }
|
86
|
97
|
}
|
|
98
|
+
|
87
|
99
|
if m["sub_button"] != nil {
|
88
|
100
|
subbuttons := m["sub_button"].([]interface{})
|
89
|
101
|
for j := 0; j < len(subbuttons); j++ {
|
|
@@ -95,6 +107,13 @@ func (c *MenuController) GetMenuList() {
|
95
|
107
|
}
|
96
|
108
|
keyList = append(keyList, key)
|
97
|
109
|
}
|
|
110
|
+ if subb["type"].(string) == "media_id" {
|
|
111
|
+ img, err := c.idao.GetWechatImgById(subb["media_id"].(string))
|
|
112
|
+ if err != nil {
|
|
113
|
+ c.ResponseError(err)
|
|
114
|
+ }
|
|
115
|
+ imgList = append(imgList, img)
|
|
116
|
+ }
|
98
|
117
|
}
|
99
|
118
|
}
|
100
|
119
|
}
|
|
@@ -111,6 +130,7 @@ func (c *MenuController) GetMenuList() {
|
111
|
130
|
c.ResponseJSON(map[string]interface{}{
|
112
|
131
|
"menu": menu,
|
113
|
132
|
"keyList": keyList,
|
|
133
|
+ "imgList": imgList,
|
114
|
134
|
})
|
115
|
135
|
}
|
116
|
136
|
|