正在显示
9 个修改的文件
包含
187 行增加
和
27 行删除
@@ -29,3 +29,11 @@ func CreateRobTaskService(options map[string]interface{}) (service.RobTaskServic | @@ -29,3 +29,11 @@ func CreateRobTaskService(options map[string]interface{}) (service.RobTaskServic | ||
29 | } | 29 | } |
30 | return domainService.NewRobTaskService(transactionContext) | 30 | return domainService.NewRobTaskService(transactionContext) |
31 | } | 31 | } |
32 | + | ||
33 | +func CreateBidTaskService(options map[string]interface{}) (service.BidTaskService, error) { | ||
34 | + var transactionContext *pgTransaction.TransactionContext | ||
35 | + if value, ok := options["transactionContext"]; ok { | ||
36 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
37 | + } | ||
38 | + return domainService.NewBidTaskService(transactionContext) | ||
39 | +} |
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query" | 9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/task/query" |
10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" | 11 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" |
12 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
12 | ) | 13 | ) |
13 | 14 | ||
14 | // 任务服务 | 15 | // 任务服务 |
@@ -63,10 +64,22 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | @@ -63,10 +64,22 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | ||
63 | defer func() { | 64 | defer func() { |
64 | transactionContext.RollbackTransaction() | 65 | transactionContext.RollbackTransaction() |
65 | }() | 66 | }() |
67 | + var bidTaskService service.BidTaskService | ||
68 | + if value, err := factory.CreateBidTaskService(map[string]interface{}{ | ||
69 | + "transactionContext": transactionContext, | ||
70 | + }); err != nil { | ||
71 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
72 | + } else { | ||
73 | + bidTaskService = value | ||
74 | + } | ||
75 | + if task, err := bidTaskService.Bid(bidTaskCommand.TaskId, bidTaskCommand.Bidder); err != nil { | ||
76 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
77 | + } else { | ||
66 | if err := transactionContext.CommitTransaction(); err != nil { | 78 | if err := transactionContext.CommitTransaction(); err != nil { |
67 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 79 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
68 | } | 80 | } |
69 | - return nil, nil | 81 | + return task, nil |
82 | + } | ||
70 | } | 83 | } |
71 | 84 | ||
72 | // 选择竞标任务的中标人 | 85 | // 选择竞标任务的中标人 |
@@ -285,6 +298,14 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -285,6 +298,14 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
285 | defer func() { | 298 | defer func() { |
286 | transactionContext.RollbackTransaction() | 299 | transactionContext.RollbackTransaction() |
287 | }() | 300 | }() |
301 | + var taskDao *dao.TaskDao | ||
302 | + if value, err := factory.CreateTaskDao(map[string]interface{}{ | ||
303 | + "transactionContext": transactionContext, | ||
304 | + }); err != nil { | ||
305 | + return nil, err | ||
306 | + } else { | ||
307 | + taskDao = value | ||
308 | + } | ||
288 | var employeeRepository domain.EmployeeRepository | 309 | var employeeRepository domain.EmployeeRepository |
289 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 310 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
290 | "transactionContext": transactionContext, | 311 | "transactionContext": transactionContext, |
@@ -302,15 +323,6 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -302,15 +323,6 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
302 | if sponsor == nil { | 323 | if sponsor == nil { |
303 | return nil, fmt.Errorf("无效的发布者") | 324 | return nil, fmt.Errorf("无效的发布者") |
304 | } | 325 | } |
305 | - var bidInfo *domain.BidInfo | ||
306 | - if createTaskCommand.TaskType == domain.TASK_TYPE_BID { | ||
307 | - bidInfo = &domain.BidInfo{ | ||
308 | - BidStartTime: createTaskCommand.BidStartTime, | ||
309 | - BidEndTime: createTaskCommand.BidEndTime, | ||
310 | - } | ||
311 | - } else { | ||
312 | - bidInfo = nil | ||
313 | - } | ||
314 | newTask := &domain.Task{ | 326 | newTask := &domain.Task{ |
315 | TaskStatus: domain.TASK_STATUS_UNRELEASED, | 327 | TaskStatus: domain.TASK_STATUS_UNRELEASED, |
316 | CompanyId: createTaskCommand.CompanyId, | 328 | CompanyId: createTaskCommand.CompanyId, |
@@ -328,7 +340,6 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -328,7 +340,6 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
328 | TaskDescription: createTaskCommand.TaskDescription, | 340 | TaskDescription: createTaskCommand.TaskDescription, |
329 | TaskPictureUrls: createTaskCommand.TaskPictureUrls, | 341 | TaskPictureUrls: createTaskCommand.TaskPictureUrls, |
330 | IsRewardTake: createTaskCommand.IsRewardTake, | 342 | IsRewardTake: createTaskCommand.IsRewardTake, |
331 | - BidInfo: bidInfo, | ||
332 | } | 343 | } |
333 | var taskRepository domain.TaskRepository | 344 | var taskRepository domain.TaskRepository |
334 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 345 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
@@ -341,6 +352,11 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -341,6 +352,11 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
341 | if task, err := taskRepository.Save(newTask); err != nil { | 352 | if task, err := taskRepository.Save(newTask); err != nil { |
342 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 353 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
343 | } else { | 354 | } else { |
355 | + if createTaskCommand.TaskType == domain.TASK_TYPE_BID { | ||
356 | + if err := taskDao.AddBidInfo(task.TaskId, createTaskCommand.BidStartTime, createTaskCommand.BidEndTime); err != nil { | ||
357 | + return nil, err | ||
358 | + } | ||
359 | + } | ||
344 | if err := transactionContext.CommitTransaction(); err != nil { | 360 | if err := transactionContext.CommitTransaction(); err != nil { |
345 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 361 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
346 | } | 362 | } |
pkg/domain/service/bid_task.go
0 → 100644
@@ -3,5 +3,5 @@ package service | @@ -3,5 +3,5 @@ package service | ||
3 | import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 3 | import "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
4 | 4 | ||
5 | type RobTaskService interface { | 5 | type RobTaskService interface { |
6 | - Rob(taskId int64, receiverUid int64) (*domain.Task, error) | 6 | + Rob(taskId int64, bidderUid int64) (*domain.Task, error) |
7 | } | 7 | } |
@@ -201,6 +201,8 @@ func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error { | @@ -201,6 +201,8 @@ func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error { | ||
201 | Bidder: bidder, | 201 | Bidder: bidder, |
202 | BidTime: bidTime, | 202 | BidTime: bidTime, |
203 | }) | 203 | }) |
204 | + task.TaskStatus = TASK_STATUS_UNDERWAY | ||
205 | + task.CurrentStatus = &UnderwayStatus{} | ||
204 | return nil | 206 | return nil |
205 | } | 207 | } |
206 | } | 208 | } |
@@ -31,6 +31,15 @@ func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime | @@ -31,6 +31,15 @@ func (dao *TaskDao) AddBidInfo(taskId int64, bidStartTime time.Time, bidEndTime | ||
31 | return err | 31 | return err |
32 | } | 32 | } |
33 | 33 | ||
34 | +func (dao *TaskDao) AddBidderInfo(taskId int64, bidder *domain.EmployeeInfo) error { | ||
35 | + tx := dao.transactionContext.PgTx | ||
36 | + _, err := tx.QueryOne( | ||
37 | + pg.Scan(), | ||
38 | + "INSERT INTO bidder_infos (task_id, bidder, bid_time) VALUES (?, ?, ?)", | ||
39 | + taskId, bidder, time.Now()) | ||
40 | + return err | ||
41 | +} | ||
42 | + | ||
34 | func NewTaskDao(transactionContext *pgTransaction.TransactionContext) (*TaskDao, error) { | 43 | func NewTaskDao(transactionContext *pgTransaction.TransactionContext) (*TaskDao, error) { |
35 | if transactionContext == nil { | 44 | if transactionContext == nil { |
36 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 45 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
1 | +package domain_service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
6 | + 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/infrastructure/dao" | ||
9 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" | ||
10 | +) | ||
11 | + | ||
12 | +type BidTaskService struct { | ||
13 | + coreDomain.BaseEventPublisher | ||
14 | + transactionContext *pgTransaction.TransactionContext | ||
15 | +} | ||
16 | + | ||
17 | +func (service *BidTaskService) Bid(taskId int64, bidderUid int64) (*domain.Task, error) { | ||
18 | + var employeeRepository domain.EmployeeRepository | ||
19 | + var taskRepository domain.TaskRepository | ||
20 | + var taskDao *dao.TaskDao | ||
21 | + if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { | ||
22 | + return nil, err | ||
23 | + } else { | ||
24 | + employeeRepository = repository | ||
25 | + } | ||
26 | + if repository, err := repository.NewTaskRepository(service.transactionContext); err != nil { | ||
27 | + return nil, err | ||
28 | + } else { | ||
29 | + taskRepository = repository | ||
30 | + } | ||
31 | + if dao, err := dao.NewTaskDao(service.transactionContext); err != nil { | ||
32 | + return nil, err | ||
33 | + } else { | ||
34 | + taskDao = dao | ||
35 | + } | ||
36 | + bidder, err := employeeRepository.FindOne(map[string]interface{}{ | ||
37 | + "uid": bidderUid, | ||
38 | + }) | ||
39 | + if err != nil { | ||
40 | + return nil, err | ||
41 | + } | ||
42 | + if bidder == nil { | ||
43 | + return nil, fmt.Errorf("无效的竞标人") | ||
44 | + } | ||
45 | + task, err := taskRepository.FindOne(map[string]interface{}{ | ||
46 | + "taskId": taskId, | ||
47 | + }) | ||
48 | + if err != nil { | ||
49 | + return nil, err | ||
50 | + } | ||
51 | + if task == nil { | ||
52 | + return nil, fmt.Errorf("无效的任务") | ||
53 | + } | ||
54 | + if bidder.EmployeeInfo.Uid == task.Sponsor.Uid { | ||
55 | + return nil, fmt.Errorf("无法竞标自己发布的任务") | ||
56 | + } | ||
57 | + if err := task.Bib(bidder.EmployeeInfo); err != nil { | ||
58 | + return nil, err | ||
59 | + } | ||
60 | + if err := taskDao.AddBidderInfo(taskId, bidder.EmployeeInfo); err != nil { | ||
61 | + return nil, err | ||
62 | + } | ||
63 | + if task, err := taskRepository.Save(task); err != nil { | ||
64 | + return nil, err | ||
65 | + } else { | ||
66 | + return task, nil | ||
67 | + } | ||
68 | +} | ||
69 | + | ||
70 | +func NewBidTaskService(transactionContext *pgTransaction.TransactionContext) (*BidTaskService, error) { | ||
71 | + if transactionContext == nil { | ||
72 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
73 | + } else { | ||
74 | + return &BidTaskService{ | ||
75 | + transactionContext: transactionContext, | ||
76 | + }, nil | ||
77 | + } | ||
78 | +} |
@@ -38,7 +38,7 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error) | @@ -38,7 +38,7 @@ func (repository *TaskRepository) Save(task *domain.Task) (*domain.Task, error) | ||
38 | } | 38 | } |
39 | } else { | 39 | } else { |
40 | var taskReceiverUid int64 | 40 | var taskReceiverUid int64 |
41 | - if task.RobInfo != nil { | 41 | + if task.RobInfo != nil && task.RobInfo.Receiver != nil { |
42 | taskReceiverUid = task.RobInfo.Receiver.Uid | 42 | taskReceiverUid = task.RobInfo.Receiver.Uid |
43 | } | 43 | } |
44 | if task.BidInfo != nil && task.BidInfo.SuccessfulBidder != nil { | 44 | if task.BidInfo != nil && task.BidInfo.SuccessfulBidder != nil { |
@@ -83,7 +83,7 @@ func (repository *TaskRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -83,7 +83,7 @@ func (repository *TaskRepository) FindOne(queryOptions map[string]interface{}) ( | ||
83 | if taskModel.BidInfo != nil { | 83 | if taskModel.BidInfo != nil { |
84 | var bidderInfoModels []*models.BidderInfo | 84 | var bidderInfoModels []*models.BidderInfo |
85 | bidderInfoQuery := tx.Model(&bidderInfoModels) | 85 | bidderInfoQuery := tx.Model(&bidderInfoModels) |
86 | - if err := bidderInfoQuery.Where("bid_info_id = ?", taskModel.BidInfo.Id).Select(); err != nil { | 86 | + if err := bidderInfoQuery.Where("task_id = ?", taskModel.Id).Select(); err != nil { |
87 | return nil, err | 87 | return nil, err |
88 | } | 88 | } |
89 | taskModel.BidInfo.BidderInfos = bidderInfoModels | 89 | taskModel.BidInfo.BidderInfos = bidderInfoModels |
@@ -176,7 +176,7 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | @@ -176,7 +176,7 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | ||
176 | if taskModel.BidInfo != nil { | 176 | if taskModel.BidInfo != nil { |
177 | var bidderInfoModels []*models.BidderInfo | 177 | var bidderInfoModels []*models.BidderInfo |
178 | bidderInfoQuery := tx.Model(&bidderInfoModels) | 178 | bidderInfoQuery := tx.Model(&bidderInfoModels) |
179 | - if err := bidderInfoQuery.Where("bid_info_id = ?", taskModel.BidInfo.Id).Select(); err != nil { | 179 | + if err := bidderInfoQuery.Where("task_id = ?", taskModel.Id).Select(); err != nil { |
180 | return int64(count), tasks, nil | 180 | return int64(count), tasks, nil |
181 | } | 181 | } |
182 | taskModel.BidInfo.BidderInfos = bidderInfoModels | 182 | taskModel.BidInfo.BidderInfos = bidderInfoModels |
@@ -205,7 +205,7 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model | @@ -205,7 +205,7 @@ func (repository *TaskRepository) transformPgModelToDomainModel(taskModel *model | ||
205 | if taskModel.BidInfo == nil { | 205 | if taskModel.BidInfo == nil { |
206 | bidInfo = nil | 206 | bidInfo = nil |
207 | } else { | 207 | } else { |
208 | - bidderInfos := make([]*domain.BidderInfo, len(taskModel.BidInfo.BidderInfos)) | 208 | + bidderInfos := make([]*domain.BidderInfo, 0) |
209 | for _, bidderInfo := range taskModel.BidInfo.BidderInfos { | 209 | for _, bidderInfo := range taskModel.BidInfo.BidderInfos { |
210 | bidderInfos = append(bidderInfos, &domain.BidderInfo{ | 210 | bidderInfos = append(bidderInfos, &domain.BidderInfo{ |
211 | Bidder: bidderInfo.Bidder, | 211 | Bidder: bidderInfo.Bidder, |
1 | package task | 1 | package task |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/go-pg/pg" | ||
5 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | ||
4 | "net/http" | 6 | "net/http" |
7 | + "time" | ||
5 | 8 | ||
6 | "github.com/gavv/httpexpect" | 9 | "github.com/gavv/httpexpect" |
7 | - "github.com/go-pg/pg" | ||
8 | . "github.com/onsi/ginkgo" | 10 | . "github.com/onsi/ginkgo" |
9 | . "github.com/onsi/gomega" | 11 | . "github.com/onsi/gomega" |
10 | pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" | 12 | pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" |
11 | ) | 13 | ) |
12 | 14 | ||
13 | var _ = Describe("对任务进行竞标", func() { | 15 | var _ = Describe("对任务进行竞标", func() { |
14 | - var taskId int64 | 16 | + Describe("对任务进行竞标", func() { |
17 | + Context("竞标人对已发布的竞标类型任务进行竞标", func() { | ||
15 | BeforeEach(func() { | 18 | BeforeEach(func() { |
19 | + dayAfter, _ := time.ParseDuration("72h") | ||
16 | _, err := pG.DB.QueryOne( | 20 | _, err := pG.DB.QueryOne( |
17 | - pg.Scan(&taskId), | ||
18 | - "INSERT INTO tasks (task_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, rob_info, bid_info, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
19 | - "testTaskId", "testCompanyId", "testTaskName", "testTaskType", "testSponsor", "testTaskStatus", "testReferenceResource", "testCustomerValue", "testTaskNature", "testSuMoney", "testAcceptanceStandard", "testTaskDescription", "testTaskPictureUrls", "testIsRewardTake", "testRobInfo", "testBidInfo", "testParticipators", "testTaskPercentage", "testSolveReport", "testSolvePictureUrls", "testCreateTime", "testReleaseTime") | 21 | + pg.Scan(), |
22 | + "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
23 | + 1, 101, "竞标任务1", 2, &domain.EmployeeInfo{ | ||
24 | + Uid: 2499036607974745088, | ||
25 | + }, 2, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{ | ||
26 | + { | ||
27 | + Uid: 2499036607974745077, | ||
28 | + }, | ||
29 | + { | ||
30 | + Uid: 2499036607974745066, | ||
31 | + }, | ||
32 | + }, "null", "", pg.Array([]string{}), 0, time.Now(), time.Now().Add(dayAfter)) | ||
20 | Expect(err).NotTo(HaveOccurred()) | 33 | Expect(err).NotTo(HaveOccurred()) |
34 | + _, err1 := pG.DB.QueryOne( | ||
35 | + pg.Scan(), | ||
36 | + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)", | ||
37 | + 1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0) | ||
38 | + Expect(err1).NotTo(HaveOccurred()) | ||
39 | + _, err2 := pG.DB.QueryOne( | ||
40 | + pg.Scan(), | ||
41 | + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)", | ||
42 | + 2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0) | ||
43 | + Expect(err2).NotTo(HaveOccurred()) | ||
44 | + _, err3 := pG.DB.QueryOne( | ||
45 | + pg.Scan(), | ||
46 | + "INSERT INTO bid_infos (task_id, bid_start_time, bid_end_time) VALUES (?, ?, ?)", | ||
47 | + 1, time.Date(2020, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()), time.Now().Add(dayAfter)) | ||
48 | + Expect(err3).NotTo(HaveOccurred()) | ||
49 | + _, err4 := pG.DB.QueryOne( | ||
50 | + pg.Scan(), | ||
51 | + "INSERT INTO bidder_infos (task_id) VALUES (?)", | ||
52 | + 1) | ||
53 | + Expect(err4).NotTo(HaveOccurred()) | ||
21 | }) | 54 | }) |
22 | - Describe("对任务进行竞标", func() { | ||
23 | - Context("", func() { | ||
24 | - It("", func() { | 55 | + It("竞标成功", func() { |
25 | httpExpect := httpexpect.New(GinkgoT(), server.URL) | 56 | httpExpect := httpexpect.New(GinkgoT(), server.URL) |
26 | body := map[string]interface{}{ | 57 | body := map[string]interface{}{ |
27 | - "bidder": "int64", | 58 | + "bidder": 2499036607974745099, |
28 | } | 59 | } |
29 | - httpExpect.POST("/tasks/{taskId}/bid"). | 60 | + httpExpect.POST("/tasks/1/bid"). |
30 | WithJSON(body). | 61 | WithJSON(body). |
31 | Expect(). | 62 | Expect(). |
32 | Status(http.StatusOK). | 63 | Status(http.StatusOK). |
@@ -34,12 +65,21 @@ var _ = Describe("对任务进行竞标", func() { | @@ -34,12 +65,21 @@ var _ = Describe("对任务进行竞标", func() { | ||
34 | Object(). | 65 | Object(). |
35 | ContainsKey("code").ValueEqual("code", 0). | 66 | ContainsKey("code").ValueEqual("code", 0). |
36 | ContainsKey("msg").ValueEqual("msg", "ok"). | 67 | ContainsKey("msg").ValueEqual("msg", "ok"). |
37 | - ContainsKey("data").Value("data").Object() | 68 | + ContainsKey("data").Value("data").Object(). |
69 | + ContainsKey("taskStatus").ValueEqual("taskStatus", 3). | ||
70 | + ContainsKey("bidInfo").Value("bidInfo").Object(). | ||
71 | + ContainsKey("bidderInfos").Value("bidderInfos").Array().Length().Equal(2) | ||
38 | }) | 72 | }) |
39 | }) | 73 | }) |
40 | }) | 74 | }) |
41 | AfterEach(func() { | 75 | AfterEach(func() { |
42 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") | 76 | _, err := pG.DB.Exec("DELETE FROM tasks WHERE true") |
43 | Expect(err).NotTo(HaveOccurred()) | 77 | Expect(err).NotTo(HaveOccurred()) |
78 | + _, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true") | ||
79 | + Expect(err1).NotTo(HaveOccurred()) | ||
80 | + _, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true") | ||
81 | + Expect(err2).NotTo(HaveOccurred()) | ||
82 | + _, err3 := pG.DB.Exec("DELETE FROM employees WHERE true") | ||
83 | + Expect(err3).NotTo(HaveOccurred()) | ||
44 | }) | 84 | }) |
45 | }) | 85 | }) |
-
请 注册 或 登录 后发表评论