user_controller.go
2.8 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
package backgroud_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
type UserController struct {
controllers.BaseController
}
func (controller *UserController) SearchUser() {
companyService := service.NewUserService(nil)
listCompanyQuery := &query.ListUserQuery{}
controller.Unmarshal(listCompanyQuery)
cnt, data, err := companyService.SearchUser(listCompanyQuery)
controller.ReturnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
}
func (controller *UserController) EnableUser() {
companyService := service.NewUserService(nil)
cmd := &command.EnableUserCommand{}
controller.Unmarshal(cmd)
data, err := companyService.EnableUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) ResetPassword() {
companyService := service.NewUserService(nil)
cmd := &command.ResetPasswordCommand{}
controller.Unmarshal(cmd)
data, err := companyService.ResetPassword(cmd)
controller.Response(data, err)
}
func (controller *UserController) SearchAdminUser() {
companyService := service.NewUserService(nil)
q := &query.ListAdminUserQuery{}
controller.Unmarshal(q)
cnt, data, err := companyService.AdminUserList(q)
controller.ReturnPageListData(cnt, data, err, q.PageNumber)
}
func (controller *UserController) EnableAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.EnableAdminUserCommand{}
controller.Unmarshal(cmd)
data, err := companyService.EnableAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) GetAdminUser() {
companyService := service.NewUserService(nil)
userId, _ := controller.GetInt(":userId")
data, err := companyService.GetAdminUser(userId)
controller.Response(data, err)
}
func (controller *UserController) UpdateAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.AdminUserEditCommand{}
controller.Unmarshal(cmd)
userId, _ := controller.GetInt(":userId")
cmd.UserId = int64(userId)
data, err := companyService.UpdateAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) CreateAdminUser() {
companyService := service.NewUserService(nil)
cmd := &command.AdminUserAddCommand{}
controller.Unmarshal(cmd)
data, err := companyService.CreateAdminUser(cmd)
controller.Response(data, err)
}
func (controller *UserController) GetAdminUserInfo() {
companyService := service.NewUserService(nil)
operator := controller.GetOperator()
data, err := companyService.GetAdminUserInfo(operator)
controller.Response(data, err)
}