作者 linmadan

添加任务过滤条件

... ... @@ -29,6 +29,8 @@ type SearchTaskCommand struct {
Receiver int64 `json:"receiver,omitempty"`
// 任务参与者
Participator int64 `json:"participator,omitempty"`
//是否过滤关闭状态任务
IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -31,6 +31,8 @@ type ListTaskQuery struct {
Receiver int64 `json:"receiver,omitempty"`
// 任务参与者
Participator int64 `json:"participator,omitempty"`
//是否过滤关闭状态任务
IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -99,6 +99,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("task.company_id = ?", companyId)
}
if isFilterCloseStatus, ok := queryOptions["isFilterCloseStatus"]; ok && isFilterCloseStatus.(bool) != false {
query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_CLOSED)
}
if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) {
query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor)
}
... ...
... ... @@ -240,6 +240,8 @@ func (controller *TaskController) ListTask() {
listTaskQuery.Receiver = receiver
participator, _ := controller.GetInt64("participator")
listTaskQuery.Participator = participator
isFilterCloseStatus, _ := controller.GetBool("isFilterCloseStatus")
listTaskQuery.IsFilterCloseStatus = isFilterCloseStatus
offset, _ := controller.GetInt("offset")
listTaskQuery.Offset = offset
limit, _ := controller.GetInt("limit")
... ...
... ... @@ -49,6 +49,20 @@ var _ = Describe("返回任务列表", func() {
Uid: 2499036607974745099,
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
Expect(err3).NotTo(HaveOccurred())
_, err4 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
5, 303, "抢单任务1", 1, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
{
Uid: 2499036607974745077,
},
{
Uid: 2499036607974745066,
},
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
Expect(err4).NotTo(HaveOccurred())
Expect(err1).NotTo(HaveOccurred())
_, err11 := pG.DB.QueryOne(
pg.Scan(),
... ... @@ -205,6 +219,23 @@ var _ = Describe("返回任务列表", func() {
ContainsKey("count").ValueEqual("count", 1).
ContainsKey("tasks").Value("tasks").Array()
})
It("返回过滤关闭状态的任务数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/tasks/").
WithQuery("companyId", 303).
WithQuery("isFilterCloseStatus", true).
WithQuery("offset", 0).
WithQuery("limit", 20).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("count").ValueEqual("count", 0).
ContainsKey("tasks").Value("tasks").Array()
})
})
})
AfterEach(func() {
... ...