service.go
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
type CommonService struct {
}
func NewCommonService(options map[string]interface{}) *CommonService {
return &CommonService{}
}
//GetDictionaryByCode 根据code获取字典数据
func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDictionaryByCodeQuery) (interface{}, error) {
//creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(domain.Operator{})
//result, err := creationBasicGateway.GetDictionarysByCode(allied_creation_basic.ReqGetDictionaryByCode{
// DictCode: getDictionaryQuery.DictCode,
//})
//if err != nil {
// return nil, err
//}
//return result, nil
// TODO:测试使用,后期移除掉
type dictItem struct {
ItemCode string `json:"itemCode"`
ItemValue string `json:"itemValue"`
}
dictionaries := make([]interface{}, 0)
for i := range getDictionaryQuery.DictCode {
switch getDictionaryQuery.DictCode[i] {
case "MenuType":
dictionaries = append(dictionaries, map[string]interface{}{
"dictName": "菜单类型",
"dictItems": []dictItem{
{"目录", "catalog"},
{"菜单", "menu"},
{"按钮", "button"},
},
})
case "scale":
dictionaries = append(dictionaries, map[string]interface{}{
"dictName": "规模",
"dictItems": []dictItem{
{"50~100人", "50~100人"},
{"100~500人", "100~500人"},
{"500人以上", "500人以上"},
},
})
case "industry":
dictionaries = append(dictionaries, map[string]interface{}{
"dictName": "产业类型",
"dictItems": []dictItem{
{"食品行业", "食品行业"},
{"金融行业", "金融行业"},
{"保险行业", "保险行业"},
{"计算机行业", "计算机行业"},
},
})
}
}
return map[string]interface{}{"dictionarys": dictionaries}, nil
}
//CompanySignUp 公司注册
func (srv *CommonService) CompanySignUp(signUpCommand *command.CompanySignUpCommand) (interface{}, error) {
if err := signUpCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//校验验证码
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
_, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{
CompanyName: signUpCommand.CompanyName,
Contacts: signUpCommand.Contacts,
IndustryCategory: signUpCommand.IndustryCategory,
Password: signUpCommand.Password,
Phone: signUpCommand.Phone,
Scale: signUpCommand.Scale,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return signUpCommand, nil
}