job limit

This commit is contained in:
苏尹岚
2020-10-15 14:16:48 +08:00
parent 3f9d251990
commit f78f323db2
4 changed files with 86 additions and 27 deletions

View File

@@ -19,6 +19,7 @@ import (
const (
AcceptMaxCount = 2
CancelMaxCount = 5
)
func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
@@ -106,3 +107,18 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
func GetJobs(ctx *jxcontext.Context, userIDs []string, categoryIDs []int, includeStep bool, fromTime, toTime string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
return dao.GetJobs(dao.GetDB(), userIDs, categoryIDs, includeStep, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
}
func AcceptJob(ctx *jxcontext.Context, jobID int) (err error) {
var (
db = dao.GetDB()
// userID = ctx.GetUserID()
)
job := &model.Job{}
job.ID = jobID
err = dao.GetEntity(db, &job)
if job.UserID == "" || job.Status == model.JobStatusFailed || job.FinishedAt.Sub(time.Now()) <= 0 {
return fmt.Errorf("未找到该任务或该任务状态不正常,无法接单!")
}
return err
}