user_controller.go
6.0 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/service"
)
type UserController struct {
beego.BaseController
}
func (controller *UserController) CreateUser() {
userService := service.NewUserService(nil)
createUserCommand := &command.CreateUserCommand{}
Must(controller.Unmarshal(createUserCommand))
createUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.CreateUser(createUserCommand)
controller.Response(data, err)
}
func (controller *UserController) UpdateUser() {
userService := service.NewUserService(nil)
updateUserCommand := &command.UpdateUserCommand{}
Must(controller.Unmarshal(updateUserCommand))
userId, _ := controller.GetInt64(":userId")
updateUserCommand.UserId = userId
updateUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateUser(updateUserCommand)
controller.Response(data, err)
}
func (controller *UserController) GetUser() {
userService := service.NewUserService(nil)
getUserQuery := &query.GetUserQuery{}
userId, _ := controller.GetInt64(":userId")
getUserQuery.UserId = userId
getUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUser(getUserQuery)
controller.Response(data, err)
}
func (controller *UserController) RemoveUser() {
userService := service.NewUserService(nil)
removeUserCommand := &command.RemoveUserCommand{}
controller.Unmarshal(removeUserCommand)
userId, _ := controller.GetInt64(":userId")
removeUserCommand.UserId = userId
removeUserCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.RemoveUser(removeUserCommand)
controller.Response(data, err)
}
func (controller *UserController) ListUser() {
userService := service.NewUserService(nil)
listUserQuery := &query.ListUserQuery{}
listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.ListUser(listUserQuery)
controller.Response(data, err)
}
func (controller *UserController) GetUserAccessMenus() {
userService := service.NewUserService(nil)
getUserAccessMenusQuery := &query.GetUserAccessMenusQuery{}
userId, _ := controller.GetInt64(":userId")
getUserAccessMenusQuery.UserId = userId
menuCategory := controller.GetString("menuCategory")
getUserAccessMenusQuery.MenuCategory = menuCategory
getUserAccessMenusQuery.OrgId, _ = controller.GetInt64("orgId", 0)
getUserAccessMenusQuery.ALLDisableMenu, _ = controller.GetInt("allDisableMenu", 0)
getUserAccessMenusQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUserAccessMenus(getUserAccessMenusQuery)
controller.Response(data, err)
}
func (controller *UserController) GetUserProfile() {
userService := service.NewUserService(nil)
getUserProfileQuery := &query.GetUserProfileQuery{}
userId, _ := controller.GetInt64(":userId")
getUserProfileQuery.UserId = userId
getUserProfileQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.GetUserProfile(getUserProfileQuery)
controller.Response(data, err)
}
func (controller *UserController) BatchAdd() {
userService := service.NewUserService(nil)
batchAddCommand := &command.BatchAddCommand{}
Must(controller.Unmarshal(batchAddCommand))
batchAddCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchAdd(batchAddCommand)
controller.Response(data, err)
}
func (controller *UserController) BatchEnable() {
userService := service.NewUserService(nil)
batchEnableCommand := &command.BatchEnableCommand{}
controller.Unmarshal(batchEnableCommand)
batchEnableCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchEnable(batchEnableCommand)
controller.Response(data, err)
}
func (controller *UserController) BatchResetPassword() {
userService := service.NewUserService(nil)
batchResetPasswordCommand := &command.BatchResetPasswordCommand{}
controller.Unmarshal(batchResetPasswordCommand)
batchResetPasswordCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.BatchResetPassword(batchResetPasswordCommand)
controller.Response(data, err)
}
func (controller *UserController) UpdateUsersBase() {
userService := service.NewUserService(nil)
updateUsersBaseCommand := &command.UpdateUsersBaseCommand{}
controller.Unmarshal(updateUsersBaseCommand)
userId, _ := controller.GetInt64(":userId")
updateUsersBaseCommand.UserId = userId
updateUsersBaseCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateUsersBase(updateUsersBaseCommand)
controller.Response(data, err)
}
func (controller *UserController) CreateCooperator() {
userService := service.NewUserService(nil)
createCooperatorCommand := &command.CreateCooperatorCommand{}
Must(controller.Unmarshal(createCooperatorCommand))
createCooperatorCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.CreateCooperator(createCooperatorCommand)
controller.Response(data, err)
}
func (controller *UserController) UpdateCooperator() {
userService := service.NewUserService(nil)
updateCooperatorCommand := &command.UpdateCooperatorCommand{}
controller.Unmarshal(updateCooperatorCommand)
userId, _ := controller.GetInt64(":userId")
updateCooperatorCommand.UserId = userId
updateCooperatorCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.UpdateCooperator(updateCooperatorCommand)
controller.Response(data, err)
}
func (controller *UserController) SearchUser() {
userService := service.NewUserService(nil)
listUserQuery := &query.ListUserQuery{}
Must(controller.Unmarshal(listUserQuery))
listUserQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := userService.ListUser(listUserQuery)
controller.Response(data, err)
}