作者 linmadan

添加任务过滤条件

@@ -29,6 +29,8 @@ type SearchTaskCommand struct { @@ -29,6 +29,8 @@ type SearchTaskCommand struct {
29 Receiver int64 `json:"receiver,omitempty"` 29 Receiver int64 `json:"receiver,omitempty"`
30 // 任务参与者 30 // 任务参与者
31 Participator int64 `json:"participator,omitempty"` 31 Participator int64 `json:"participator,omitempty"`
  32 + //是否过滤关闭状态任务
  33 + IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
32 // 查询偏离量 34 // 查询偏离量
33 Offset int `json:"offset,omitempty"` 35 Offset int `json:"offset,omitempty"`
34 // 查询限制 36 // 查询限制
@@ -31,6 +31,8 @@ type ListTaskQuery struct { @@ -31,6 +31,8 @@ type ListTaskQuery struct {
31 Receiver int64 `json:"receiver,omitempty"` 31 Receiver int64 `json:"receiver,omitempty"`
32 // 任务参与者 32 // 任务参与者
33 Participator int64 `json:"participator,omitempty"` 33 Participator int64 `json:"participator,omitempty"`
  34 + //是否过滤关闭状态任务
  35 + IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
34 // 查询偏离量 36 // 查询偏离量
35 Offset int `json:"offset,omitempty"` 37 Offset int `json:"offset,omitempty"`
36 // 查询限制 38 // 查询限制
@@ -99,6 +99,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int @@ -99,6 +99,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
99 if companyId, ok := queryOptions["companyId"]; ok { 99 if companyId, ok := queryOptions["companyId"]; ok {
100 query = query.Where("task.company_id = ?", companyId) 100 query = query.Where("task.company_id = ?", companyId)
101 } 101 }
  102 + if isFilterCloseStatus, ok := queryOptions["isFilterCloseStatus"]; ok && isFilterCloseStatus.(bool) != false {
  103 + query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_CLOSED)
  104 + }
102 if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) { 105 if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) {
103 query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor) 106 query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor)
104 } 107 }
@@ -240,6 +240,8 @@ func (controller *TaskController) ListTask() { @@ -240,6 +240,8 @@ func (controller *TaskController) ListTask() {
240 listTaskQuery.Receiver = receiver 240 listTaskQuery.Receiver = receiver
241 participator, _ := controller.GetInt64("participator") 241 participator, _ := controller.GetInt64("participator")
242 listTaskQuery.Participator = participator 242 listTaskQuery.Participator = participator
  243 + isFilterCloseStatus, _ := controller.GetBool("isFilterCloseStatus")
  244 + listTaskQuery.IsFilterCloseStatus = isFilterCloseStatus
243 offset, _ := controller.GetInt("offset") 245 offset, _ := controller.GetInt("offset")
244 listTaskQuery.Offset = offset 246 listTaskQuery.Offset = offset
245 limit, _ := controller.GetInt("limit") 247 limit, _ := controller.GetInt("limit")
@@ -49,6 +49,20 @@ var _ = Describe("返回任务列表", func() { @@ -49,6 +49,20 @@ var _ = Describe("返回任务列表", func() {
49 Uid: 2499036607974745099, 49 Uid: 2499036607974745099,
50 }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) 50 }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), false, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
51 Expect(err3).NotTo(HaveOccurred()) 51 Expect(err3).NotTo(HaveOccurred())
  52 + _, err4 := pG.DB.QueryOne(
  53 + pg.Scan(),
  54 + "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
  55 + 5, 303, "抢单任务1", 1, &domain.EmployeeInfo{
  56 + Uid: 2499036607974745088,
  57 + }, 6, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
  58 + {
  59 + Uid: 2499036607974745077,
  60 + },
  61 + {
  62 + Uid: 2499036607974745066,
  63 + },
  64 + }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
  65 + Expect(err4).NotTo(HaveOccurred())
52 Expect(err1).NotTo(HaveOccurred()) 66 Expect(err1).NotTo(HaveOccurred())
53 _, err11 := pG.DB.QueryOne( 67 _, err11 := pG.DB.QueryOne(
54 pg.Scan(), 68 pg.Scan(),
@@ -205,6 +219,23 @@ var _ = Describe("返回任务列表", func() { @@ -205,6 +219,23 @@ var _ = Describe("返回任务列表", func() {
205 ContainsKey("count").ValueEqual("count", 1). 219 ContainsKey("count").ValueEqual("count", 1).
206 ContainsKey("tasks").Value("tasks").Array() 220 ContainsKey("tasks").Value("tasks").Array()
207 }) 221 })
  222 + It("返回过滤关闭状态的任务数据列表", func() {
  223 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  224 + httpExpect.GET("/tasks/").
  225 + WithQuery("companyId", 303).
  226 + WithQuery("isFilterCloseStatus", true).
  227 + WithQuery("offset", 0).
  228 + WithQuery("limit", 20).
  229 + Expect().
  230 + Status(http.StatusOK).
  231 + JSON().
  232 + Object().
  233 + ContainsKey("code").ValueEqual("code", 0).
  234 + ContainsKey("msg").ValueEqual("msg", "ok").
  235 + ContainsKey("data").Value("data").Object().
  236 + ContainsKey("count").ValueEqual("count", 0).
  237 + ContainsKey("tasks").Value("tasks").Array()
  238 + })
208 }) 239 })
209 }) 240 })
210 AfterEach(func() { 241 AfterEach(func() {