正在显示
2 个修改的文件
包含
34 行增加
和
3 行删除
@@ -66,8 +66,12 @@ func (repository *OffTaskRecordRepository) Find(queryOptions map[string]interfac | @@ -66,8 +66,12 @@ func (repository *OffTaskRecordRepository) Find(queryOptions map[string]interfac | ||
66 | var offTaskRecordModels []*models.OffTaskRecord | 66 | var offTaskRecordModels []*models.OffTaskRecord |
67 | offTaskRecords := make([]*domain.OffTaskRecord, 0) | 67 | offTaskRecords := make([]*domain.OffTaskRecord, 0) |
68 | query := tx.Model(&offTaskRecordModels) | 68 | query := tx.Model(&offTaskRecordModels) |
69 | - if taskIds, ok := queryOptions["taskIds"]; ok && len(taskIds.([]int64)) > 0 { | ||
70 | - query = query.Where(`off_task_record.task_id IN (?)`, pg.In(taskIds.([]int64))) | 69 | + if taskIds, ok := queryOptions["taskIds"]; ok { |
70 | + if len(taskIds.([]int64)) > 0{ | ||
71 | + query = query.Where(`off_task_record.task_id IN (?)`, pg.In(taskIds.([]int64))) | ||
72 | + }else { | ||
73 | + return int64(0), offTaskRecords, nil | ||
74 | + } | ||
71 | } | 75 | } |
72 | if offStartTime, ok := queryOptions["offStartTime"]; ok && !offStartTime.(time.Time).IsZero() { | 76 | if offStartTime, ok := queryOptions["offStartTime"]; ok && !offStartTime.(time.Time).IsZero() { |
73 | query = query.Where(`off_task_record.create_time > ?`, offStartTime) | 77 | query = query.Where(`off_task_record.create_time > ?`, offStartTime) |
@@ -61,7 +61,34 @@ var _ = Describe("搜索关闭任务记录", func() { | @@ -61,7 +61,34 @@ var _ = Describe("搜索关闭任务记录", func() { | ||
61 | Object(). | 61 | Object(). |
62 | ContainsKey("code").ValueEqual("code", 0). | 62 | ContainsKey("code").ValueEqual("code", 0). |
63 | ContainsKey("msg").ValueEqual("msg", "ok"). | 63 | ContainsKey("msg").ValueEqual("msg", "ok"). |
64 | - ContainsKey("data").Value("data").Object() | 64 | + ContainsKey("data").Value("data").Object(). |
65 | + ContainsKey("count").ValueEqual("count", 1) | ||
66 | + }) | ||
67 | + }) | ||
68 | + Context("", func() { | ||
69 | + It("", func() { | ||
70 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
71 | + body := map[string]interface{}{ | ||
72 | + "companyId": 102, | ||
73 | + "taskContentMatch": "", | ||
74 | + "taskType": 1, | ||
75 | + "customerValue": "", | ||
76 | + "taskNature": "", | ||
77 | + "offStartTime": time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), | ||
78 | + "offEndTime": time.Time{}, | ||
79 | + "offset": 0, | ||
80 | + "limit": 20, | ||
81 | + } | ||
82 | + httpExpect.POST("/off-task-records/search-off-task-record"). | ||
83 | + WithJSON(body). | ||
84 | + Expect(). | ||
85 | + Status(http.StatusOK). | ||
86 | + JSON(). | ||
87 | + Object(). | ||
88 | + ContainsKey("code").ValueEqual("code", 0). | ||
89 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
90 | + ContainsKey("data").Value("data").Object(). | ||
91 | + ContainsKey("count").ValueEqual("count", 0) | ||
65 | }) | 92 | }) |
66 | }) | 93 | }) |
67 | }) | 94 | }) |
-
请 注册 或 登录 后发表评论