config.go 5.2 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())
	}
	taskStatusMap := map[int]string{
		1: "待发布",
		2: "待领取",
		3: "进行中",
		4: "待验收",
		5: "已完成",
		7: "待确认",
		8: "已过期",
	}
	var list []map[string]interface{}
	for key, value := range taskStatusMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"taskStatuses": list,
	}, nil
}

// 返回任务类型列表
func (configService *ConfigService) ListTaskType(listTaskTypeQuery *query.ListTaskTypeQuery) (interface{}, error) {
	if err := listTaskTypeQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	taskTypeMap := map[int]string{
		1: "抢单任务",
		2: "竞标任务",
		3: "指派任务",
	}
	var list []map[string]interface{}
	for key, value := range taskTypeMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"taskTypes": list,
	}, nil
}

// 返回任务性质列表
func (configService *ConfigService) ListTaskNature(listTaskNatureQuery *query.ListTaskNatureQuery) (interface{}, error) {
	if err := listTaskNatureQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	taskNatureMap := map[int]string{
		1: "点",
		2: "线",
		3: "面",
		4: "链",
		5: "网",
	}
	var list []map[string]interface{}
	for key, value := range taskNatureMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"taskNatures": list,
	}, nil
}

// 返回客户价值列表
func (configService *ConfigService) ListCustomerValue(listCustomerValueQuery *query.ListCustomerValueQuery) (interface{}, error) {
	if err := listCustomerValueQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	customerValueMap := 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: "合同",
	}
	var list []map[string]interface{}
	for key, value := range customerValueMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"customerValues": list,
	}, nil
}

// 返回任务引用资源类型字典列表
func (configService *ConfigService) ListReferenceResourceType(listReferenceResourceTypeQuery *query.ListReferenceResourceTypeQuery) (interface{}, error) {
	if err := listReferenceResourceTypeQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	referenceResourceTypeMap := map[int]string{
		1: "问题",
		//2: "机会",
	}
	var list []map[string]interface{}
	for key, value := range referenceResourceTypeMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"referenceResourceTypes": list,
	}, nil
}

// 返回竞标时间字典列表(1全部,2已截止,3未截止)
func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *query.ListBidTimeMatchQuery) (interface{}, error) {
	if err := listBidTimeMatchQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	bidTimeMatchMap := map[int]string{
		1: "全部",
		2: "已截止",
		3: "未截止",
	}
	var list []map[string]interface{}
	for key, value := range bidTimeMatchMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"bidTimeMatchs": list,
	}, nil
}

// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理,4标签管理,5排行榜管理)
func (configService *ConfigService) ListEmployeePermission(listEmployeePermissionQuery *query.ListEmployeePermissionQuery) (interface{}, error) {
	if err := listEmployeePermissionQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	employeePermissionMap := map[int]string{
		1: "任务管理",
		2: "素币管理",
		3: "成员管理",
		4: "标签管理",
		5: "排行榜管理",
	}
	var list []map[string]interface{}
	for key, value := range employeePermissionMap {
		list = append(list, map[string]interface{}{
			"id":   key,
			"name": value,
		})
	}
	return map[string]interface{}{
		"employeePermissions": list,
	}, nil
}

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