user_controller.go
3.5 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
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/query"
"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)
}
func (controller *UserController) DestroyAccount() {
authService := service.UserService{}
cmd := &command.DestroyAccountCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.DestroyAccount(cmd)
controller.Response(data, err)
}
func (controller *UserController) DepartmentUsers() {
orgService := service.UserService{}
departmentsUsersQuery := &query.DepartmentsUsersQuery{}
err := controller.Unmarshal(departmentsUsersQuery)
if err != nil {
controller.Response(nil, err)
return
}
departmentsUsersQuery.Operator = controller.GetOperator()
data, err := orgService.DepartmentsUsers(departmentsUsersQuery)
controller.Response(data, err)
}
func (controller *UserController) Messages() {
svr := service.UserService{}
messagesListQuery := &query.MessagesListQuery{}
err := controller.Unmarshal(messagesListQuery)
if err != nil {
controller.Response(nil, err)
return
}
messagesListQuery.Operator = controller.GetOperator()
total, data, err := svr.MessagesList(messagesListQuery)
controller.ReturnPageListData(total, data, err, messagesListQuery.PageNumber)
}
func (controller *UserController) MessagesMarkRead() {
svr := service.UserService{}
cmd := &command.MessageMarkReadCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.MessagesMarkRead(cmd)
controller.Response(data, err)
}