auth_controller.go
2.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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/application/auth/query"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/application/auth/service"
)
type AuthController struct {
beego.BaseController
}
func (controller *AuthController) Login() {
authService := service.NewAuthService(nil)
loginQuery := &query.LoginQuery{}
controller.Unmarshal(loginQuery)
data, err := authService.Login(loginQuery)
controller.Response(data, err)
}
func (controller *AuthController) LoginByCompany() {
authService := service.NewAuthService(nil)
loginByCompanyCommand := &command.LoginByCompanyCommand{}
controller.Unmarshal(loginByCompanyCommand)
data, err := authService.LoginByCompany(loginByCompanyCommand)
controller.Response(data, err)
}
func (controller *AuthController) AccessToken() {
authService := service.NewAuthService(nil)
accessTokenCommand := &command.AccessTokenCommand{}
controller.Unmarshal(accessTokenCommand)
data, err := authService.AccessToken(accessTokenCommand)
controller.Response(data, err)
}
func (controller *AuthController) RefreshToken() {
authService := service.NewAuthService(nil)
refreshTokenCommand := &command.RefreshTokenCommand{}
controller.Unmarshal(refreshTokenCommand)
data, err := authService.RefreshToken(refreshTokenCommand)
controller.Response(data, err)
}
func (controller *AuthController) SendSmsCode() {
authService := service.NewAuthService(nil)
sendSmsCodeCommand := &command.SendSmsCodeCommand{}
controller.Unmarshal(sendSmsCodeCommand)
data, err := authService.SendSmsCode(sendSmsCodeCommand)
controller.Response(data, err)
}
func (controller *AuthController) Revoke() {
authService := service.NewAuthService(nil)
revokeCommand := &command.RevokeCommand{}
controller.Unmarshal(revokeCommand)
data, err := authService.Revoke(revokeCommand)
controller.Response(data, err)
}
func (controller *AuthController) ChangePassword() {
authService := service.NewAuthService(nil)
changePasswordCommand := &command.ChangePasswordCommand{}
controller.Unmarshal(changePasswordCommand)
data, err := authService.ChangePassword(changePasswordCommand)
controller.Response(data, err)
}