胡轶钦 6 年 前
コミット
fbf8d1091f

+ 4
- 1
controllers/autoreply/autoreply.go ファイルの表示

@@ -4,11 +4,13 @@ import (
4 4
 	"wechat-conf/controllers"
5 5
 	"wechat-conf/models/model"
6 6
 	"wechat-conf/service/autoreply"
7
+	"wechat-conf/service/wechatimg"
7 8
 )
8 9
 
9 10
 // AutoreplyController 信息
10 11
 type AutoreplyController struct {
11
-	dao *autoreply.AutoreplyServ
12
+	dao    *autoreply.AutoreplyServ
13
+	imgdao *wechatimg.WechatImgServ
12 14
 	controllers.BaseController
13 15
 }
14 16
 
@@ -17,6 +19,7 @@ type AutoreplyController struct {
17 19
 // @Description 初始化 Controller, 系统自动调用
18 20
 func (c *AutoreplyController) Constructor() {
19 21
 	c.dao = autoreply.NewAutoreplyServ(c.Context)
22
+	c.imgdao = wechatimg.NewWechatImgServ(c.Context)
20 23
 }
21 24
 
22 25
 func (c *AutoreplyController) GetAutoReplyList() {

+ 4
- 1
controllers/component.go ファイルの表示

@@ -348,6 +348,8 @@ func (c *WechatController) getReplayMessage(receviceData map[string]string, wech
348 348
 
349 349
 		break
350 350
 	case "event":
351
+		beego.Info("_______________这里是event————————————————")
352
+		beego.Info(receviceData["Event"])
351 353
 		switch receviceData["Event"] {
352 354
 		case "subscribe":
353 355
 			if replay, err = c.serv.GetSubscribeByAppID(appID); err != nil {
@@ -356,7 +358,8 @@ func (c *WechatController) getReplayMessage(receviceData map[string]string, wech
356 358
 			}
357 359
 
358 360
 			break
359
-		case "CLICK":
361
+		case "CLICK", "LICK":
362
+			beego.Info("_______________这里是CLICK————————————————")
360 363
 			target := receviceData["EventKey"]
361 364
 			if target != "" {
362 365
 				var replyText string

+ 6
- 2
controllers/wechatmenu/wechatmenu.go ファイルの表示

@@ -165,7 +165,7 @@ func (c *MenuController) RefreshMenu() {
165 165
 		if wechatmenu[i].Type == "text" {
166 166
 			wechatmenu[i].Type = "click"
167 167
 			var keyvalue = model.TaWechatKeyValue{
168
-				KeyId: utils.GetGUID(),
168
+				KeyId: user.OrgId + wechatmenu[i].Name,
169 169
 				Value: wechatmenu[i].Value,
170 170
 				OrgId: user.OrgId,
171 171
 			}
@@ -173,6 +173,8 @@ func (c *MenuController) RefreshMenu() {
173 173
 			if err != nil {
174 174
 				c.ResponseError(err)
175 175
 			}
176
+			utils.LogInfo("↓↓↓↓_________________________↓↓↓↓keyId button(controller)↓↓↓↓___________________↓↓↓↓")
177
+			utils.LogInfo(keyvalue.KeyId)
176 178
 			wechatmenu[i].Key = keyvalue.KeyId
177 179
 			wechatmenu[i].Value = ""
178 180
 		}
@@ -180,7 +182,7 @@ func (c *MenuController) RefreshMenu() {
180 182
 			if wechatmenu[i].Sub_Button[j].Type == "text" {
181 183
 				wechatmenu[i].Sub_Button[j].Type = "click"
182 184
 				var keyvalue = model.TaWechatKeyValue{
183
-					KeyId: utils.GetGUID(),
185
+					KeyId: user.OrgId + wechatmenu[i].Sub_Button[j].Name,
184 186
 					Value: wechatmenu[i].Sub_Button[j].Value,
185 187
 					OrgId: user.OrgId,
186 188
 				}
@@ -188,6 +190,8 @@ func (c *MenuController) RefreshMenu() {
188 190
 				if err != nil {
189 191
 					c.ResponseError(err)
190 192
 				}
193
+				utils.LogInfo("↓↓↓↓_________________________↓↓↓↓keyId sub button(controller)↓↓↓↓___________________↓↓↓↓")
194
+				utils.LogInfo(keyvalue.KeyId)
191 195
 				wechatmenu[i].Sub_Button[j].Key = keyvalue.KeyId
192 196
 				wechatmenu[i].Sub_Button[j].Value = ""
193 197
 			}

+ 2
- 2
models/autoreply/autoreply.go ファイルの表示

@@ -133,7 +133,7 @@ func (m *AutoreplyDAO) GetAutoReplayByAppID(appid, val string) (*model.TaAutoRep
133 133
 		return &reply[0], nil
134 134
 	}
135 135
 	// 模糊查询
136
-	sql = `SELECT
136
+	sql = `SELECT DISTINCT
137 137
 						a.*
138 138
 					FROM
139 139
 						ta_auto_reply a
@@ -147,7 +147,7 @@ func (m *AutoreplyDAO) GetAutoReplayByAppID(appid, val string) (*model.TaAutoRep
147 147
 					AND b.status > ?
148 148
 					AND a.auto_type = ?
149 149
 					AND a.pair_type = ?
150
-					AND ? like CONCAT('%', d.keywords, '%') order by a.create_date desc`
150
+					AND d.keywords like CONCAT('%',?, '%') order by a.create_date desc`
151 151
 	err = m.db.Sql(sql, appid, models.AUTOREPLY_IS_USE_ON, models.STATUS_DEL, models.STATUS_DEL, models.AUTOREPLY_KEYWORDS, models.PAIR_TYPE_BLUR, val).Find(&reply)
152 152
 	if err != nil {
153 153
 		return nil, err

+ 8
- 0
models/keyvalue/keyvalue.go ファイルの表示

@@ -6,6 +6,8 @@ import (
6 6
 	"wechat-conf/models/model"
7 7
 	"wechat-conf/utils"
8 8
 
9
+	"github.com/astaxie/beego"
10
+
9 11
 	"github.com/go-xorm/xorm"
10 12
 )
11 13
 
@@ -33,14 +35,20 @@ WHERE
33 35
 	key_id = '` + key + `'
34 36
 	and status > ` + strconv.Itoa(models.STATUS_DEL)
35 37
 	err := m.db.Sql(sql).Find(&keyvalue)
38
+	beego.Info(sql)
39
+	beego.Info("______________________这里是model key——————————————————————————————————")
40
+	beego.Info(keyvalue)
36 41
 	if len(keyvalue) > 0 {
37 42
 		return &keyvalue[0], err
38 43
 	}
44
+
39 45
 	return nil, err
40 46
 }
41 47
 
42 48
 func (m *KeyvalueDAO) AddValueKey(valueKey model.TaWechatKeyValue) error {
43 49
 	valueKey.Status = models.STATUS_NORMAL
50
+	utils.LogInfo("↓↓↓↓_________________________↓↓↓↓keyId button(model)↓↓↓↓___________________↓↓↓↓")
51
+	utils.LogInfo(valueKey.KeyId)
44 52
 	_, err := m.db.Insert(valueKey)
45 53
 	return err
46 54
 }

+ 1
- 1
models/model/ta_wechat_menu.go ファイルの表示

@@ -5,7 +5,7 @@ import (
5 5
 )
6 6
 
7 7
 type TaWechatMenu struct {
8
-	WechatConfigId   string    `xorm:"not null pk VARCHAR(64)"`
8
+	WechatConfigId   string    `xorm:"not null pk VARCHAR(128)"`
9 9
 	WechatConfigJson string    `xorm:"TEXT"`
10 10
 	Status           int       `xorm:"SMALLINT(6)"`
11 11
 	OrgId            string    `xorm:"VARCHAR(64)"`

+ 9
- 1
models/wechatmenu/wechatmenu.go ファイルの表示

@@ -7,6 +7,8 @@ import (
7 7
 	"wechat-conf/models/model"
8 8
 	"wechat-conf/utils"
9 9
 
10
+	"github.com/astaxie/beego"
11
+
10 12
 	"github.com/go-xorm/xorm"
11 13
 )
12 14
 
@@ -48,9 +50,15 @@ func (m *WechatMenuDAO) UpdateWechatMenu(wechatMenu, orgId string) error {
48 50
 	var cols = []string{
49 51
 		"wechat_config_json",
50 52
 	}
51
-	_, err := m.db.Cols(cols...).Where("org_id = ?", menu.WechatConfigId).And("status > ?", strconv.Itoa(models.STATUS_DEL)).Update(menu)
53
+	beego.Info("__________________________更新微信菜单——————————————————————————————————————")
54
+	beego.Info(menu)
55
+	_, err := m.db.Cols(cols...).Where("org_id = ?", menu.OrgId).And("status > ?", strconv.Itoa(models.STATUS_DEL)).Update(menu)
52 56
 	return err
53 57
 }
58
+
59
+// func (m *WechatMenuDAO) GetMenuByOrgId(orgId string) (*model.TaWechatMenu, error) {
60
+
61
+// }
54 62
 func (m *WechatMenuDAO) DeleteWechatMenu(wechatConfigId string) error {
55 63
 	var menu = model.TaWechatMenu{
56 64
 		WechatConfigId: wechatConfigId,

+ 2
- 0
service/wechat/wechat.go ファイルの表示

@@ -98,6 +98,8 @@ func (s *WechatServ) UnAuthorized(appid string) error {
98 98
 // GetMenuReplyText 获取菜单的文字返回
99 99
 func (s *WechatServ) GetMenuReplyText(key string) (string, error) {
100 100
 	res, err := s.kvDAO.GetValueByKey(key)
101
+	utils.LogInfo("_______________________________________res________________________________")
102
+	utils.LogInfo(res)
101 103
 	if err != nil {
102 104
 		return "", err
103 105
 	}