作者 linmadan

重构更新功能,添加任务搜索参数

@@ -33,6 +33,8 @@ type SearchTaskCommand struct { @@ -33,6 +33,8 @@ type SearchTaskCommand struct {
33 Participator int64 `json:"participator,omitempty"` 33 Participator int64 `json:"participator,omitempty"`
34 //是否过滤关闭状态任务 34 //是否过滤关闭状态任务
35 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"` 35 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
  36 + //是否过滤待发布状态任务
  37 + IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
36 // 查询偏离量 38 // 查询偏离量
37 Offset int `json:"offset,omitempty"` 39 Offset int `json:"offset,omitempty"`
38 // 查询限制 40 // 查询限制
@@ -35,6 +35,8 @@ type ListTaskQuery struct { @@ -35,6 +35,8 @@ type ListTaskQuery struct {
35 Participator int64 `json:"participator,omitempty"` 35 Participator int64 `json:"participator,omitempty"`
36 //是否过滤关闭状态任务 36 //是否过滤关闭状态任务
37 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"` 37 IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
  38 + //是否过滤待发布状态任务
  39 + IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
38 // 查询偏离量 40 // 查询偏离量
39 Offset int `json:"offset,omitempty"` 41 Offset int `json:"offset,omitempty"`
40 // 查询限制 42 // 查询限制
@@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
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 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
  13 + "time"
13 ) 14 )
14 15
15 // 任务服务 16 // 任务服务
@@ -445,6 +446,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -445,6 +446,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
445 TaskDescription: createTaskCommand.TaskDescription, 446 TaskDescription: createTaskCommand.TaskDescription,
446 TaskPictureUrls: createTaskCommand.TaskPictureUrls, 447 TaskPictureUrls: createTaskCommand.TaskPictureUrls,
447 IsRewardTake: createTaskCommand.IsRewardTake, 448 IsRewardTake: createTaskCommand.IsRewardTake,
  449 + CreateTime: time.Now(),
448 } 450 }
449 var taskRepository domain.TaskRepository 451 var taskRepository domain.TaskRepository
450 if value, err := factory.CreateTaskRepository(map[string]interface{}{ 452 if value, err := factory.CreateTaskRepository(map[string]interface{}{
@@ -31,13 +31,13 @@ func (employee *Employee) Identify() interface{} { @@ -31,13 +31,13 @@ func (employee *Employee) Identify() interface{} {
31 } 31 }
32 32
33 func (employee *Employee) Update(data map[string]interface{}) error { 33 func (employee *Employee) Update(data map[string]interface{}) error {
34 - if employeeName, ok := data["employeeName"]; ok { 34 + if employeeName, ok := data["employeeName"]; ok && employeeName != "" {
35 employee.EmployeeInfo.EmployeeName = employeeName.(string) 35 employee.EmployeeInfo.EmployeeName = employeeName.(string)
36 } 36 }
37 - if employeeAccount, ok := data["employeeAccount"]; ok { 37 + if employeeAccount, ok := data["employeeAccount"]; ok && employeeAccount != "" {
38 employee.EmployeeInfo.EmployeeAccount = employeeAccount.(string) 38 employee.EmployeeInfo.EmployeeAccount = employeeAccount.(string)
39 } 39 }
40 - if status, ok := data["status"]; ok { 40 + if status, ok := data["status"]; ok && status != 0 {
41 employee.Status = status.(int) 41 employee.Status = status.(int)
42 } 42 }
43 if permissions, ok := data["permissions"]; ok { 43 if permissions, ok := data["permissions"]; ok {
@@ -31,7 +31,7 @@ func (offTaskRecord *OffTaskRecord) Identify() interface{} { @@ -31,7 +31,7 @@ func (offTaskRecord *OffTaskRecord) Identify() interface{} {
31 } 31 }
32 32
33 func (offTaskRecord *OffTaskRecord) Update(data map[string]interface{}) error { 33 func (offTaskRecord *OffTaskRecord) Update(data map[string]interface{}) error {
34 - if offReason, ok := data["offReason"]; ok { 34 + if offReason, ok := data["offReason"]; ok && offReason != "" {
35 offTaskRecord.OffReason = offReason.(string) 35 offTaskRecord.OffReason = offReason.(string)
36 } 36 }
37 return nil 37 return nil
@@ -88,42 +88,42 @@ type TaskStatus interface { @@ -88,42 +88,42 @@ type TaskStatus interface {
88 type UnReleasedStatus struct{} 88 type UnReleasedStatus struct{}
89 89
90 func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { 90 func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error {
91 - if taskName, ok := data["taskName"]; ok { 91 + if taskName, ok := data["taskName"]; ok && taskName != "" {
92 task.TaskName = taskName.(string) 92 task.TaskName = taskName.(string)
93 } 93 }
94 - if referenceResourceType, ok := data["referenceResourceType"]; ok { 94 + if referenceResourceType, ok := data["referenceResourceType"]; ok && referenceResourceType != 0 {
95 task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int) 95 task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
96 } 96 }
97 - if referenceResourceItems, ok := data["referenceResourceItems"]; ok { 97 + if referenceResourceItems, ok := data["referenceResourceItems"]; ok && len(referenceResourceItems.([]*ReferenceResourceItem)) != 0 {
98 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem) 98 task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
99 } 99 }
100 - if customerValue, ok := data["customerValue"]; ok { 100 + if customerValue, ok := data["customerValue"]; ok && len(customerValue.([]string)) != 0 {
101 task.CustomerValue = customerValue.([]string) 101 task.CustomerValue = customerValue.([]string)
102 } 102 }
103 - if taskNature, ok := data["taskNature"]; ok { 103 + if taskNature, ok := data["taskNature"]; ok && taskNature != "" {
104 task.TaskNature = taskNature.(string) 104 task.TaskNature = taskNature.(string)
105 } 105 }
106 - if suMoney, ok := data["suMoney"]; ok { 106 + if suMoney, ok := data["suMoney"]; ok && suMoney.(float64) != float64(0) {
107 task.SuMoney = suMoney.(float64) 107 task.SuMoney = suMoney.(float64)
108 } 108 }
109 if task.TaskType == TASK_TYPE_BID { 109 if task.TaskType == TASK_TYPE_BID {
110 - if bidStartTime, ok := data["bidStartTime"]; ok { 110 + if bidStartTime, ok := data["bidStartTime"]; ok && !bidStartTime.(time.Time).IsZero() {
111 task.BidInfo.BidStartTime = bidStartTime.(time.Time) 111 task.BidInfo.BidStartTime = bidStartTime.(time.Time)
112 } 112 }
113 - if bidEndTime, ok := data["bidEndTime"]; ok { 113 + if bidEndTime, ok := data["bidEndTime"]; ok && !bidEndTime.(time.Time).IsZero() {
114 task.BidInfo.BidEndTime = bidEndTime.(time.Time) 114 task.BidInfo.BidEndTime = bidEndTime.(time.Time)
115 } 115 }
116 } 116 }
117 - if acceptanceStandard, ok := data["acceptanceStandard"]; ok { 117 + if acceptanceStandard, ok := data["acceptanceStandard"]; ok && acceptanceStandard != "" {
118 task.AcceptanceStandard = acceptanceStandard.(string) 118 task.AcceptanceStandard = acceptanceStandard.(string)
119 } 119 }
120 - if taskDescription, ok := data["taskDescription"]; ok { 120 + if taskDescription, ok := data["taskDescription"]; ok && taskDescription != "" {
121 task.TaskDescription = taskDescription.(string) 121 task.TaskDescription = taskDescription.(string)
122 } 122 }
123 - if taskPictureUrls, ok := data["taskPictureUrls"]; ok { 123 + if taskPictureUrls, ok := data["taskPictureUrls"]; ok && len(taskPictureUrls.([]string)) != 0 {
124 task.TaskPictureUrls = taskPictureUrls.([]string) 124 task.TaskPictureUrls = taskPictureUrls.([]string)
125 } 125 }
126 - if isRewardTake, ok := data["isRewardTake"]; ok { 126 + if isRewardTake, ok := data["isRewardTake"]; ok && isRewardTake != false {
127 task.IsRewardTake = isRewardTake.(bool) 127 task.IsRewardTake = isRewardTake.(bool)
128 } 128 }
129 return nil 129 return nil
@@ -102,6 +102,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int @@ -102,6 +102,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
102 if isFilterCloseStatus, ok := queryOptions["isFilterCloseStatus"]; ok && isFilterCloseStatus.(bool) != false { 102 if isFilterCloseStatus, ok := queryOptions["isFilterCloseStatus"]; ok && isFilterCloseStatus.(bool) != false {
103 query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_CLOSED) 103 query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_CLOSED)
104 } 104 }
  105 + if isFilterUnReleasedStatus, ok := queryOptions["isFilterUnReleasedStatus"]; ok && isFilterUnReleasedStatus.(bool) != false {
  106 + query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_UNRELEASED)
  107 + }
105 if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) { 108 if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) {
106 query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor) 109 query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor)
107 } 110 }