560 lines
16 KiB
Go
560 lines
16 KiB
Go
package dao
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"math"
|
|
"strings"
|
|
"time"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
)
|
|
|
|
const (
|
|
sortTypeDistance = 1 //距离
|
|
sortTypeTime = 2 //发布时间
|
|
sortTypeAvgPrice = 4 //奖励高低
|
|
)
|
|
|
|
func GetJobCategories(db *DaoDB, name string) (jobCategories []*model.JobCategory, err error) {
|
|
sql := `
|
|
SELECT * FROM job_category WHERE deleted_at = ?
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
if name != "" {
|
|
sql += ` AND name LIKE ?`
|
|
sqlParams = append(sqlParams, "%"+name+"%")
|
|
}
|
|
err = GetRows(db, &jobCategories, sql, sqlParams)
|
|
return jobCategories, err
|
|
}
|
|
|
|
type GetJobsResult struct {
|
|
model.Job
|
|
CategoryName string `json:"categoryName"` //分类名
|
|
IndexImg string `json:"indexImg"` //任务封面
|
|
Distance float64 `json:"distance"` //距用户距离
|
|
}
|
|
|
|
func GetJobSteps(db *DaoDB, jobID int) (jobSteps []*model.JobStep, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM job_step
|
|
WHERE job_id = ?
|
|
AND deleted_at = ?
|
|
`
|
|
sqlParams := []interface{}{jobID, utils.DefaultTimeValue}
|
|
err = GetRows(db, &jobSteps, sql, sqlParams)
|
|
return jobSteps, err
|
|
}
|
|
|
|
func GetJobImgs(db *DaoDB, jobID int) (jobImgs []*model.JobImg, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM job_img
|
|
WHERE job_id = ?
|
|
`
|
|
sqlParams := []interface{}{jobID}
|
|
err = GetRows(db, &jobImgs, sql, sqlParams)
|
|
return jobImgs, err
|
|
}
|
|
|
|
func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types []int, includeStep bool, fromTime, toTime time.Time, lng, lat float64, span int, keyword string, sortType, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
|
var (
|
|
jobs []*GetJobsResult
|
|
sqlParams = []interface{}{}
|
|
)
|
|
sql := `
|
|
SELECT SQL_CALC_FOUND_ROWS a.*, b.name, getDistance(?, ?, CAST(a.lng AS DECIMAL(15,6))/1000000, CAST(a.lat AS DECIMAL(15,6))/1000000) distance
|
|
FROM job a
|
|
JOIN job_category b ON b.id = a.job_category_id AND b.deleted_at = ?
|
|
WHERE a.deleted_at = ?
|
|
`
|
|
sqlParams = append(sqlParams, lng, lat, utils.DefaultTimeValue, utils.DefaultTimeValue)
|
|
if len(userIDs) > 0 {
|
|
sql += ` AND a.user_id IN (` + GenQuestionMarks(len(userIDs)) + `)`
|
|
sqlParams = append(sqlParams, userIDs)
|
|
}
|
|
if len(categoryIDs) > 0 {
|
|
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
|
|
sqlParams = append(sqlParams, categoryIDs)
|
|
}
|
|
if len(statuss) > 0 {
|
|
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
|
sqlParams = append(sqlParams, statuss)
|
|
}
|
|
if len(vendorIDs) > 0 {
|
|
sql += ` AND a.vendor_id IN (` + GenQuestionMarks(len(vendorIDs)) + `)`
|
|
sqlParams = append(sqlParams, vendorIDs)
|
|
}
|
|
if len(types) > 0 {
|
|
sql += ` AND a.type IN (` + GenQuestionMarks(len(types)) + `)`
|
|
sqlParams = append(sqlParams, types)
|
|
}
|
|
if fromTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at >= ?`
|
|
sqlParams = append(sqlParams, fromTime)
|
|
}
|
|
if toTime != utils.ZeroTimeValue {
|
|
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`
|
|
}
|
|
}
|
|
if keyword != "" {
|
|
sql += ` AND (a.title LIKE ? OR a.content LIKE ? OR a.address LIKE ? OR b.name LIKE ?)`
|
|
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
|
}
|
|
if sortType != 0 {
|
|
if sortType == sortTypeDistance {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, distance`
|
|
} else if sortType == -sortTypeDistance {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, distance DESC`
|
|
} else if sortType == sortTypeAvgPrice {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, a.avg_price`
|
|
} else if sortType == -sortTypeAvgPrice {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, a.avg_price DESC`
|
|
} else if sortType == sortTypeTime {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, a.created_at`
|
|
} else if sortType == -sortTypeTime {
|
|
sql += ` ORDER BY job_span_top DESC, top_seq, a.created_at DESC`
|
|
}
|
|
}
|
|
sql += " LIMIT ? OFFSET ?"
|
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
|
sqlParams = append(sqlParams, pageSize, offset)
|
|
Begin(db)
|
|
defer Commit(db)
|
|
if err = GetRows(db, &jobs, sql, sqlParams...); err == nil {
|
|
pagedInfo = &model.PagedInfo{
|
|
TotalCount: GetLastTotalRowCount(db),
|
|
// Data: jobs,
|
|
}
|
|
for _, v := range jobs {
|
|
if includeStep {
|
|
if jobSteps, err := GetJobSteps(db, v.ID); err == nil && len(jobSteps) > 0 {
|
|
v.JobSteps = jobSteps
|
|
}
|
|
}
|
|
if jobImgs, err := GetJobImgs(db, v.ID); err == nil && len(jobImgs) > 0 {
|
|
v.JobImgs = jobImgs
|
|
v.IndexImg = jobImgs[0].Img
|
|
}
|
|
}
|
|
pagedInfo.Data = jobs
|
|
}
|
|
return pagedInfo, err
|
|
}
|
|
|
|
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)
|
|
if err != nil {
|
|
return job, err
|
|
}
|
|
if len(jobs) == 0 {
|
|
return job, fmt.Errorf("未查询到对应的京东快递任务!")
|
|
}
|
|
if data, err := json.Marshal(jobs[0]); err == nil {
|
|
json.Unmarshal(data, &job)
|
|
}
|
|
return job, err
|
|
}
|
|
|
|
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (jobs []*GetJobsResult, err error) {
|
|
sql := `
|
|
SELECT a.*, b.name
|
|
FROM job a
|
|
JOIN job_category b ON b.id = a.job_category_id AND b.deleted_at = ?
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
if len(userIDs) > 0 {
|
|
sql += ` AND a.user_id IN (` + GenQuestionMarks(len(userIDs)) + `)`
|
|
sqlParams = append(sqlParams, userIDs)
|
|
}
|
|
if len(categoryIDs) > 0 {
|
|
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
|
|
sqlParams = append(sqlParams, categoryIDs)
|
|
}
|
|
if len(statuss) > 0 {
|
|
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
|
sqlParams = append(sqlParams, statuss)
|
|
}
|
|
if len(types) > 0 {
|
|
sql += ` AND a.type IN (` + GenQuestionMarks(len(types)) + `)`
|
|
sqlParams = append(sqlParams, types)
|
|
}
|
|
if fromTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at >= ?`
|
|
sqlParams = append(sqlParams, fromTime)
|
|
}
|
|
if toTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at <= ?`
|
|
sqlParams = append(sqlParams, toTime)
|
|
}
|
|
err = GetRows(db, &jobs, sql, sqlParams...)
|
|
for _, v := range jobs {
|
|
if includeStep {
|
|
if jobSteps, err := GetJobSteps(db, v.ID); err == nil && len(jobSteps) > 0 {
|
|
v.JobSteps = jobSteps
|
|
}
|
|
}
|
|
if jobImgs, err := GetJobImgs(db, v.ID); err == nil && len(jobImgs) > 0 {
|
|
v.JobImgs = jobImgs
|
|
}
|
|
}
|
|
return jobs, err
|
|
}
|
|
|
|
func GetJobDetail(db *DaoDB, jobID int) (job *GetJobsResult, err error) {
|
|
sql := `
|
|
SELECT a.*, b.name
|
|
FROM job a
|
|
JOIN job_category b ON b.id = a.job_category_id AND b.deleted_at = ?
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
if jobID != 0 {
|
|
sql += ` AND a.id = ?`
|
|
sqlParams = append(sqlParams, jobID)
|
|
}
|
|
err = GetRow(db, &job, sql, sqlParams...)
|
|
if job != nil {
|
|
if jobSteps, err := GetJobSteps(db, job.ID); err == nil && len(jobSteps) > 0 {
|
|
job.JobSteps = jobSteps
|
|
}
|
|
if jobImgs, err := GetJobImgs(db, job.ID); err == nil && len(jobImgs) > 0 {
|
|
job.JobImgs = jobImgs
|
|
}
|
|
} else {
|
|
return job, fmt.Errorf("未查到到该任务!")
|
|
}
|
|
return job, err
|
|
}
|
|
|
|
func GetJobOrdersNoPage(db *DaoDB, jobID int, jobOrderID int64, userID string, statusCompareStr string, fromTime, toTime time.Time, statuss []int) (jobOrders []*model.JobOrder, err error) {
|
|
sql := `
|
|
SELECT a.*
|
|
FROM job_order a
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{}
|
|
if jobID != 0 {
|
|
sql += ` AND a.job_id = ?`
|
|
sqlParams = append(sqlParams, jobID)
|
|
}
|
|
if jobOrderID != 0 {
|
|
sql += ` AND a.job_order_id = ?`
|
|
sqlParams = append(sqlParams, jobOrderID)
|
|
}
|
|
if userID != "" {
|
|
sql += ` AND a.user_id = ?`
|
|
sqlParams = append(sqlParams, userID)
|
|
}
|
|
if statusCompareStr != "" {
|
|
sql += ` AND a.status ` + statusCompareStr
|
|
}
|
|
if fromTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at >= ?`
|
|
sqlParams = append(sqlParams, fromTime)
|
|
}
|
|
if toTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at <= ?`
|
|
sqlParams = append(sqlParams, toTime)
|
|
}
|
|
if len(statuss) > 0 {
|
|
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
|
sqlParams = append(sqlParams, statuss)
|
|
}
|
|
err = GetRows(db, &jobOrders, sql, sqlParams)
|
|
return jobOrders, err
|
|
}
|
|
|
|
type GetJobOrdersResult struct {
|
|
model.JobOrder
|
|
JobLimitAt int `json:"jobLimitAt"` //任务限时完成小时数
|
|
AuditLimitAt int `json:"auditLimitAt"` //限时审核小时数
|
|
JobOrderFinishAt time.Time `json:"jobOrderFinishAt"`
|
|
JobOrderAuditFinishAt time.Time `json:"jobOrderAuditFinishAt"`
|
|
JobIndexImg string `json:"jobIndexImg"`
|
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"` //推广平台
|
|
AvgPrice int `json:"avgPrice"` //单个任务金额
|
|
Title string `orm:"size(255)" json:"title"` //任务标题
|
|
JobContent string `orm:"size(500)" json:"jobContent"`
|
|
JobCategoryID int `orm:"column(job_category_id)" json:"jobCategoryID"`
|
|
StoreURL string `orm:"column(store_url)" json:"storeURL"`
|
|
}
|
|
|
|
func GetJobOrders(db *DaoDB, jobID int, jobOrderID int64, userID, jobUserID string, statusCompareStr string, fromTime, toTime time.Time, statuss []int, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
|
var jobOrders []*GetJobOrdersResult
|
|
sql := `
|
|
SELECT SQL_CALC_FOUND_ROWS a.*, b.job_limit_at, b.vendor_id, b.avg_price, b.title, b.content job_content, b.audit_limit_at, b.job_category_id, b.store_url
|
|
FROM job_order a
|
|
JOIN job b ON a.job_id = b.id
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{}
|
|
if jobID != 0 {
|
|
sql += ` AND a.job_id = ?`
|
|
sqlParams = append(sqlParams, jobID)
|
|
}
|
|
if jobOrderID != 0 {
|
|
sql += ` AND a.job_order_id = ?`
|
|
sqlParams = append(sqlParams, jobOrderID)
|
|
}
|
|
if userID != "" {
|
|
sql += ` AND a.user_id = ?`
|
|
sqlParams = append(sqlParams, userID)
|
|
}
|
|
if jobUserID != "" {
|
|
sql += ` AND b.user_id = ?`
|
|
sqlParams = append(sqlParams, jobUserID)
|
|
}
|
|
if statusCompareStr != "" {
|
|
sql += ` AND a.status ` + statusCompareStr
|
|
}
|
|
if fromTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at >= ?`
|
|
sqlParams = append(sqlParams, fromTime)
|
|
}
|
|
if toTime != utils.ZeroTimeValue {
|
|
sql += ` AND a.created_at <= ?`
|
|
sqlParams = append(sqlParams, toTime)
|
|
}
|
|
if len(statuss) > 0 {
|
|
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
|
sqlParams = append(sqlParams, statuss)
|
|
}
|
|
sql += " LIMIT ? OFFSET ?"
|
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
|
sqlParams = append(sqlParams, pageSize, offset)
|
|
Begin(db)
|
|
defer Commit(db)
|
|
if err = GetRows(db, &jobOrders, sql, sqlParams...); err == nil {
|
|
pagedInfo = &model.PagedInfo{
|
|
TotalCount: GetLastTotalRowCount(db),
|
|
// Data: jobOrders,
|
|
}
|
|
for _, v := range jobOrders {
|
|
if jobImgs, err := GetJobImgs(db, v.JobID); err == nil && len(jobImgs) > 0 {
|
|
v.JobIndexImg = jobImgs[0].Img
|
|
}
|
|
v.JobOrderFinishAt = v.JobOrder.CreatedAt.Add(time.Duration(v.JobLimitAt) * time.Hour)
|
|
v.JobOrderAuditFinishAt = v.JobOrder.SubmitAuditAt.Add(time.Duration(v.AuditLimitAt) * time.Hour)
|
|
}
|
|
pagedInfo.Data = jobOrders
|
|
}
|
|
return pagedInfo, err
|
|
}
|
|
|
|
func GetMtMember(db *DaoDB) (mtMember *model.MtMember, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM mt_member
|
|
WHERE deleted_at = ?
|
|
LIMIT 1
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
err = GetRow(db, &mtMember, sql, sqlParams)
|
|
return mtMember, err
|
|
}
|
|
|
|
func GetJobTimers(db *DaoDB, status int) (jobTimers []*model.JobTimer, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM job_timer
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{}
|
|
if status != -1 {
|
|
sql += ` AND status = ?`
|
|
sqlParams = append(sqlParams, status)
|
|
}
|
|
err = GetRows(db, &jobTimers, sql, sqlParams)
|
|
return jobTimers, err
|
|
}
|
|
|
|
func GetMtMembers(db *DaoDB) (num int, err error) {
|
|
var mtMembers []*model.MtMember
|
|
sql := `
|
|
SELECT * FROM mt_member WHERE deleted_at = ?
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
err = GetRows(db, &mtMembers, sql, sqlParams)
|
|
num = len(mtMembers)
|
|
return num, err
|
|
}
|
|
|
|
func GetUserSearch(db *DaoDB, userID, keyword string) (userSearchs []*model.UserSearch, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM user_search
|
|
WHERE 1 = 1
|
|
`
|
|
sqlParams := []interface{}{}
|
|
if userID != "" {
|
|
sql += " AND user_id = ?"
|
|
sqlParams = append(sqlParams, userID)
|
|
}
|
|
if keyword != "" {
|
|
sql += " AND keyword = ?"
|
|
sqlParams = append(sqlParams, keyword)
|
|
}
|
|
err = GetRows(db, &userSearchs, sql, sqlParams)
|
|
return userSearchs, err
|
|
}
|
|
|
|
func GetStationList(db *DaoDB) (stations []*model.StationInfo, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM station_info
|
|
`
|
|
sqlParams := []interface{}{}
|
|
err = GetRows(db, &stations, sql, sqlParams)
|
|
return stations, err
|
|
}
|
|
|
|
func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng float64, oilCode string, sortType, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
|
var (
|
|
stations []*model.StationInfo
|
|
distanceFlag bool
|
|
sqlParams = []interface{}{}
|
|
)
|
|
if lng != 0 && lat != 0 {
|
|
distanceFlag = true
|
|
}
|
|
sql := `
|
|
SELECT SQL_CALC_FOUND_ROWS *
|
|
`
|
|
if distanceFlag {
|
|
sql += `, getDistance(?, ?, longitude, latitude) distance`
|
|
sqlParams = append(sqlParams, lng, lat)
|
|
}
|
|
sql += `
|
|
FROM station_info
|
|
WHERE 1 = 1
|
|
`
|
|
if stationName != "" {
|
|
sql += " AND station_name LIKE ?"
|
|
sqlParams = append(sqlParams, "%"+stationName+"%")
|
|
}
|
|
if cityCode != 0 {
|
|
sql += " AND city_id = ?"
|
|
sqlParams = append(sqlParams, cityCode)
|
|
}
|
|
if oilCode != "" {
|
|
sql += " AND POSITION(? IN prices) > 0"
|
|
sqlParams = append(sqlParams, oilCode)
|
|
}
|
|
if sortType != 0 {
|
|
if sortType == 1 {
|
|
sql += " ORDER BY distance"
|
|
} else if sortType == -1 {
|
|
sql += " ORDER BY distance DESC"
|
|
} else if sortType == 2 {
|
|
sql += " ORDER BY star_num"
|
|
} else if sortType == -2 {
|
|
sql += " ORDER BY star_num DESC"
|
|
}
|
|
}
|
|
sql += " LIMIT ? OFFSET ?"
|
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
|
sqlParams = append(sqlParams, pageSize, offset)
|
|
Begin(db)
|
|
defer Commit(db)
|
|
if err = GetRows(db, &stations, sql, sqlParams...); err == nil {
|
|
pagedInfo = &model.PagedInfo{
|
|
TotalCount: GetLastTotalRowCount(db),
|
|
// Data: stations,
|
|
}
|
|
for _, v := range stations {
|
|
var oilInfo []*model.OilInfo
|
|
json.Unmarshal([]byte(strings.ReplaceAll(v.Prices, "\\", "")), &oilInfo)
|
|
v.OilInfo = oilInfo
|
|
}
|
|
if math.Abs(utils.Int2Float64(sortType)) == 3 {
|
|
if oilCode != "" {
|
|
for i := 0; i < len(stations); i++ {
|
|
for j := 0; j < len(stations)-i-1; j++ {
|
|
var (
|
|
index int
|
|
index2 int
|
|
)
|
|
for k, v := range stations[j].OilInfo {
|
|
if v.OilCode == oilCode {
|
|
index = k
|
|
}
|
|
}
|
|
for k, v := range stations[j+1].OilInfo {
|
|
if v.OilCode == oilCode {
|
|
index2 = k
|
|
}
|
|
}
|
|
if sortType == 3 {
|
|
if utils.Str2Float64(stations[j].OilInfo[index].DiscountPrice) > utils.Str2Float64(stations[j+1].OilInfo[index2].DiscountPrice) {
|
|
temp := stations[j]
|
|
stations[j] = stations[j+1]
|
|
stations[j+1] = temp
|
|
}
|
|
} else if sortType == -3 {
|
|
if utils.Str2Float64(stations[j].OilInfo[index].DiscountPrice) < utils.Str2Float64(stations[j+1].OilInfo[index2].DiscountPrice) {
|
|
temp := stations[j]
|
|
stations[j] = stations[j+1]
|
|
stations[j+1] = temp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pagedInfo.Data = stations
|
|
}
|
|
return pagedInfo, err
|
|
}
|
|
|
|
func GetMaxJobTopSeq(db *DaoDB) (maxSeq int, err error) {
|
|
Seq := &struct {
|
|
TopSeq int
|
|
}{}
|
|
sql := `
|
|
SELECT MAX(top_seq) top_seq FROM job WHERE deleted_at = ? AND status = ? AND job_span_top = ?
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue, model.JobStatusDoing, 1}
|
|
if err = GetRow(db, &Seq, sql, sqlParams); err == nil {
|
|
return Seq.TopSeq, err
|
|
}
|
|
return maxSeq, err
|
|
}
|
|
|
|
func GetMaxJobRecmdSeq(db *DaoDB) (maxSeq int, err error) {
|
|
Seq := &struct {
|
|
RecmdSeq int
|
|
}{}
|
|
sql := `
|
|
SELECT MAX(recmd_seq) recmd_seq FROM job WHERE deleted_at = ? AND status = ? AND job_span_recmd = ?
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue, model.JobStatusDoing, 1}
|
|
if err = GetRow(db, &Seq, sql, sqlParams); err == nil {
|
|
return Seq.RecmdSeq, err
|
|
}
|
|
return maxSeq, err
|
|
}
|
|
|
|
func GetJobSpans(db *DaoDB) (jobSpans []*model.JobSpan, err error) {
|
|
sql := `
|
|
SELECT *
|
|
FROM job_span
|
|
WHERE deleted_at = ?
|
|
`
|
|
sqlParams := []interface{}{utils.DefaultTimeValue}
|
|
err = GetRows(db, &jobSpans, sql, sqlParams)
|
|
return jobSpans, err
|
|
}
|