TmpGetJxBadComments添加可选参数keyword

This commit is contained in:
gazebo
2019-11-11 17:33:19 +08:00
parent e763aac526
commit ef5e755544
2 changed files with 13 additions and 5 deletions

View File

@@ -1123,7 +1123,7 @@ func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err
return count, err
}
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, keyword string, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
db := dao.GetDB()
sql := `
SELECT SQL_CALC_FOUND_ROWS
@@ -1136,6 +1136,13 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset
WHERE 1 = 1
`
sqlParams := []interface{}{}
if keyword != "" {
keywordLike := "%" + keyword + "%"
sql += `
AND (t1.order_id LIKE ? OR t1.jxstoreid LIKE ? OR t1.userphone LIKE ? OR t1.scorecontent LIKE ? OR t1.vendertags LIKE ? OR t1.updated_scorecontent LIKE ?
OR t1.updated_vendertags LIKE ? OR t2.name LIKE ?)`
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
}
if len(storeIDs) > 0 {
sql += " AND t1.jxstoreid IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
sqlParams = append(sqlParams, storeIDs)

View File

@@ -237,7 +237,7 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() {
if err = err2; err == nil {
pageSize := jxutils.FormalizePageSize(params.Size)
offset := (params.Page - 1) * pageSize
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1])
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, "", []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1])
}
return retVal, "", err
})
@@ -247,11 +247,12 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() {
// @Description 得到门店评价列表(多店)
// @Param token header string true "认证token"
// @Param type query int true "评论类型0差评1所有2已解决"
// @Param keyword query string false "关键字"
// @Param storeIDs query string false "门店I列表"
// @Param offset query int false "起始页从1开始"
// @Param pageSize query int false "页大小(-1表示无限大"
// @Param fromTime query string false "创建起始时间"
// @Param toTime query string false "创建结束时间"
// @Param offset query int false "起始页从1开始"
// @Param pageSize query int false "页大小(-1表示无限大"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /TmpGetJxBadComments [get]
@@ -261,7 +262,7 @@ func (c *StoreController) TmpGetJxBadComments() {
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime)
if err = err2; err == nil {
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1])
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, params.Keyword, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1])
}
}
return retVal, "", err