- add optional params fromTime and toTime for TmpGetJxBadCommentsByStoreId
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user