胡轶钦 6 年之前
父節點
當前提交
b378a5d856

+ 28
- 13
models/autoreply/autoreply.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
 
@@ -23,16 +25,24 @@ func NewAutoreplyDAO(ctx *utils.Context) *AutoreplyDAO {
23 25
 		db:  ctx.DB,
24 26
 	}
25 27
 }
26
-func (m *AutoreplyDAO) GetAutoReplyList(orgId, autoType string, page, pagesize int) ([]model.TaAutoReply, error) {
27
-	var autoreply []model.TaAutoReply
28
+
29
+type AutoReply struct {
30
+	model.TaAutoReply `xorm:"extends"`
31
+	Url               string
32
+}
33
+
34
+func (m *AutoreplyDAO) GetAutoReplyList(orgId, autoType string, page, pagesize int) ([]AutoReply, error) {
35
+	var autoreply []AutoReply
28 36
 	sql := `SELECT
29
-	* 
37
+	a.*,
38
+	b.url
30 39
 FROM
31
-	ta_auto_reply 
40
+	ta_auto_reply  a
41
+	LEFT JOIN ta_wechat_img b ON a.message_img = b.media_id
32 42
 WHERE
33
-	org_id = '` + orgId + `'
34
-	AND auto_type = '` + autoType + `'
35
-	and status >` + strconv.Itoa(models.STATUS_DEL)
43
+	a.org_id = '` + orgId + `'
44
+	AND a.auto_type = '` + autoType + `'
45
+	and a.status >` + strconv.Itoa(models.STATUS_DEL)
36 46
 	sql += ` order by create_date desc limit ` + strconv.Itoa((page-1)*pagesize) + `, ` + strconv.Itoa(pagesize)
37 47
 	err := m.db.Sql(sql).Find(&autoreply)
38 48
 	return autoreply, err
@@ -91,14 +101,16 @@ func (m *AutoreplyDAO) DeleteAutoReply(autoReplyId string) error {
91 101
 	_, err := m.db.Cols(cols...).Where("auto_reply_id = ?", auto.AutoReplyId).Update(auto)
92 102
 	return err
93 103
 }
94
-func (m *AutoreplyDAO) GetAutoReplyById(autoReplyId string) (*model.TaAutoReply, error) {
95
-	var autoReply []model.TaAutoReply
104
+func (m *AutoreplyDAO) GetAutoReplyById(autoReplyId string) (*AutoReply, error) {
105
+	var autoReply []AutoReply
96 106
 	sql := `SELECT
97
-	* 
107
+	a.*,
108
+	b.url
98 109
 FROM
99
-	ta_auto_reply 
110
+	ta_auto_reply  a
111
+	LEFT JOIN ta_wechat_img b ON a.message_img = b.media_id
100 112
 WHERE
101
-	auto_reply_id = '` + autoReplyId + `'`
113
+	a.auto_reply_id = '` + autoReplyId + `'`
102 114
 	err := m.db.Sql(sql).Find(&autoReply)
103 115
 	if len(autoReply) > 0 {
104 116
 		return &autoReply[0], err
@@ -147,13 +159,16 @@ func (m *AutoreplyDAO) GetAutoReplayByAppID(appid, val string) (*model.TaAutoRep
147 159
 					AND b.status > ?
148 160
 					AND a.auto_type = ?
149 161
 					AND a.pair_type = ?
150
-					AND d.keywords like CONCAT('%',?, '%') order by a.create_date desc`
162
+					AND ? like CONCAT('%',d.keywords, '%') 
163
+					order by a.create_date desc`
151 164
 	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 165
 	if err != nil {
153 166
 		return nil, err
154 167
 	}
155 168
 	if len(reply) > 0 {
156 169
 		return &reply[0], nil
170
+		beego.Info("__________________________REPLY__________________________")
171
+		beego.Info(reply[0])
157 172
 	}
158 173
 	return nil, nil
159 174
 }

+ 1
- 1
service/autoreply/autoreply.go 查看文件

@@ -45,7 +45,7 @@ func (s *AutoreplyServ) GetAutoReplyList(orgId, autoType string, page, pageSize
45 45
 	}, nil
46 46
 }
47 47
 
48
-func (s *AutoreplyServ) GetAutoReplyById(autoReplyId string) (*model.TaAutoReply, error) {
48
+func (s *AutoreplyServ) GetAutoReplyById(autoReplyId string) (*autoreply.AutoReply, error) {
49 49
 	autoreply, err := s.dao.GetAutoReplyById(autoReplyId)
50 50
 	if err != nil {
51 51
 		utils.LogError("获取自动回复详情失败: " + err.Error())

二進制
upload/32C8F661-5180-4903-B994-24FABEF708B4.png 查看文件


二進制
upload/WIN_20180911_15_53_14_Pro (2).jpg 查看文件