- add optional params fromTime and toTime for TmpGetJxBadCommentsByStoreId

This commit is contained in:
gazebo
2019-02-19 16:36:31 +08:00
parent c18a522132
commit c0d659e300
7 changed files with 134 additions and 9 deletions

View File

@@ -608,24 +608,44 @@ func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err
return count, err
}
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, page, size, commentType int) (retVal map[string]interface{}, err error) {
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
db := dao.GetDB()
sql := `
SELECT SQL_CALC_FOUND_ROWS *
FROM jx_bad_comments
WHERE jxstoreid = ?
WHERE 1 = 1
`
if commentType == GET_BAD_COMMENTS_TYPE {
sql += " AND status = 0"
sqlParams := []interface{}{}
if storeID > 0 {
sql += " AND jxstoreid = ?"
sqlParams = append(sqlParams, storeID)
}
sql += " ORDER BY createtime DESC LIMIT ? OFFSET ?"
if commentType == GET_BAD_COMMENTS_TYPE {
sql += " AND status = ?"
sqlParams = append(sqlParams, commentType)
}
if !utils.IsTimeZero(fromTime) {
sql += " AND createtime >= ?"
sqlParams = append(sqlParams, fromTime)
}
if !utils.IsTimeZero(toTime) {
sql += " AND createtime < ?"
sqlParams = append(sqlParams, toTime)
}
sql += " ORDER BY createtime DESC"
pageSize = jxutils.FormalizePageSize(pageSize)
if offset < 0 {
offset = 0
}
sql += " LIMIT ? OFFSET ?"
sqlParams = append(sqlParams, pageSize, offset)
var commentList []*legacymodel.JxBadComments
dao.Begin(db)
defer func() {
dao.Rollback(db)
}()
globals.SugarLogger.Debug(sql)
if err = dao.GetRows(db, &commentList, sql, utils.Int2Str(storeID), size, (page-1)*size); err == nil {
if err = dao.GetRows(db, &commentList, sql, sqlParams...); err == nil {
retVal = map[string]interface{}{
"total": dao.GetLastTotalRowCount(db),
"list": commentList,