作者 linmadan

重构更新方法

@@ -325,8 +325,6 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * @@ -325,8 +325,6 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
325 "taskType": searchOffTaskRecordCommand.TaskType, 325 "taskType": searchOffTaskRecordCommand.TaskType,
326 "customerValue": searchOffTaskRecordCommand.CustomerValue, 326 "customerValue": searchOffTaskRecordCommand.CustomerValue,
327 "taskNature": searchOffTaskRecordCommand.TaskNature, 327 "taskNature": searchOffTaskRecordCommand.TaskNature,
328 - "offset": searchOffTaskRecordCommand.Offset,  
329 - "limit": searchOffTaskRecordCommand.Limit,  
330 }) 328 })
331 if err != nil { 329 if err != nil {
332 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 330 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -94,42 +94,42 @@ type TaskStatus interface { @@ -94,42 +94,42 @@ type TaskStatus interface {
94 type UnReleasedStatus struct{} 94 type UnReleasedStatus struct{}
95 95
96 func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { 96 func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error {
97 - if taskName, ok := data["taskName"]; ok && taskName != "" { 97 + if taskName, ok := data["taskName"]; ok {
98 task.TaskName = taskName.(string) 98 task.TaskName = taskName.(string)
99 } 99 }
100 - if referenceResourceType, ok := data["referenceResourceType"]; ok && referenceResourceType != 0 { 100 + if referenceResourceType, ok := data["referenceResourceType"]; ok {
101 task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int) 101 task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
102 } 102 }
103 - if referenceResourceItems, ok := data["referenceResourceItems"]; ok && len(referenceResourceItems.([]*ReferenceResourceItem)) != 0 { 103 + if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
104 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem) 104 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
105 } 105 }
106 - if customerValue, ok := data["customerValue"]; ok && len(customerValue.([]string)) != 0 { 106 + if customerValue, ok := data["customerValue"]; ok {
107 task.CustomerValue = customerValue.([]string) 107 task.CustomerValue = customerValue.([]string)
108 } 108 }
109 - if taskNature, ok := data["taskNature"]; ok && taskNature != "" { 109 + if taskNature, ok := data["taskNature"]; ok {
110 task.TaskNature = taskNature.(string) 110 task.TaskNature = taskNature.(string)
111 } 111 }
112 - if suMoney, ok := data["suMoney"]; ok && suMoney.(float64) != float64(0) { 112 + if suMoney, ok := data["suMoney"]; ok {
113 task.SuMoney = suMoney.(float64) 113 task.SuMoney = suMoney.(float64)
114 } 114 }
115 if task.TaskType == TASK_TYPE_BID { 115 if task.TaskType == TASK_TYPE_BID {
116 - if bidStartTime, ok := data["bidStartTime"]; ok && !bidStartTime.(time.Time).IsZero() { 116 + if bidStartTime, ok := data["bidStartTime"]; ok {
117 task.BidInfo.BidStartTime = bidStartTime.(time.Time) 117 task.BidInfo.BidStartTime = bidStartTime.(time.Time)
118 } 118 }
119 - if bidEndTime, ok := data["bidEndTime"]; ok && !bidEndTime.(time.Time).IsZero() { 119 + if bidEndTime, ok := data["bidEndTime"]; ok {
120 task.BidInfo.BidEndTime = bidEndTime.(time.Time) 120 task.BidInfo.BidEndTime = bidEndTime.(time.Time)
121 } 121 }
122 } 122 }
123 - if acceptanceStandard, ok := data["acceptanceStandard"]; ok && acceptanceStandard != "" { 123 + if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
124 task.AcceptanceStandard = acceptanceStandard.(string) 124 task.AcceptanceStandard = acceptanceStandard.(string)
125 } 125 }
126 - if taskDescription, ok := data["taskDescription"]; ok && taskDescription != "" { 126 + if taskDescription, ok := data["taskDescription"]; ok {
127 task.TaskDescription = taskDescription.(string) 127 task.TaskDescription = taskDescription.(string)
128 } 128 }
129 - if taskPictureUrls, ok := data["taskPictureUrls"]; ok && len(taskPictureUrls.([]string)) != 0 { 129 + if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
130 task.TaskPictureUrls = taskPictureUrls.([]string) 130 task.TaskPictureUrls = taskPictureUrls.([]string)
131 } 131 }
132 - if isRewardTake, ok := data["isRewardTake"]; ok && isRewardTake != false { 132 + if isRewardTake, ok := data["isRewardTake"]; ok {
133 task.IsRewardTake = isRewardTake.(bool) 133 task.IsRewardTake = isRewardTake.(bool)
134 } 134 }
135 return nil 135 return nil
@@ -91,6 +91,32 @@ var _ = Describe("搜索关闭任务记录", func() { @@ -91,6 +91,32 @@ var _ = Describe("搜索关闭任务记录", func() {
91 ContainsKey("count").ValueEqual("count", 0) 91 ContainsKey("count").ValueEqual("count", 0)
92 }) 92 })
93 }) 93 })
  94 + Context("", func() {
  95 + It("", func() {
  96 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  97 + body := map[string]interface{}{
  98 + "companyId": 101,
  99 + "taskContentMatch": "",
  100 + "taskType": 1,
  101 + "customerValue": "",
  102 + "taskNature": "",
  103 + "offStartTime": time.Date(2030, time.Month(4), 5, 8, 0, 0, 0, time.Now().Location()),
  104 + "offEndTime": time.Time{},
  105 + "offset": 0,
  106 + "limit": 20,
  107 + }
  108 + httpExpect.POST("/off-task-records/search-off-task-record").
  109 + WithJSON(body).
  110 + Expect().
  111 + Status(http.StatusOK).
  112 + JSON().
  113 + Object().
  114 + ContainsKey("code").ValueEqual("code", 0).
  115 + ContainsKey("msg").ValueEqual("msg", "ok").
  116 + ContainsKey("data").Value("data").Object().
  117 + ContainsKey("count").ValueEqual("count", 0)
  118 + })
  119 + })
94 }) 120 })
95 AfterEach(func() { 121 AfterEach(func() {
96 _, err := pG.DB.Exec("DELETE FROM off_task_records WHERE true") 122 _, err := pG.DB.Exec("DELETE FROM off_task_records WHERE true")