users.go
8.3 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package service
import (
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 用户信息
type UsersService struct {
}
// 获取公司用户信息
func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.CompanyUserGetQuery) (interface{}, error) {
return nil, nil
}
// 创建公司用户信息
func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.CompanyUserAddCommand) (interface{}, error) {
return nil, nil
}
// 启用禁用公司用户信息
func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *command.CompanyUserEnableCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserEnableCommand.Operator.CompanyId,
companyUserEnableCommand.Operator.OrgId,
companyUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: companyUserEnableCommand.UsersIds,
EnableStatus: companyUserEnableCommand.EnableStatus,
})
return result, err
}
// 返回公司用户信息列表
func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(0, 0, 0)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
Limit: companyUserListQuery.PageSize,
CompanyId: companyUserListQuery.CompanyId,
OrganizationId: 0,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
Phone: "",
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//数据转换
cnt := int64(result.Count)
var (
listData []dto.UserListItem
item dto.UserListItem
)
for _, v := range result.Users {
item = dto.UserListItem{
DepName: v.Ext.DepName,
OrgName: v.Ext.OrgName,
Phone: v.Ext.Phone,
EnableStatus: v.EnableStatus,
UserCode: v.UserCode,
UserId: int64(v.UserID),
UserName: v.UserName,
}
listData = append(listData, item)
}
return cnt, listData, nil
}
// 批量重置密码
func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPasswordCommand *command.CompanyUserResetPasswordCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserResetPasswordCommand.Operator.CompanyId,
companyUserResetPasswordCommand.Operator.OrgId,
companyUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: companyUserResetPasswordCommand.UsersIds,
})
return result, err
}
// 更新公司用户信息
func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *command.CompanyUserUpdateCommand) (interface{}, error) {
return nil, nil
}
// 创建共创用户信息
func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserAddCommand.Operator.CompanyId,
cooperationUserAddCommand.Operator.OrgId,
cooperationUserAddCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserAddCommand.CooperationDeadline, 0),
Email: cooperationUserAddCommand.Email,
EnableStatus: cooperationUserAddCommand.EnableStatus,
UserCode: cooperationUserAddCommand.UsersCode,
UserName: cooperationUserAddCommand.UsersName,
Avatar: cooperationUserAddCommand.Avatar,
OrgId: cooperationUserAddCommand.Operator.OrgId,
Phone: cooperationUserAddCommand.Phone,
Password: "",
})
return result, err
}
// 启用禁用共创用户信息
func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCommand *command.CooperationUserEnableCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserEnableCommand.Operator.CompanyId,
cooperationUserEnableCommand.Operator.OrgId,
cooperationUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: cooperationUserEnableCommand.UsersIds,
EnableStatus: cooperationUserEnableCommand.EnableStatus,
})
return result, err
}
// 获取共创用户信息
func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *query.CooperationUserGetQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserGetQuery.Operator.CompanyId,
cooperationUserGetQuery.Operator.OrgId,
cooperationUserGetQuery.Operator.UserId)
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
UserId: cooperationUserGetQuery.UsersId,
})
if err != nil {
return nil, err
}
deadline := result.CooperationInfo.CooperationDeadline.Unix()
userInfo := dto.CooperationUserInfo{
UserId: strconv.FormatInt(result.UserId, 10),
UserCode: result.UserCode,
EnableStatus: int32(result.EnableStatus),
CooperationCompany: result.CooperationInfo.CooperationCompany,
CooperationDeadline: deadline,
UserName: result.UserInfo.UserName,
Email: result.UserInfo.Email,
Phone: result.UserInfo.Phone,
Avatar: result.UserInfo.Avatar,
}
return userInfo, nil
}
// 返回共创用户信息列表
func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *query.CooperationUserListQuery) (interface{}, error) {
return nil, nil
}
// 批量重置密码
func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserResetPasswordCommand.Operator.CompanyId,
cooperationUserResetPasswordCommand.Operator.OrgId,
cooperationUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: cooperationUserResetPasswordCommand.UsersIds,
})
return result, err
}
// 编辑共创用户信息
func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCommand *command.CooperationUserUpdateCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserUpdateCommand.Operator.CompanyId,
cooperationUserUpdateCommand.Operator.OrgId,
cooperationUserUpdateCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserUpdate(allied_creation_user.ReqUpdateCooperatorUser{
UserId: cooperationUserUpdateCommand.UsersId,
CooperationCompany: cooperationUserUpdateCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserUpdateCommand.CooperationDeadline, 0),
Email: cooperationUserUpdateCommand.Email,
EnableStatus: cooperationUserUpdateCommand.EnableStatus,
UserCode: cooperationUserUpdateCommand.UsersCode,
UserName: cooperationUserUpdateCommand.UsersName,
Avatar: cooperationUserUpdateCommand.Avatar,
OrgId: cooperationUserUpdateCommand.Operator.OrgId,
Phone: cooperationUserUpdateCommand.Phone,
})
return result, err
}
func NewUsersService(options map[string]interface{}) *UsersService {
newUsersService := &UsersService{}
return newUsersService
}