config.go 2.5 KB
package service

import (
	"github.com/linmadan/egglib-go/core/application"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/config/query"
)

// 配置服务
type ConfigService struct {
}

// 返回任务状态列表
func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.ListTaskStatusQuery) (interface{}, error) {
	if err := listTaskStatusQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	taskStatuses := map[int]string{
		1: "待发布",
		2: "待领取",
		3: "进行中",
		4: "待验收",
		5: "已完成",
	}
	return map[string]interface{}{
		"taskStatuses": taskStatuses,
	}, nil
}

// 返回任务类型列表
func (configService *ConfigService) ListTaskTypes(listTaskTypesQuery *query.ListTaskTypesQuery) (interface{}, error) {
	if err := listTaskTypesQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	taskTypes := map[int]string{
		1: "抢单任务",
		2: "竞标任务",
	}
	return map[string]interface{}{
		"taskTypes": taskTypes,
	}, nil
}

// 返回任务性质列表
func (configService *ConfigService) ListTaskNatures(listTaskNaturesQuery *query.ListTaskNaturesQuery) (interface{}, error) {
	if err := listTaskNaturesQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	taskNatures := map[int]string{
		1: "点",
		2: "线",
		3: "面",
		4: "链",
		5: "网",
	}
	return map[string]interface{}{
		"taskNatures": taskNatures,
	}, nil
}

// 返回客户价值列表
func (configService *ConfigService) ListCustomerValues(listCustomerValuesQuery *query.ListCustomerValuesQuery) (interface{}, error) {
	if err := listCustomerValuesQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	customerValues := map[int]string{
		1:  "口味",
		2:  "口感",
		3:  "色泽",
		4:  "卖相",
		5:  "包装",
		6:  "储存",
		7:  "运输",
		8:  "价格",
		9:  "应用",
		10: "便利",
		11: "交期",
		12: "数量",
		13: "账期",
		14: "品质",
		15: "新鲜度",
		16: "推广",
		17: "规格",
		18: "人情关系",
		19: "商务服务",
		20: "售后服务",
		21: "新品",
		22: "品牌",
		23: "合同",
	}
	return map[string]interface{}{
		"customerValues": customerValues,
	}, nil
}

func NewConfigService(options map[string]interface{}) *ConfigService {
	newConfigService := &ConfigService{}
	return newConfigService
}