|
@@ -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
|
}
|