作者 tangxvhui

更新数据排序

package dao
import (
"time"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
... ... @@ -20,7 +22,7 @@ func NewSummaryEvaluationDao(options map[string]interface{}) *SummaryEvaluationD
}
}
type PersonalCycle struct {
type ExecutorCycle struct {
CycleId string `pg:"cycle_id" ` //周期id
CycleName string `pg:"cycle_name"` //周期名称
}
... ... @@ -28,7 +30,7 @@ type PersonalCycle struct {
// GetExecutorCycleList 获取执行人拥有的周期列表
// executorId 执行人id
// offset,limit 分页
func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, evaluationType domain.EvaluationType) ([]PersonalCycle, error) {
func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, evaluationType domain.EvaluationType) ([]ExecutorCycle, error) {
sqlStr := `select
distinct
summary_evaluation.cycle_id ,
... ... @@ -48,7 +50,7 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
condition = append(condition, offset, limit)
sqlStr += ` order by summary_evaluation.cycle_id desc offset ? limit ? `
result := []PersonalCycle{}
result := []ExecutorCycle{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ... @@ -75,13 +77,20 @@ func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluation
return cnt, err
}
type TargetUserCycle struct {
CycleId string `pg:"cycle_id" ` //周期id
CycleName string `pg:"cycle_name"` //周期名称
BeginTime time.Time `pg:"begin_time"`
}
// GetExecutorCycleList 获取被评估目标人拥有的周期列表
// executorId 执行人id
// offset,limit 分页
func (d *SummaryEvaluationDao) GetTargetUserCycleList(executorId int, offset int, limit int, evaluationType int) ([]PersonalCycle, error) {
func (d *SummaryEvaluationDao) GetTargetUserCycleList(executorId int, offset int, limit int, evaluationType int) ([]TargetUserCycle, error) {
sqlStr := `select
distinct
summary_evaluation.cycle_id ,
summary_evaluation.begin_time ,
summary_evaluation.cycle_name
from summary_evaluation
where summary_evaluation.target_user ->>'userId'='?'
... ... @@ -97,8 +106,8 @@ func (d *SummaryEvaluationDao) GetTargetUserCycleList(executorId int, offset int
}
condition = append(condition, offset, limit)
sqlStr += ` offset ? limit ? `
result := []PersonalCycle{}
sqlStr += ` order by summary_evaluation.begin_time desc offset ? limit ? `
result := []TargetUserCycle{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ...