job limit
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user