作者 tangxvhui

调整参数类型

@@ -8,6 +8,6 @@ type ListTaskAnomalyCommand struct { @@ -8,6 +8,6 @@ type ListTaskAnomalyCommand struct {
8 TaskName string `json:"taskName"` 8 TaskName string `json:"taskName"`
9 DayTime string `json:"dayTime"` //发生异常的日期 9 DayTime string `json:"dayTime"` //发生异常的日期
10 Category int `json:"category"` //异常分类 10 Category int `json:"category"` //异常分类
11 - LeaderId string `json:"leaderId"` //任务负责人id 11 + LeaderId []string `json:"leaderId"` //任务负责人id
12 SubLevel int `json:"subLevel"` //userId 的下级 ,向下查询多少级 12 SubLevel int `json:"subLevel"` //userId 的下级 ,向下查询多少级
13 } 13 }
@@ -36,10 +36,7 @@ func (srv TaskService) listTaskAnomaly2(param *command.ListTaskAnomalyCommand) ( @@ -36,10 +36,7 @@ func (srv TaskService) listTaskAnomaly2(param *command.ListTaskAnomalyCommand) (
36 }) 36 })
37 limit := 500 37 limit := 500
38 offset := 0 38 offset := 0
39 - // if param.SubLevel < 1 {  
40 - // param.SubLevel = 2  
41 - // }  
42 - cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, param.SubLevel, limit, offset) 39 + cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.LeaderId, param.DayTime, param.SubLevel, limit, offset)
43 if err != nil { 40 if err != nil {
44 return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 41 return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
45 } 42 }
@@ -139,7 +139,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ @@ -139,7 +139,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ
139 // pageSize 分页大小 139 // pageSize 分页大小
140 // pageNumber 分页页码 140 // pageNumber 分页页码
141 // subLevel 我的下级的层级 141 // subLevel 我的下级的层级
142 -func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, category int, leaderId string, dayTime string, subLevel int, limit int, offset int) (int, []ListTaskAnomaly, error) { 142 +func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, category int, leaderId []string, dayTime string, subLevel int, limit int, offset int) (int, []ListTaskAnomaly, error) {
143 sqlStr1 := `with 143 sqlStr1 := `with
144 -- 人员自身以及全下级 144 -- 人员自身以及全下级
145 recursive t_user as ( 145 recursive t_user as (
@@ -232,6 +232,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -232,6 +232,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
232 task.end_time as "task_end_time", 232 task.end_time as "task_end_time",
233 task.sort_by as "task_sort_by", 233 task.sort_by as "task_sort_by",
234 task.leader->>'name' as "leader_name", 234 task.leader->>'name' as "leader_name",
  235 + task.leader ->>'id' as "leader_id"
235 task.level_name 236 task.level_name
236 from task 237 from task
237 left join t_task_ignore on task.id=t_task_ignore.task_id 238 left join t_task_ignore on task.id=t_task_ignore.task_id
@@ -261,6 +262,11 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -261,6 +262,11 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
261 sqlStr1 += ` and task_anomaly.category=? ` 262 sqlStr1 += ` and task_anomaly.category=? `
262 sqlStr2 += ` and task_anomaly.category=? ` 263 sqlStr2 += ` and task_anomaly.category=? `
263 } 264 }
  265 + if len(leaderId) > 0 {
  266 + condition = append(condition, pg.In(leaderId))
  267 + sqlStr2 += ` and t_task.leader_id in (?) `
  268 + sqlStr1 += ` and t_task.leader_id in (?) `
  269 + }
264 condition = append(condition, limit, offset) 270 condition = append(condition, limit, offset)
265 sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? ` 271 sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? `
266 272
@@ -281,7 +287,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -281,7 +287,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
281 // dayTime 搜索条件日期 ,例:"2006-01-02" 287 // dayTime 搜索条件日期 ,例:"2006-01-02"
282 // pageSize 分页大小 288 // pageSize 分页大小
283 // pageNumber 分页页码 289 // pageNumber 分页页码
284 -func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId string, limit int, offset int) (int, []ListTaskAnomaly, error) { 290 +func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId []string, limit int, offset int) (int, []ListTaskAnomaly, error) {
285 sqlStr1 := ` with t_task_ignore as ( 291 sqlStr1 := ` with t_task_ignore as (
286 select task_ignore.id ,task_ignore.task_id 292 select task_ignore.id ,task_ignore.task_id
287 from task_ignore 293 from task_ignore
@@ -345,9 +351,9 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ @@ -345,9 +351,9 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
345 351
346 } 352 }
347 if len(leaderId) > 0 { 353 if len(leaderId) > 0 {
348 - condition = append(condition, fmt.Sprintf(`{"id":"%s"}`, leaderId))  
349 - sqlStr1 += ` and task.leader@>? `  
350 - sqlStr2 += ` and task.leader@>? ` 354 + condition = append(condition, pg.In(leaderId))
  355 + sqlStr1 += ` and task.leader->>'id' in (?) `
  356 + sqlStr2 += ` and task.leader->>'id' in (?) `
351 } 357 }
352 condition = append(condition, limit, offset) 358 condition = append(condition, limit, offset)
353 sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? ` 359 sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? `