service.go
2.4 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
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/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 UserService struct {
}
// 创建菜单服务
func (userService *UserService) SearchUser(cmd *query.ListUserQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
result, err := creationUserGateway.UserBaseSearch(allied_creation_user.ReqUserBaseSearch{
Offset: (cmd.PageNumber - 1) * cmd.PageSize,
Limit: cmd.PageSize,
UserName: cmd.UserName,
OrgName: cmd.OrgName,
FetchOrgBelong: true,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var users = make([]dto.UserBaseDto, 0)
for i := range result.Users {
item := &dto.UserBaseDto{}
item.LoadDto(result.Users[i])
users = append(users, *item)
}
return result.Count, users, nil
}
func (userService *UserService) EnableUser(cmd *command.EnableUserCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
_, err := creationUserGateway.EnableUserBase(allied_creation_user.ReqEnableUserBase{
UserBaseIds: []int64{cmd.UserBaseId},
EnableStatus: cmd.EnableStatus,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return struct{}{}, nil
}
func (userService *UserService) ResetPassword(cmd *command.ResetPasswordCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
_, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
Phone: cmd.Account,
Password: domain.DefaultPassword, //TL123456!
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return struct{}{}, nil
}
func NewUserService(options map[string]interface{}) *UserService {
newUserService := &UserService{}
return newUserService
}