胡轶钦 6 years ago
parent
commit
b378a5d856

+ 28
- 13
models/autoreply/autoreply.go View File

7
 	"wechat-conf/models/model"
7
 	"wechat-conf/models/model"
8
 	"wechat-conf/utils"
8
 	"wechat-conf/utils"
9
 
9
 
10
+	"github.com/astaxie/beego"
11
+
10
 	"github.com/go-xorm/xorm"
12
 	"github.com/go-xorm/xorm"
11
 )
13
 )
12
 
14
 
23
 		db:  ctx.DB,
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
 	sql := `SELECT
36
 	sql := `SELECT
29
-	* 
37
+	a.*,
38
+	b.url
30
 FROM
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
 WHERE
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
 	sql += ` order by create_date desc limit ` + strconv.Itoa((page-1)*pagesize) + `, ` + strconv.Itoa(pagesize)
46
 	sql += ` order by create_date desc limit ` + strconv.Itoa((page-1)*pagesize) + `, ` + strconv.Itoa(pagesize)
37
 	err := m.db.Sql(sql).Find(&autoreply)
47
 	err := m.db.Sql(sql).Find(&autoreply)
38
 	return autoreply, err
48
 	return autoreply, err
91
 	_, err := m.db.Cols(cols...).Where("auto_reply_id = ?", auto.AutoReplyId).Update(auto)
101
 	_, err := m.db.Cols(cols...).Where("auto_reply_id = ?", auto.AutoReplyId).Update(auto)
92
 	return err
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
 	sql := `SELECT
106
 	sql := `SELECT
97
-	* 
107
+	a.*,
108
+	b.url
98
 FROM
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
 WHERE
112
 WHERE
101
-	auto_reply_id = '` + autoReplyId + `'`
113
+	a.auto_reply_id = '` + autoReplyId + `'`
102
 	err := m.db.Sql(sql).Find(&autoReply)
114
 	err := m.db.Sql(sql).Find(&autoReply)
103
 	if len(autoReply) > 0 {
115
 	if len(autoReply) > 0 {
104
 		return &autoReply[0], err
116
 		return &autoReply[0], err
147
 					AND b.status > ?
159
 					AND b.status > ?
148
 					AND a.auto_type = ?
160
 					AND a.auto_type = ?
149
 					AND a.pair_type = ?
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
 	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)
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
 	if err != nil {
165
 	if err != nil {
153
 		return nil, err
166
 		return nil, err
154
 	}
167
 	}
155
 	if len(reply) > 0 {
168
 	if len(reply) > 0 {
156
 		return &reply[0], nil
169
 		return &reply[0], nil
170
+		beego.Info("__________________________REPLY__________________________")
171
+		beego.Info(reply[0])
157
 	}
172
 	}
158
 	return nil, nil
173
 	return nil, nil
159
 }
174
 }

+ 1
- 1
service/autoreply/autoreply.go View File

45
 	}, nil
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
 	autoreply, err := s.dao.GetAutoReplyById(autoReplyId)
49
 	autoreply, err := s.dao.GetAutoReplyById(autoReplyId)
50
 	if err != nil {
50
 	if err != nil {
51
 		utils.LogError("获取自动回复详情失败: " + err.Error())
51
 		utils.LogError("获取自动回复详情失败: " + err.Error())

BIN
upload/32C8F661-5180-4903-B994-24FABEF708B4.png View File


BIN
upload/WIN_20180911_15_53_14_Pro (2).jpg View File