作者 linmadan

重构更新方法

... ... @@ -325,8 +325,6 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
"taskType": searchOffTaskRecordCommand.TaskType,
"customerValue": searchOffTaskRecordCommand.CustomerValue,
"taskNature": searchOffTaskRecordCommand.TaskNature,
"offset": searchOffTaskRecordCommand.Offset,
"limit": searchOffTaskRecordCommand.Limit,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -94,42 +94,42 @@ type TaskStatus interface {
type UnReleasedStatus struct{}
func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error {
if taskName, ok := data["taskName"]; ok && taskName != "" {
if taskName, ok := data["taskName"]; ok {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok && referenceResourceType != 0 {
if referenceResourceType, ok := data["referenceResourceType"]; ok {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok && len(referenceResourceItems.([]*ReferenceResourceItem)) != 0 {
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if customerValue, ok := data["customerValue"]; ok && len(customerValue.([]string)) != 0 {
if customerValue, ok := data["customerValue"]; ok {
task.CustomerValue = customerValue.([]string)
}
if taskNature, ok := data["taskNature"]; ok && taskNature != "" {
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(string)
}
if suMoney, ok := data["suMoney"]; ok && suMoney.(float64) != float64(0) {
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok && !bidStartTime.(time.Time).IsZero() {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok && !bidEndTime.(time.Time).IsZero() {
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok && acceptanceStandard != "" {
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok && taskDescription != "" {
if taskDescription, ok := data["taskDescription"]; ok {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok && len(taskPictureUrls.([]string)) != 0 {
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok && isRewardTake != false {
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
return nil
... ...
... ... @@ -91,6 +91,32 @@ var _ = Describe("搜索关闭任务记录", func() {
ContainsKey("count").ValueEqual("count", 0)
})
})
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"companyId": 101,
"taskContentMatch": "",
"taskType": 1,
"customerValue": "",
"taskNature": "",
"offStartTime": time.Date(2030, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
"offEndTime": time.Time{},
"offset": 0,
"limit": 20,
}
httpExpect.POST("/off-task-records/search-off-task-record").
WithJSON(body).
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)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM off_task_records WHERE true")
... ...