distance
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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("未查到到该任务!")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user