作者 tangxvhui

调整参数类型

package command
type ListTaskAnomalyCommand struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserId int `json:"-"`
CompanyId int `json:"-"`
TaskName string `json:"taskName"`
DayTime string `json:"dayTime"` //发生异常的日期
Category int `json:"category"` //异常分类
LeaderId string `json:"leaderId"` //任务负责人id
SubLevel int `json:"subLevel"` //userId 的下级 ,向下查询多少级
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserId int `json:"-"`
CompanyId int `json:"-"`
TaskName string `json:"taskName"`
DayTime string `json:"dayTime"` //发生异常的日期
Category int `json:"category"` //异常分类
LeaderId []string `json:"leaderId"` //任务负责人id
SubLevel int `json:"subLevel"` //userId 的下级 ,向下查询多少级
}
... ...
... ... @@ -36,10 +36,7 @@ func (srv TaskService) listTaskAnomaly2(param *command.ListTaskAnomalyCommand) (
})
limit := 500
offset := 0
// if param.SubLevel < 1 {
// param.SubLevel = 2
// }
cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, param.SubLevel, limit, offset)
cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.LeaderId, param.DayTime, param.SubLevel, limit, offset)
if err != nil {
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -139,7 +139,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ
// pageSize 分页大小
// pageNumber 分页页码
// subLevel 我的下级的层级
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) {
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) {
sqlStr1 := `with
-- 人员自身以及全下级
recursive t_user as (
... ... @@ -232,6 +232,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
task.end_time as "task_end_time",
task.sort_by as "task_sort_by",
task.leader->>'name' as "leader_name",
task.leader ->>'id' as "leader_id"
task.level_name
from task
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
sqlStr1 += ` and task_anomaly.category=? `
sqlStr2 += ` and task_anomaly.category=? `
}
if len(leaderId) > 0 {
condition = append(condition, pg.In(leaderId))
sqlStr2 += ` and t_task.leader_id in (?) `
sqlStr1 += ` and t_task.leader_id in (?) `
}
condition = append(condition, limit, offset)
sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? `
... ... @@ -281,7 +287,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
// dayTime 搜索条件日期 ,例:"2006-01-02"
// pageSize 分页大小
// pageNumber 分页页码
func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId string, limit int, offset int) (int, []ListTaskAnomaly, error) {
func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId []string, limit int, offset int) (int, []ListTaskAnomaly, error) {
sqlStr1 := ` with t_task_ignore as (
select task_ignore.id ,task_ignore.task_id
from task_ignore
... ... @@ -345,9 +351,9 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
}
if len(leaderId) > 0 {
condition = append(condition, fmt.Sprintf(`{"id":"%s"}`, leaderId))
sqlStr1 += ` and task.leader@>? `
sqlStr2 += ` and task.leader@>? `
condition = append(condition, pg.In(leaderId))
sqlStr1 += ` and task.leader->>'id' in (?) `
sqlStr2 += ` and task.leader->>'id' in (?) `
}
condition = append(condition, limit, offset)
sqlStr1 += ` order by task_anomaly.id desc limit ? offset ? `
... ...