作者 tangxvhui

调整自评周期列表

... ... @@ -3,6 +3,6 @@ package query
type ListTargetUserCycleQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CompanyId int `json:"companyId"` //
CompanyId int `json:"-"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
}
... ...
... ... @@ -174,32 +174,29 @@ func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int,
}
type TargetUserCycleProject struct {
CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
EvaluationProjectIds []string `pg:"evaluation_project_ids,array" json:"evaluationProjectIds"`
CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
EvaluationProjectId string `pg:"evaluation_project_id" json:"evaluationProjectId"`
EvaluationProjectName string `pg:"evaluation_project_name" json:"evaluationProjectName"`
}
// 获取目标员工的自评周期和项目
func (d *StaffAssessDao) SearchTargetUserCycleProject(companyId int, targetUserId int, limit int, offset int) ([]TargetUserCycleProject, error) {
sqlStr := ` with t_staff_assess as (
select distinct staff_assess.cycle_id ,
staff_assess.cycle_name,
staff_assess.evaluation_project_id
from staff_assess
where 1=1
and staff_assess."types" ='self'
and staff_assess.deleted_at isnull
and staff_assess.target_user ->>'userId'='?'
and staff_assess.company_id=?
)
select
t_staff_assess.cycle_id,
t_staff_assess.cycle_name,
array_agg(to_char(t_staff_assess.evaluation_project_id,'9999999999999999999')) as evaluation_project_ids
from t_staff_assess
group by cycle_id,cycle_name
limit ? offset ?
sqlStr := `select distinct
staff_assess.cycle_name,
staff_assess.cycle_id ,
staff_assess.evaluation_project_id,
staff_assess.evaluation_project_name
from staff_assess ,staff_assess_task
where 1=1
and staff_assess_task.id =staff_assess.staff_assess_task_id
and staff_assess."types" ='self'
and staff_assess_task.deleted_at isnull
and staff_assess.deleted_at isnull
and staff_assess.target_user ->>'userId'='?'
and staff_assess.company_id=?
`
sqlStr += ` order by cycle_id desc limit ? offset ? `
condition := []interface{}{targetUserId, companyId, limit, offset}
result := []TargetUserCycleProject{}
tx := d.transactionContext.PgTx
... ...
... ... @@ -337,7 +337,6 @@ func (c *StaffAssessController) ListTargetUserSelfCycle() {
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserSelfCycle(paramReq)
c.Response(data, err)
}
... ...