正在显示
9 个修改的文件
包含
171 行增加
和
18 行删除
@@ -36,15 +36,17 @@ type SearchTaskCommand struct { | @@ -36,15 +36,17 @@ type SearchTaskCommand struct { | ||
36 | //是否过滤待发布状态任务 | 36 | //是否过滤待发布状态任务 |
37 | IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"` | 37 | IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"` |
38 | //按创建任务时间排序(ASC,DESC) | 38 | //按创建任务时间排序(ASC,DESC) |
39 | - SortByCreateTime int `json:"sortByCreateTime,omitempty"` | 39 | + SortByCreateTime string `json:"sortByCreateTime,omitempty"` |
40 | //按发布任务时间排序(ASC,DESC) | 40 | //按发布任务时间排序(ASC,DESC) |
41 | - SortByReleaseTime int `json:"sortByReleaseTime,omitempty"` | 41 | + SortByReleaseTime string `json:"sortByReleaseTime,omitempty"` |
42 | //按领取任务时间排序(ASC,DESC) | 42 | //按领取任务时间排序(ASC,DESC) |
43 | - SortByReceiveTime int `json:"sortByReceiveTime,omitempty"` | 43 | + SortByReceiveTime string `json:"sortByReceiveTime,omitempty"` |
44 | //按完成任务操作时间排序(ASC,DESC) | 44 | //按完成任务操作时间排序(ASC,DESC) |
45 | - SortByCompleteTime int `json:"sortByCompleteTime,omitempty"` | 45 | + SortByCompleteTime string `json:"sortByCompleteTime,omitempty"` |
46 | //按验收方验收时间排序(ASC,DESC) | 46 | //按验收方验收时间排序(ASC,DESC) |
47 | - SortByAcceptanceTime int `json:"sortByAcceptanceTime,omitempty"` | 47 | + SortByAcceptanceTime string `json:"sortByAcceptanceTime,omitempty"` |
48 | + //按参与竞标时间排序(ASC,DESC) | ||
49 | + SortByBidTime string `json:"sortByBidTime,omitempty"` | ||
48 | // 查询偏离量 | 50 | // 查询偏离量 |
49 | Offset int `json:"offset,omitempty"` | 51 | Offset int `json:"offset,omitempty"` |
50 | // 查询限制 | 52 | // 查询限制 |
@@ -38,15 +38,17 @@ type ListTaskQuery struct { | @@ -38,15 +38,17 @@ type ListTaskQuery struct { | ||
38 | //是否过滤待发布状态任务 | 38 | //是否过滤待发布状态任务 |
39 | IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"` | 39 | IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"` |
40 | //按创建任务时间排序(ASC,DESC) | 40 | //按创建任务时间排序(ASC,DESC) |
41 | - SortByCreateTime int `json:"sortByCreateTime,omitempty"` | 41 | + SortByCreateTime string `json:"sortByCreateTime,omitempty"` |
42 | //按发布任务时间排序(ASC,DESC) | 42 | //按发布任务时间排序(ASC,DESC) |
43 | - SortByReleaseTime int `json:"sortByReleaseTime,omitempty"` | 43 | + SortByReleaseTime string `json:"sortByReleaseTime,omitempty"` |
44 | //按领取任务时间排序(ASC,DESC) | 44 | //按领取任务时间排序(ASC,DESC) |
45 | - SortByReceiveTime int `json:"sortByReceiveTime,omitempty"` | 45 | + SortByReceiveTime string `json:"sortByReceiveTime,omitempty"` |
46 | //按完成任务操作时间排序(ASC,DESC) | 46 | //按完成任务操作时间排序(ASC,DESC) |
47 | - SortByCompleteTime int `json:"sortByCompleteTime,omitempty"` | 47 | + SortByCompleteTime string `json:"sortByCompleteTime,omitempty"` |
48 | //按验收方验收时间排序(ASC,DESC) | 48 | //按验收方验收时间排序(ASC,DESC) |
49 | - SortByAcceptanceTime int `json:"sortByAcceptanceTime,omitempty"` | 49 | + SortByAcceptanceTime string `json:"sortByAcceptanceTime,omitempty"` |
50 | + //按参与竞标时间排序(ASC,DESC) | ||
51 | + SortByBidTime string `json:"sortByBidTime,omitempty"` | ||
50 | // 查询偏离量 | 52 | // 查询偏离量 |
51 | Offset int `json:"offset,omitempty"` | 53 | Offset int `json:"offset,omitempty"` |
52 | // 查询限制 | 54 | // 查询限制 |
@@ -470,6 +470,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -470,6 +470,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
470 | } | 470 | } |
471 | queryOptions := make(map[string]interface{}) | 471 | queryOptions := make(map[string]interface{}) |
472 | queryOptions["referenceResourceIds"] = referenceResourceIds | 472 | queryOptions["referenceResourceIds"] = referenceResourceIds |
473 | + queryOptions["isFilterCloseStatus"] = true | ||
474 | + queryOptions["isFilterUnReleasedStatus"] = true | ||
473 | if count, _, err := taskRepository.Find(queryOptions); err != nil { | 475 | if count, _, err := taskRepository.Find(queryOptions); err != nil { |
474 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 476 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
475 | } else { | 477 | } else { |
@@ -575,6 +577,8 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -575,6 +577,8 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
575 | } | 577 | } |
576 | queryOptions := make(map[string]interface{}) | 578 | queryOptions := make(map[string]interface{}) |
577 | queryOptions["referenceResourceIds"] = referenceResourceIds | 579 | queryOptions["referenceResourceIds"] = referenceResourceIds |
580 | + queryOptions["isFilterCloseStatus"] = true | ||
581 | + queryOptions["isFilterUnReleasedStatus"] = true | ||
578 | if count, tasks, err := taskRepository.Find(queryOptions); err != nil { | 582 | if count, tasks, err := taskRepository.Find(queryOptions); err != nil { |
579 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 583 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
580 | } else { | 584 | } else { |
@@ -360,13 +360,11 @@ func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd | @@ -360,13 +360,11 @@ func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidd | ||
360 | } | 360 | } |
361 | 361 | ||
362 | func (status *CompletedStatus) ApplyComplete(task *Task) error { | 362 | func (status *CompletedStatus) ApplyComplete(task *Task) error { |
363 | - return fmt.Errorf("已完成的任务不允许申请完成任务") | 363 | + return fmt.Errorf("已完成的任务不允许关闭") |
364 | } | 364 | } |
365 | 365 | ||
366 | func (status *CompletedStatus) Off(task *Task) error { | 366 | func (status *CompletedStatus) Off(task *Task) error { |
367 | - task.TaskStatus = TASK_STATUS_CLOSED | ||
368 | - task.CurrentStatus = &ClosedStatus{} | ||
369 | - return nil | 367 | + return fmt.Errorf("已完成的任务不允许申请完成任务") |
370 | } | 368 | } |
371 | 369 | ||
372 | func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { | 370 | func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string) error { |
@@ -2,6 +2,7 @@ package domain_service | @@ -2,6 +2,7 @@ package domain_service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
@@ -49,6 +50,28 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do | @@ -49,6 +50,28 @@ func (service *ReleaseTaskService) Release(taskId int64, operatorUid int64) (*do | ||
49 | if operator.EmployeeInfo.Uid != task.Sponsor.Uid { | 50 | if operator.EmployeeInfo.Uid != task.Sponsor.Uid { |
50 | return nil, fmt.Errorf("无效的发布者") | 51 | return nil, fmt.Errorf("无效的发布者") |
51 | } | 52 | } |
53 | + if task.ReferenceResource != nil && len(task.ReferenceResource.ReferenceResourceItems) > 0 { | ||
54 | + var referenceResourceIds []int64 | ||
55 | + for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems { | ||
56 | + referenceResourceIds = append(referenceResourceIds, referenceResourceItem.ReferenceResourceId) | ||
57 | + } | ||
58 | + queryOptions := make(map[string]interface{}) | ||
59 | + queryOptions["referenceResourceIds"] = referenceResourceIds | ||
60 | + queryOptions["isFilterCloseStatus"] = true | ||
61 | + queryOptions["isFilterUnReleasedStatus"] = true | ||
62 | + if count, tasks, err := taskRepository.Find(queryOptions); err != nil { | ||
63 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
64 | + } else { | ||
65 | + if count > 1 { | ||
66 | + return nil, fmt.Errorf("问题资源已经被引用,发布任务失败") | ||
67 | + } | ||
68 | + if count == 1 { | ||
69 | + if tasks[0].TaskId != task.TaskId { | ||
70 | + return nil, fmt.Errorf("问题资源已经被引用,发布任务失败") | ||
71 | + } | ||
72 | + } | ||
73 | + } | ||
74 | + } | ||
52 | if err := task.Release(); err != nil { | 75 | if err := task.Release(); err != nil { |
53 | return nil, err | 76 | return nil, err |
54 | } | 77 | } |
@@ -200,6 +200,10 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | @@ -200,6 +200,10 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | ||
200 | query = query.Order(fmt.Sprintf("task.complete_time %s", sortByCompleteTime.(string))) | 200 | query = query.Order(fmt.Sprintf("task.complete_time %s", sortByCompleteTime.(string))) |
201 | } else if sortByAcceptanceTime, ok := queryOptions["sortByAcceptanceTime"]; ok && (sortByAcceptanceTime == "ASC" || sortByAcceptanceTime == "DESC") { | 201 | } else if sortByAcceptanceTime, ok := queryOptions["sortByAcceptanceTime"]; ok && (sortByAcceptanceTime == "ASC" || sortByAcceptanceTime == "DESC") { |
202 | query = query.Order(fmt.Sprintf("task.acceptance_time %s", sortByAcceptanceTime.(string))) | 202 | query = query.Order(fmt.Sprintf("task.acceptance_time %s", sortByAcceptanceTime.(string))) |
203 | + } else if sortByBidTime, ok := queryOptions["sortByBidTime"]; ok && (sortByBidTime == "ASC" || sortByBidTime == "DESC") { | ||
204 | + if bidder, ok := queryOptions["bidder"]; ok && (bidder != int64(0)) { | ||
205 | + query = query.Order(fmt.Sprintf("bidder_info.bid_time %s", sortByBidTime.(string))) | ||
206 | + } | ||
203 | } else { | 207 | } else { |
204 | query = query.Order("task.id DESC") | 208 | query = query.Order("task.id DESC") |
205 | } | 209 | } |
@@ -24,7 +24,7 @@ var _ = Describe("创建新任务", func() { | @@ -24,7 +24,7 @@ var _ = Describe("创建新任务", func() { | ||
24 | "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, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | 24 | "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, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
25 | 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{ | 25 | 2, 101, "抢单任务2", 1, &domain.EmployeeInfo{ |
26 | Uid: 2499036607974745088, | 26 | Uid: 2499036607974745088, |
27 | - }, 1, &domain.ReferenceResource{ | 27 | + }, 2, &domain.ReferenceResource{ |
28 | ReferenceResourceType: 1, | 28 | ReferenceResourceType: 1, |
29 | ReferenceResourceItems: []*domain.ReferenceResourceItem{ | 29 | ReferenceResourceItems: []*domain.ReferenceResourceItem{ |
30 | { | 30 | { |
@@ -21,7 +21,14 @@ var _ = Describe("发布任务", func() { | @@ -21,7 +21,14 @@ var _ = Describe("发布任务", func() { | ||
21 | "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | 21 | "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
22 | 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ | 22 | 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ |
23 | Uid: 2499036607974745088, | 23 | Uid: 2499036607974745088, |
24 | - }, 1, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | 24 | + }, 1, &domain.ReferenceResource{ |
25 | + ReferenceResourceType: 1, | ||
26 | + ReferenceResourceItems: []*domain.ReferenceResourceItem{ | ||
27 | + { | ||
28 | + ReferenceResourceId: 4, | ||
29 | + }, | ||
30 | + }, | ||
31 | + }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | ||
25 | { | 32 | { |
26 | Uid: 2499036607974745077, | 33 | Uid: 2499036607974745077, |
27 | }, | 34 | }, |
@@ -59,7 +66,7 @@ var _ = Describe("发布任务", func() { | @@ -59,7 +66,7 @@ var _ = Describe("发布任务", func() { | ||
59 | _, err := pG.DB.QueryOne( | 66 | _, err := pG.DB.QueryOne( |
60 | pg.Scan(), | 67 | pg.Scan(), |
61 | "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | 68 | "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
62 | - 1, 101, "抢单任务1",1, &domain.EmployeeInfo{ | 69 | + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ |
63 | Uid: 2499036607974745088, | 70 | Uid: 2499036607974745088, |
64 | }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | 71 | }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ |
65 | { | 72 | { |
@@ -91,6 +98,72 @@ var _ = Describe("发布任务", func() { | @@ -91,6 +98,72 @@ var _ = Describe("发布任务", func() { | ||
91 | ContainsKey("msg").ValueEqual("msg", "内部服务出错:进行中的任务不允许重新发布") | 98 | ContainsKey("msg").ValueEqual("msg", "内部服务出错:进行中的任务不允许重新发布") |
92 | }) | 99 | }) |
93 | }) | 100 | }) |
101 | + Context("发布资源已经被引用的的任务", func() { | ||
102 | + BeforeEach(func() { | ||
103 | + dayAfter, _ := time.ParseDuration("72h") | ||
104 | + _, err := pG.DB.QueryOne( | ||
105 | + pg.Scan(), | ||
106 | + "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
107 | + 1, 101, "抢单任务1", 1, &domain.EmployeeInfo{ | ||
108 | + Uid: 2499036607974745088, | ||
109 | + }, 2, &domain.ReferenceResource{ | ||
110 | + ReferenceResourceType: 1, | ||
111 | + ReferenceResourceItems: []*domain.ReferenceResourceItem{ | ||
112 | + { | ||
113 | + ReferenceResourceId: 4, | ||
114 | + }, | ||
115 | + }, | ||
116 | + }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | ||
117 | + { | ||
118 | + Uid: 2499036607974745077, | ||
119 | + }, | ||
120 | + { | ||
121 | + Uid: 2499036607974745066, | ||
122 | + }, | ||
123 | + }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter)) | ||
124 | + Expect(err).NotTo(HaveOccurred()) | ||
125 | + _, err1 := pG.DB.QueryOne( | ||
126 | + pg.Scan(), | ||
127 | + "INSERT INTO employees (id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?)", | ||
128 | + 1, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0) | ||
129 | + Expect(err1).NotTo(HaveOccurred()) | ||
130 | + _, err2 := pG.DB.QueryOne( | ||
131 | + pg.Scan(), | ||
132 | + "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
133 | + 2, 101, "抢单任务1", 1, &domain.EmployeeInfo{ | ||
134 | + Uid: 2499036607974745088, | ||
135 | + }, 2, &domain.ReferenceResource{ | ||
136 | + ReferenceResourceType: 1, | ||
137 | + ReferenceResourceItems: []*domain.ReferenceResourceItem{ | ||
138 | + { | ||
139 | + ReferenceResourceId: 4, | ||
140 | + }, | ||
141 | + }, | ||
142 | + }, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | ||
143 | + { | ||
144 | + Uid: 2499036607974745077, | ||
145 | + }, | ||
146 | + { | ||
147 | + Uid: 2499036607974745066, | ||
148 | + }, | ||
149 | + }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter)) | ||
150 | + Expect(err2).NotTo(HaveOccurred()) | ||
151 | + }) | ||
152 | + It("发布任务失败", func() { | ||
153 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
154 | + body := map[string]interface{}{ | ||
155 | + "operator": 2499036607974745088, | ||
156 | + } | ||
157 | + httpExpect.POST("/tasks/1/release"). | ||
158 | + WithJSON(body). | ||
159 | + Expect(). | ||
160 | + Status(http.StatusOK). | ||
161 | + JSON(). | ||
162 | + Object(). | ||
163 | + ContainsKey("code").ValueEqual("code", 501). | ||
164 | + ContainsKey("msg").ValueEqual("msg", "内部服务出错:问题资源已经被引用,发布任务失败") | ||
165 | + }) | ||
166 | + }) | ||
94 | }) | 167 | }) |
95 | AfterEach(func() { | 168 | AfterEach(func() { |
96 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") | 169 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") |
@@ -46,8 +46,34 @@ var _ = Describe("搜索任务", func() { | @@ -46,8 +46,34 @@ var _ = Describe("搜索任务", func() { | ||
46 | _, err3 := pG.DB.QueryOne( | 46 | _, err3 := pG.DB.QueryOne( |
47 | pg.Scan(), | 47 | pg.Scan(), |
48 | "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)", | 48 | "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)", |
49 | - 1, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Now().Add(dayAfter)) | 49 | + 3, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Now().Add(dayAfter)) |
50 | Expect(err3).NotTo(HaveOccurred()) | 50 | Expect(err3).NotTo(HaveOccurred()) |
51 | + _, err4 := pG.DB.QueryOne( | ||
52 | + pg.Scan(), | ||
53 | + "INSERT INTO bidder_infos (id, bid_info_id, bidder, bid_time, task_id) VALUES (?, ?, ?, ?, ?)", | ||
54 | + 1, 1, &domain.EmployeeInfo{ | ||
55 | + Uid: 2499036607974745088, | ||
56 | + }, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), 3) | ||
57 | + Expect(err4).NotTo(HaveOccurred()) | ||
58 | + _, err5 := pG.DB.QueryOne( | ||
59 | + pg.Scan(), | ||
60 | + "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, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
61 | + 4, 101, "竞标任务1", 2, &domain.EmployeeInfo{ | ||
62 | + Uid: 2499036607974745088, | ||
63 | + }, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter)) | ||
64 | + Expect(err5).NotTo(HaveOccurred()) | ||
65 | + _, err6 := pG.DB.QueryOne( | ||
66 | + pg.Scan(), | ||
67 | + "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)", | ||
68 | + 4, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Now().Add(dayAfter)) | ||
69 | + Expect(err6).NotTo(HaveOccurred()) | ||
70 | + _, err7 := pG.DB.QueryOne( | ||
71 | + pg.Scan(), | ||
72 | + "INSERT INTO bidder_infos (id, bid_info_id, bidder, bid_time, task_id) VALUES (?, ?, ?, ?, ?)", | ||
73 | + 2, 1, &domain.EmployeeInfo{ | ||
74 | + Uid: 2499036607974745088, | ||
75 | + }, time.Date(2020, time.Month(5), 5, 8, 0, 0, 0, time.Now().Location()), 4) | ||
76 | + Expect(err7).NotTo(HaveOccurred()) | ||
51 | }) | 77 | }) |
52 | Describe("搜索任务", func() { | 78 | Describe("搜索任务", func() { |
53 | Context("", func() { | 79 | Context("", func() { |
@@ -117,6 +143,27 @@ var _ = Describe("搜索任务", func() { | @@ -117,6 +143,27 @@ var _ = Describe("搜索任务", func() { | ||
117 | ContainsKey("data").Value("data").Object() | 143 | ContainsKey("data").Value("data").Object() |
118 | }) | 144 | }) |
119 | }) | 145 | }) |
146 | + Context("", func() { | ||
147 | + It("", func() { | ||
148 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
149 | + body := map[string]interface{}{ | ||
150 | + "companyId": 101, | ||
151 | + "bidder": 2499036607974745088, | ||
152 | + "sortByBidTime": "ASC", | ||
153 | + "offset": 0, | ||
154 | + "limit": 20, | ||
155 | + } | ||
156 | + httpExpect.POST("/tasks/search"). | ||
157 | + WithJSON(body). | ||
158 | + Expect(). | ||
159 | + Status(http.StatusOK). | ||
160 | + JSON(). | ||
161 | + Object(). | ||
162 | + ContainsKey("code").ValueEqual("code", 0). | ||
163 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
164 | + ContainsKey("data").Value("data").Object() | ||
165 | + }) | ||
166 | + }) | ||
120 | }) | 167 | }) |
121 | AfterEach(func() { | 168 | AfterEach(func() { |
122 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") | 169 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") |
-
请 注册 或 登录 后发表评论