auth_controller.go
6.9 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
package controllers
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/service"
)
type AuthController struct {
BaseController
}
func (controller *AuthController) Login() {
authService := service.AuthService{}
loginCmd := &command.LoginCommand{}
Must(controller.Unmarshal(loginCmd))
data, err := authService.AuthLogin(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) LoginPwd() {
authService := service.AuthService{}
loginCmd := &command.LoginPwdCommand{}
Must(controller.Unmarshal(loginCmd))
loginCmd.DeviceType = controller.GetDeviceType()
data, err := authService.AuthLoginPwd(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) LoginSms() {
authService := service.AuthService{}
loginCmd := &command.LoginSmsCommand{}
Must(controller.Unmarshal(loginCmd))
loginCmd.DeviceType = controller.GetDeviceType()
data, err := authService.AuthLoginSms(loginCmd)
controller.Response(data, err)
}
func (controller *AuthController) SendSmsCode() {
authService := service.AuthService{}
cmd := &command.SendSmsCodeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
err = authService.SendSmsCaptcha(cmd)
controller.Response(nil, err)
}
func (controller *AuthController) GetAuthAccessToken() {
authService := service.AuthService{}
accessTokenCommand := &command.AccessTokenCommand{}
err := controller.Unmarshal(accessTokenCommand)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.GetAuthAccessToken(accessTokenCommand)
controller.Response(data, err)
}
func (controller *AuthController) RefreshAuthAccessToken() {
authService := service.AuthService{}
refreshTokenCmd := &command.RefreshTokenCommand{}
err := controller.Unmarshal(refreshTokenCmd)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.RefreshAuthAccessToken(refreshTokenCmd)
controller.Response(data, err)
}
func (controller *AuthController) GetUserInfo() {
authService := service.AuthService{}
userInfoCommand := &command.UserInfoCommand{}
err := controller.Unmarshal(userInfoCommand)
if err != nil {
controller.Response(nil, err)
return
}
userInfoCommand.Operator = controller.GetOperator()
data, err := authService.GetUserInfo(userInfoCommand)
controller.Response(data, err)
}
func (controller *AuthController) GetFavoriteMenus() {
authService := service.AuthService{}
userInfoCommand := &command.UserInfoCommand{}
err := controller.Unmarshal(userInfoCommand)
if err != nil {
controller.Response(nil, err)
return
}
userInfoCommand.Operator = controller.GetOperator()
data, err := authService.GetFavoriteMenus(userInfoCommand)
controller.Response(data, err)
}
func (controller *AuthController) GetUserMenus() {
authService := service.AuthService{}
userMenusCommand := &command.UserMenusCommand{}
err := controller.Unmarshal(userMenusCommand)
if err != nil {
controller.Response(nil, err)
return
}
userMenusCommand.Operator = controller.GetOperator()
data, err := authService.GetUserMenus(userMenusCommand)
controller.Response(data, err)
}
func (controller *AuthController) GetUserOrg() {
authService := service.AuthService{}
userOrgCommand := &command.UserOrgCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
userOrgCommand.Operator = controller.GetOperator()
data, err := authService.GetUserOrg(userOrgCommand)
controller.Response(data, err)
}
func (controller *AuthController) CompanySignUp() {
authService := service.AuthService{}
userOrgCommand := &command.CompanySignUpCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
//userOrgCommand.Operator = controller.GetOperator()
data, err := authService.CompanySignUp(userOrgCommand)
controller.Response(data, err)
}
func (controller *AuthController) UserSignUp() {
authService := service.AuthService{}
cmd := &command.UserSignUpCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.UserSignUp(cmd)
controller.Response(data, err)
}
func (controller *AuthController) ResetPassword() {
authService := service.AuthService{}
userOrgCommand := &command.ResetPasswordCommand{}
err := controller.Unmarshal(userOrgCommand)
if err != nil {
controller.Response(nil, err)
return
}
//userOrgCommand.Operator = controller.GetOperator()
data, err := authService.ResetPassword(userOrgCommand)
controller.Response(data, err)
}
func (controller *AuthController) OrgSwitch() {
authService := service.AuthService{}
cmd := &command.SwitchOrgCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.OrgSwitch(cmd)
controller.Response(data, err)
}
func (controller *AuthController) GetCompanyOrgsByUser() {
authService := service.AuthService{}
cmd := &query.GetCompanyOrgsByUserQuery{}
Must(controller.Unmarshal(cmd))
cmd.Operator = controller.GetOperator()
data, err := authService.GetCompanyOrgsByUser(cmd)
controller.Response(data, err)
}
func (controller *AuthController) GetQrcode() {
authService := service.AuthService{}
data, err := authService.GetQrcode()
controller.Response(data, err)
}
func (controller *AuthController) LoginQrcode() {
authService := service.AuthService{}
cmd := &query.QrcodeLoginStatusQuery{}
Must(controller.Unmarshal(cmd))
cmd.DeviceType = controller.GetDeviceType()
data, err := authService.AuthLoginQrcode(cmd)
controller.Response(data, err)
}
func (controller *AuthController) QrcodeBinding() {
authService := service.AuthService{}
cmd := &command.QrcodeBindingCommand{}
Must(controller.Unmarshal(cmd))
cmd.Operator = controller.GetOperator()
data, err := authService.AuthLoginQrcodeBinding(cmd)
controller.Response(data, err)
}
func (controller *AuthController) CheckSmsCode() {
authService := service.AuthService{}
cmd := &command.CheckSmsCodeCommand{}
Must(controller.Unmarshal(cmd))
data, err := authService.CheckSmsCode(cmd)
controller.Response(data, err)
}
func (controller *AuthController) CaptchaInit() {
authService := service.AuthService{}
cmd := &query.CaptchaInitRequest{}
Must(controller.Unmarshal(cmd))
cmd.UserIp = controller.Ctx.Request.RemoteAddr
data, err := authService.CaptchaInit(cmd)
controller.Response(data, err)
}
func (controller *AuthController) CheckModuleAccessCommand() {
authService := service.AuthService{}
cmd := &command.CheckModuleAccessCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.CheckModuleAccess(cmd)
controller.Response(data, err)
}