作者 tangxvhui

调整自评周期列表

@@ -3,6 +3,6 @@ package query @@ -3,6 +3,6 @@ package query
3 type ListTargetUserCycleQuery struct { 3 type ListTargetUserCycleQuery struct {
4 PageNumber int `json:"pageNumber"` 4 PageNumber int `json:"pageNumber"`
5 PageSize int `json:"pageSize"` 5 PageSize int `json:"pageSize"`
6 - CompanyId int `json:"companyId"` // 6 + CompanyId int `json:"-"` //
7 TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填 7 TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
8 } 8 }
@@ -174,32 +174,29 @@ func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int, @@ -174,32 +174,29 @@ func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int,
174 } 174 }
175 175
176 type TargetUserCycleProject struct { 176 type TargetUserCycleProject struct {
177 - CycleId string `pg:"cycle_id" json:"cycleId"` //周期id  
178 - CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称  
179 - EvaluationProjectIds []string `pg:"evaluation_project_ids,array" json:"evaluationProjectIds"` 177 + CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
  178 + CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
  179 + EvaluationProjectId string `pg:"evaluation_project_id" json:"evaluationProjectId"`
  180 + EvaluationProjectName string `pg:"evaluation_project_name" json:"evaluationProjectName"`
180 } 181 }
181 182
182 // 获取目标员工的自评周期和项目 183 // 获取目标员工的自评周期和项目
183 func (d *StaffAssessDao) SearchTargetUserCycleProject(companyId int, targetUserId int, limit int, offset int) ([]TargetUserCycleProject, error) { 184 func (d *StaffAssessDao) SearchTargetUserCycleProject(companyId int, targetUserId int, limit int, offset int) ([]TargetUserCycleProject, error) {
184 - sqlStr := ` with t_staff_assess as (  
185 - select distinct staff_assess.cycle_id ,  
186 - staff_assess.cycle_name,  
187 - staff_assess.evaluation_project_id  
188 - from staff_assess  
189 - where 1=1  
190 - and staff_assess."types" ='self'  
191 - and staff_assess.deleted_at isnull  
192 - and staff_assess.target_user ->>'userId'='?'  
193 - and staff_assess.company_id=?  
194 - )  
195 - select  
196 - t_staff_assess.cycle_id,  
197 - t_staff_assess.cycle_name,  
198 - array_agg(to_char(t_staff_assess.evaluation_project_id,'9999999999999999999')) as evaluation_project_ids  
199 - from t_staff_assess  
200 - group by cycle_id,cycle_name  
201 - limit ? offset ? 185 + sqlStr := `select distinct
  186 + staff_assess.cycle_name,
  187 + staff_assess.cycle_id ,
  188 + staff_assess.evaluation_project_id,
  189 + staff_assess.evaluation_project_name
  190 + from staff_assess ,staff_assess_task
  191 + where 1=1
  192 + and staff_assess_task.id =staff_assess.staff_assess_task_id
  193 + and staff_assess."types" ='self'
  194 + and staff_assess_task.deleted_at isnull
  195 + and staff_assess.deleted_at isnull
  196 + and staff_assess.target_user ->>'userId'='?'
  197 + and staff_assess.company_id=?
202 ` 198 `
  199 + sqlStr += ` order by cycle_id desc limit ? offset ? `
203 condition := []interface{}{targetUserId, companyId, limit, offset} 200 condition := []interface{}{targetUserId, companyId, limit, offset}
204 result := []TargetUserCycleProject{} 201 result := []TargetUserCycleProject{}
205 tx := d.transactionContext.PgTx 202 tx := d.transactionContext.PgTx
@@ -337,7 +337,6 @@ func (c *StaffAssessController) ListTargetUserSelfCycle() { @@ -337,7 +337,6 @@ func (c *StaffAssessController) ListTargetUserSelfCycle() {
337 } 337 }
338 userReq := middlewares.GetUser(c.Ctx) 338 userReq := middlewares.GetUser(c.Ctx)
339 paramReq.CompanyId = int(userReq.CompanyId) 339 paramReq.CompanyId = int(userReq.CompanyId)
340 - paramReq.TargetUserId = int(userReq.UserId)  
341 data, err := srv.ListTargetUserSelfCycle(paramReq) 340 data, err := srv.ListTargetUserSelfCycle(paramReq)
342 c.Response(data, err) 341 c.Response(data, err)
343 } 342 }