job statsu

This commit is contained in:
苏尹岚
2020-10-16 10:11:05 +08:00
parent 2dbd9d542b
commit 25461b7f8f
3 changed files with 14 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ type GetJobsResult struct {
CategoryName string `json:"CategoryName"` //分类名
}
func GetJobs(db *DaoDB, userIDs []string, categoryIDs []int, includeStep bool, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss []int, includeStep bool, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
var jobs []*GetJobsResult
sql := `
SELECT SQL_CALC_FOUND_ROWS a.*, b.name
@@ -43,6 +43,10 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs []int, includeStep bool, f
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
sqlParams = append(sqlParams, categoryIDs)
}
if len(statuss) > 0 {
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
sqlParams = append(sqlParams, statuss)
}
if fromTime != utils.ZeroTimeValue {
sql += ` AND a.created_at >= ?`
sqlParams = append(sqlParams, fromTime)
@@ -51,9 +55,9 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs []int, includeStep bool, f
sql += ` AND a.created_at <= ?`
sqlParams = append(sqlParams, toTime)
}
sql += " AND a.status <> ? LIMIT ? OFFSET ?"
sql += " LIMIT ? OFFSET ?"
pageSize = jxutils.FormalizePageSize(pageSize)
sqlParams = append(sqlParams, model.JobStatusFailed, pageSize, offset)
sqlParams = append(sqlParams, pageSize, offset)
Begin(db)
defer Commit(db)
if err = GetRows(db, &jobs, sql, sqlParams...); err == nil {