...
|
...
|
@@ -5,7 +5,6 @@ import ( |
|
|
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
)
|
|
|
|
|
|
type SummaryEvaluationDao struct {
|
...
|
...
|
@@ -31,7 +30,7 @@ type ExecutorCycle struct { |
|
|
// GetExecutorCycleList 获取执行人拥有的周期列表
|
|
|
// executorId 执行人id
|
|
|
// offset,limit 分页
|
|
|
func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
|
|
|
func (d *SummaryEvaluationDao) GetExecutorCycleList(companyId int, executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
|
|
|
sqlStr := `select
|
|
|
distinct on(
|
|
|
summary_evaluation.cycle_id ,
|
...
|
...
|
@@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
|
|
summary_evaluation.cycle_id ,
|
|
|
summary_evaluation.cycle_name
|
|
|
from summary_evaluation
|
|
|
where summary_evaluation.executor ->>'userId'='?'
|
|
|
where summary_evaluation.company_id=?
|
|
|
`
|
|
|
tx := d.transactionContext.PgTx
|
|
|
condition := []interface{}{
|
|
|
executorId,
|
|
|
companyId, executorId,
|
|
|
}
|
|
|
if isHrbp {
|
|
|
sqlStr += ` or summary_evaluation."types"=4 `
|
|
|
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
|
|
|
} else {
|
|
|
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
|
|
|
}
|
|
|
condition = append(condition, offset, limit)
|
|
|
|
...
|
...
|
@@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
|
|
}
|
|
|
|
|
|
// CountExecutorCycleList 统计执行人拥有的周期列表
|
|
|
func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluationType domain.EvaluationType) (int, error) {
|
|
|
func (d *SummaryEvaluationDao) CountExecutorCycleList(companyId int, executorId int, isHrbp bool) (int, error) {
|
|
|
sqlStr := `select count(
|
|
|
distinct summary_evaluation.cycle_id
|
|
|
) as cnt
|
|
|
from summary_evaluation
|
|
|
where summary_evaluation.executor ->>'userId'='?' `
|
|
|
where summary_evaluation.company_id=? `
|
|
|
|
|
|
tx := d.transactionContext.PgTx
|
|
|
condition := []interface{}{
|
|
|
executorId,
|
|
|
companyId, executorId,
|
|
|
}
|
|
|
if evaluationType > 0 {
|
|
|
sqlStr += ` and summary_evaluation."types"=? `
|
|
|
condition = append(condition, int(evaluationType))
|
|
|
if isHrbp {
|
|
|
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
|
|
|
} else {
|
|
|
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
|
|
|
}
|
|
|
|
|
|
var cnt int
|
|
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
|
|
return cnt, err
|
...
|
...
|
|