This commit is contained in:
苏尹岚
2020-12-17 17:35:57 +08:00
parent e5082bbfe7
commit 1f3164832d
3 changed files with 40 additions and 4 deletions

View File

@@ -154,7 +154,7 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
}
func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (job *model.Job, err error) {
jobs, err := GetJobsNoPage(db, userIDs, categoryIDs, statuss, types, fromTime, toTime, includeStep)
jobs, err := GetJobsNoPage(db, userIDs, categoryIDs, statuss, types, fromTime, toTime, 0, includeStep)
if err != nil {
return job, err
}
@@ -167,7 +167,7 @@ func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, from
return job, err
}
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (jobs []*GetJobsResult, err error) {
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, span int, includeStep bool) (jobs []*GetJobsResult, err error) {
sql := `
SELECT a.*, b.name
FROM job a
@@ -199,6 +199,13 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []in
sql += ` AND a.created_at <= ?`
sqlParams = append(sqlParams, toTime)
}
if span != 0 {
if span == model.JobSpanTop {
sql += ` AND a.job_span_top = 1`
} else {
sql += ` AND a.job_span_recmd = 1`
}
}
err = GetRows(db, &jobs, sql, sqlParams...)
for _, v := range jobs {
if includeStep {