This commit is contained in:
苏尹岚
2020-11-02 18:25:25 +08:00
parent ca819b108c
commit 8ab2af4f1c
3 changed files with 29 additions and 4 deletions

View File

@@ -196,6 +196,17 @@ func GetJobs(ctx *jxcontext.Context, userIDs []string, categoryIDs, statuss, ven
return dao.GetJobs(dao.GetDB(), userIDs, categoryIDs, statuss, vendorIDs, []int{model.JobTypeNormal}, includeStep, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
}
func GetJobDetail(ctx *jxcontext.Context, jobID int, lng, lat float64) (job *dao.GetJobsResult, err error) {
var (
db = dao.GetDB()
)
job, err = dao.GetJobDetail(db, jobID)
if job.Lng != 0 && job.Lat != 0 {
job.Distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(job.Lng), jxutils.IntCoordinate2Standard(job.Lat))
}
return job, err
}
func AcceptJob(ctx *jxcontext.Context, jobID int) (errCode string, err error) {
var (
db = dao.GetDB()

View File

@@ -25,8 +25,9 @@ func GetJobCategories(db *DaoDB, name string) (jobCategories []*model.JobCategor
type GetJobsResult struct {
model.Job
CategoryName string `json:"categoryName"` //分类名
IndexImg string `json:"indexImg"` //任务封面
CategoryName string `json:"categoryName"` //分类名
IndexImg string `json:"indexImg"` //任务封面
Distance float64 `json:"distance"` //距用户距离
}
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types []int, includeStep bool, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
@@ -182,7 +183,10 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []in
}
func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
var jobSteps []*model.JobStep
var (
jobImgs []*model.JobImg
jobSteps []*model.JobStep
)
sql := `
SELECT a.*, b.name
FROM job a
@@ -205,6 +209,14 @@ func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
sqlParams2 := []interface{}{job.ID, utils.DefaultTimeValue}
err = GetRows(db, &jobSteps, sql2, sqlParams2)
job.JobSteps = jobSteps
sql3 := `
SELECT *
FROM job_img
WHERE job_id = ?
`
sqlParams3 := []interface{}{job.ID}
err = GetRows(db, &jobImgs, sql3, sqlParams3)
job.JobImgs = jobImgs
} else {
return job, fmt.Errorf("未查到到该任务!")
}

View File

@@ -93,12 +93,14 @@ func (c *JobController) GetJobs() {
// @Description 查看任务
// @Param token header string true "认证token"
// @Param jobID query int false "任务ID"
// @Param lng query float64 false "经度"
// @Param lat query float64 false "维度"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetJobDetail [get]
func (c *JobController) GetJobDetail() {
c.callGetJobDetail(func(params *tJobGetJobDetailParams) (retVal interface{}, errCode string, err error) {
retVal, err = dao.GetJobDetail(dao.GetDB(), params.JobID)
retVal, err = cms.GetJobDetail(params.Ctx, params.JobID, params.Lng, params.Lat)
return retVal, "", err
})
}