user_controller.go
1.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
package mobile_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/user/service"
)
type UserController struct {
baseController
}
func (controller *UserController) SendSmsCode() {
authService := service.UserService{}
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 *UserController) CheckSmsCode() {
authService := service.UserService{}
cmd := &command.CheckSmsCodeCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
data, err := authService.CheckSmsCode(cmd)
controller.Response(data, err)
}
func (controller *UserController) ChangePassword() {
authService := service.UserService{}
cmd := &command.ChangePasswordCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.ChangePassword(cmd)
controller.Response(data, err)
}
func (controller *UserController) ChangePhone() {
authService := service.UserService{}
cmd := &command.ResetPhoneCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.ChangePhone(cmd)
controller.Response(data, err)
}
func (controller *UserController) UpdateUserInfo() {
authService := service.UserService{}
cmd := &command.UpdateUserInfoCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.UpdateUserBaseInfo(cmd)
controller.Response(data, err)
}