auth_controller.go
3.2 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
package mobile_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/auth/service"
)
type AuthController struct {
baseController
}
func (controller *AuthController) Login() {
authService := service.AuthService{}
loginCmd := &command.LoginCommand{}
err := controller.Unmarshal(loginCmd)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.AuthLogin(loginCmd)
controller.Response(data, 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) 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) 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)
}