作者 linmadan

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

... ... @@ -33,6 +33,8 @@ type SearchTaskCommand struct {
Participator int64 `json:"participator,omitempty"`
//是否过滤关闭状态任务
IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
//是否过滤待发布状态任务
IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -35,6 +35,8 @@ type ListTaskQuery struct {
Participator int64 `json:"participator,omitempty"`
//是否过滤关闭状态任务
IsFilterCloseStatus bool `json:"isFilterCloseStatus,omitempty"`
//是否过滤待发布状态任务
IsFilterUnReleasedStatus bool `json:"isFilterUnReleasedStatus,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
// 任务服务
... ... @@ -445,6 +446,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
TaskDescription: createTaskCommand.TaskDescription,
TaskPictureUrls: createTaskCommand.TaskPictureUrls,
IsRewardTake: createTaskCommand.IsRewardTake,
CreateTime: time.Now(),
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
... ...
... ... @@ -31,13 +31,13 @@ func (employee *Employee) Identify() interface{} {
}
func (employee *Employee) Update(data map[string]interface{}) error {
if employeeName, ok := data["employeeName"]; ok {
if employeeName, ok := data["employeeName"]; ok && employeeName != "" {
employee.EmployeeInfo.EmployeeName = employeeName.(string)
}
if employeeAccount, ok := data["employeeAccount"]; ok {
if employeeAccount, ok := data["employeeAccount"]; ok && employeeAccount != "" {
employee.EmployeeInfo.EmployeeAccount = employeeAccount.(string)
}
if status, ok := data["status"]; ok {
if status, ok := data["status"]; ok && status != 0 {
employee.Status = status.(int)
}
if permissions, ok := data["permissions"]; ok {
... ...
... ... @@ -31,7 +31,7 @@ func (offTaskRecord *OffTaskRecord) Identify() interface{} {
}
func (offTaskRecord *OffTaskRecord) Update(data map[string]interface{}) error {
if offReason, ok := data["offReason"]; ok {
if offReason, ok := data["offReason"]; ok && offReason != "" {
offTaskRecord.OffReason = offReason.(string)
}
return nil
... ...
... ... @@ -88,42 +88,42 @@ type TaskStatus interface {
type UnReleasedStatus struct{}
func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error {
if taskName, ok := data["taskName"]; ok {
if taskName, ok := data["taskName"]; ok && taskName != "" {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok {
if referenceResourceType, ok := data["referenceResourceType"]; ok && referenceResourceType != 0 {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
if referenceResourceItems, ok := data["referenceResourceItems"]; ok && len(referenceResourceItems.([]*ReferenceResourceItem)) != 0 {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if customerValue, ok := data["customerValue"]; ok {
if customerValue, ok := data["customerValue"]; ok && len(customerValue.([]string)) != 0 {
task.CustomerValue = customerValue.([]string)
}
if taskNature, ok := data["taskNature"]; ok {
if taskNature, ok := data["taskNature"]; ok && taskNature != "" {
task.TaskNature = taskNature.(string)
}
if suMoney, ok := data["suMoney"]; ok {
if suMoney, ok := data["suMoney"]; ok && suMoney.(float64) != float64(0) {
task.SuMoney = suMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
if bidStartTime, ok := data["bidStartTime"]; ok && !bidStartTime.(time.Time).IsZero() {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok {
if bidEndTime, ok := data["bidEndTime"]; ok && !bidEndTime.(time.Time).IsZero() {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
if acceptanceStandard, ok := data["acceptanceStandard"]; ok && acceptanceStandard != "" {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok {
if taskDescription, ok := data["taskDescription"]; ok && taskDescription != "" {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
if taskPictureUrls, ok := data["taskPictureUrls"]; ok && len(taskPictureUrls.([]string)) != 0 {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok {
if isRewardTake, ok := data["isRewardTake"]; ok && isRewardTake != false {
task.IsRewardTake = isRewardTake.(bool)
}
return nil
... ...
... ... @@ -102,6 +102,9 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int
if isFilterCloseStatus, ok := queryOptions["isFilterCloseStatus"]; ok && isFilterCloseStatus.(bool) != false {
query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_CLOSED)
}
if isFilterUnReleasedStatus, ok := queryOptions["isFilterUnReleasedStatus"]; ok && isFilterUnReleasedStatus.(bool) != false {
query = query.Where("task.task_status <> ? ", domain.TASK_STATUS_UNRELEASED)
}
if sponsor, ok := queryOptions["sponsor"]; ok && (sponsor != int64(0)) {
query = query.Where(`task.sponsor @> '{"uid":?}'`, sponsor)
}
... ...