正在显示
1 个修改的文件
包含
37 行增加
和
5 行删除
@@ -317,7 +317,23 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ | @@ -317,7 +317,23 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ | ||
317 | // pageSize 分页大小 | 317 | // pageSize 分页大小 |
318 | // pageNumber 分页页码 | 318 | // pageNumber 分页页码 |
319 | func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId []string, limit int, offset int) (int, []ListTaskAnomaly, error) { | 319 | func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId []string, limit int, offset int) (int, []ListTaskAnomaly, error) { |
320 | - sqlStr1 := ` with t_task_ignore as ( | 320 | + sqlStr1 := ` with |
321 | + recursive t_user as ( | ||
322 | + ( | ||
323 | + select "user".id,"user".parent_id ,"user".account,"user".name, 1 as "level" | ||
324 | + from "user" | ||
325 | + where "user".id=? and "user".deleted_at isnull | ||
326 | + ) | ||
327 | + union | ||
328 | + ( | ||
329 | + select "child_user".id,"child_user".parent_id,"child_user".account,"child_user".name, | ||
330 | + "parent_user"."level"+1 as "level" | ||
331 | + from "user" as "child_user" | ||
332 | + join t_user as "parent_user" on "parent_user".id="child_user".parent_id | ||
333 | + where "child_user".deleted_at isnull | ||
334 | + ) | ||
335 | + ), | ||
336 | + t_task_ignore as ( | ||
321 | select task_ignore.id ,task_ignore.task_id | 337 | select task_ignore.id ,task_ignore.task_id |
322 | from task_ignore | 338 | from task_ignore |
323 | where user_id = ? | 339 | where user_id = ? |
@@ -349,11 +365,27 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ | @@ -349,11 +365,27 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ | ||
349 | where t_task_ignore.id isnull and task.deleted_at isnull | 365 | where t_task_ignore.id isnull and task.deleted_at isnull |
350 | and task_anomaly.company_id = ? | 366 | and task_anomaly.company_id = ? |
351 | and task.related_user@> ? | 367 | and task.related_user@> ? |
352 | - and task.leader->>'id' <> ? | 368 | + and task.leader->>'id' not in (select id::text from t_user where t_user."level" <3) |
353 | and task_anomaly.is_last=1 | 369 | and task_anomaly.is_last=1 |
354 | ` | 370 | ` |
355 | 371 | ||
356 | - sqlStr2 := ` with t_task_ignore as ( | 372 | + sqlStr2 := ` with |
373 | + recursive t_user as ( | ||
374 | + ( | ||
375 | + select "user".id,"user".parent_id ,"user".account,"user".name, 1 as "level" | ||
376 | + from "user" | ||
377 | + where "user".id=? and "user".deleted_at isnull | ||
378 | + ) | ||
379 | + union | ||
380 | + ( | ||
381 | + select "child_user".id,"child_user".parent_id,"child_user".account,"child_user".name, | ||
382 | + "parent_user"."level"+1 as "level" | ||
383 | + from "user" as "child_user" | ||
384 | + join t_user as "parent_user" on "parent_user".id="child_user".parent_id | ||
385 | + where "child_user".deleted_at isnull | ||
386 | + ) | ||
387 | + ), | ||
388 | + t_task_ignore as ( | ||
357 | select task_ignore.id ,task_ignore.task_id | 389 | select task_ignore.id ,task_ignore.task_id |
358 | from task_ignore | 390 | from task_ignore |
359 | where user_id = ? | 391 | where user_id = ? |
@@ -364,11 +396,11 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ | @@ -364,11 +396,11 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ | ||
364 | where t_task_ignore.id isnull and task.deleted_at isnull | 396 | where t_task_ignore.id isnull and task.deleted_at isnull |
365 | and task_anomaly.company_id = ? | 397 | and task_anomaly.company_id = ? |
366 | and task.related_user@> ? | 398 | and task.related_user@> ? |
367 | - and task.leader->>'id' <> ? | 399 | + and task.leader->>'id' not in (select id::text from t_user where t_user."level" <3) |
368 | and task_anomaly.is_last=1 | 400 | and task_anomaly.is_last=1 |
369 | ` | 401 | ` |
370 | 402 | ||
371 | - condition := []interface{}{userId, companyId, fmt.Sprintf("[%d]", userId), strconv.Itoa(userId)} | 403 | + condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId), strconv.Itoa(userId)} |
372 | if len(dayTime) > 0 { | 404 | if len(dayTime) > 0 { |
373 | condition = append(condition, dayTime) | 405 | condition = append(condition, dayTime) |
374 | sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` | 406 | sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` |
-
请 注册 或 登录 后发表评论