审查视图

pkg/port/beego/controllers/web_client/users_controller.go 7.0 KB
tangxuhui authored
1 2 3
package web_client

import (
4 5
	"strconv"
tangxuhui authored
6 7 8
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/service"
tangxuhui authored
9 10 11
)

type UsersController struct {
tangxuhui authored
12
	baseController
tangxuhui authored
13 14
}
tangxuhui authored
15 16 17 18
func (controller *UsersController) CompanyUserAdd() {
	usersService := service.NewUsersService(nil)
	companyUserAddCommand := &command.CompanyUserAddCommand{}
	controller.Unmarshal(companyUserAddCommand)
tangxuhui authored
19
	companyUserAddCommand.Operator = controller.GetOperator()
tangxuhui authored
20 21 22 23 24 25 26 27
	data, err := usersService.CompanyUserAdd(companyUserAddCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserUpdate() {
	usersService := service.NewUsersService(nil)
	companyUserUpdateCommand := &command.CompanyUserUpdateCommand{}
	controller.Unmarshal(companyUserUpdateCommand)
yangfu authored
28 29 30 31
	if len(companyUserUpdateCommand.UsersId) == 0 {
		userId := controller.GetString(":userId")
		companyUserUpdateCommand.UsersId = userId
	}
tangxuhui authored
32
	companyUserUpdateCommand.Operator = controller.GetOperator()
tangxuhui authored
33 34 35 36 37 38 39
	data, err := usersService.CompanyUserUpdate(companyUserUpdateCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserList() {
	usersService := service.NewUsersService(nil)
	companyUserListQuery := &query.CompanyUserListQuery{}
tangxuhui authored
40
	controller.Unmarshal(companyUserListQuery)
tangxuhui authored
41
	companyUserListQuery.Operator = controller.GetOperator()
tangxuhui authored
42
	cnt, data, err := usersService.CompanyUserList(companyUserListQuery)
yangfu authored
43
	controller.ReturnPageListData(cnt, data, err, companyUserListQuery.PageNumber)
tangxuhui authored
44 45 46 47 48
}

func (controller *UsersController) CompanyUserGet() {
	usersService := service.NewUsersService(nil)
	companyUserGetQuery := &query.CompanyUserGetQuery{}
tangxuhui authored
49
	userId := controller.GetString(":userId")
tangxuhui authored
50
	companyUserGetQuery.UsersId = userId
tangxuhui authored
51
	companyUserGetQuery.Operator = controller.GetOperator()
tangxuhui authored
52 53 54 55 56 57 58 59
	data, err := usersService.CompanyUserGet(companyUserGetQuery)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserEnable() {
	usersService := service.NewUsersService(nil)
	companyUserEnableCommand := &command.CompanyUserEnableCommand{}
	controller.Unmarshal(companyUserEnableCommand)
tangxuhui authored
60
	companyUserEnableCommand.Operator = controller.GetOperator()
tangxuhui authored
61 62 63 64 65 66 67 68
	data, err := usersService.CompanyUserEnable(companyUserEnableCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserResetPassword() {
	usersService := service.NewUsersService(nil)
	companyUserResetPasswordCommand := &command.CompanyUserResetPasswordCommand{}
	controller.Unmarshal(companyUserResetPasswordCommand)
tangxuhui authored
69
	companyUserResetPasswordCommand.Operator = controller.GetOperator()
tangxuhui authored
70 71 72 73 74 75 76 77
	data, err := usersService.CompanyUserResetPassword(companyUserResetPasswordCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserAdd() {
	usersService := service.NewUsersService(nil)
	cooperationUserAddCommand := &command.CooperationUserAddCommand{}
	controller.Unmarshal(cooperationUserAddCommand)
tangxuhui authored
78
	cooperationUserAddCommand.Operator = controller.GetOperator()
tangxuhui authored
79 80 81 82 83 84 85 86
	data, err := usersService.CooperationUserAdd(cooperationUserAddCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserUpdate() {
	usersService := service.NewUsersService(nil)
	cooperationUserUpdateCommand := &command.CooperationUserUpdateCommand{}
	controller.Unmarshal(cooperationUserUpdateCommand)
87 88
	userId := controller.GetString(":userId")
	cooperationUserUpdateCommand.UserId, _ = strconv.ParseInt(userId, 10, 64)
tangxuhui authored
89
	cooperationUserUpdateCommand.Operator = controller.GetOperator()
tangxuhui authored
90 91 92 93 94 95 96
	data, err := usersService.CooperationUserUpdate(cooperationUserUpdateCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserList() {
	usersService := service.NewUsersService(nil)
	cooperationUserListQuery := &query.CooperationUserListQuery{}
tangxuhui authored
97
	controller.Unmarshal(cooperationUserListQuery)
tangxuhui authored
98
	cooperationUserListQuery.Operator = controller.GetOperator()
tangxuhui authored
99
	cnt, data, err := usersService.CooperationUserList(cooperationUserListQuery)
yangfu authored
100
	controller.ReturnPageListData(cnt, data, err, cooperationUserListQuery.PageNumber)
tangxuhui authored
101 102 103 104 105
}

func (controller *UsersController) CooperationUserGet() {
	usersService := service.NewUsersService(nil)
	cooperationUserGetQuery := &query.CooperationUserGetQuery{}
tangxuhui authored
106
	userId := controller.GetString(":userId")
yangfu authored
107
	cooperationUserGetQuery.UserId = userId
tangxuhui authored
108
	cooperationUserGetQuery.Operator = controller.GetOperator()
tangxuhui authored
109 110 111 112 113 114 115 116
	data, err := usersService.CooperationUserGet(cooperationUserGetQuery)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserEnable() {
	usersService := service.NewUsersService(nil)
	cooperationUserEnableCommand := &command.CooperationUserEnableCommand{}
	controller.Unmarshal(cooperationUserEnableCommand)
tangxuhui authored
117
	cooperationUserEnableCommand.Operator = controller.GetOperator()
tangxuhui authored
118 119 120 121 122 123 124 125
	data, err := usersService.CooperationUserEnable(cooperationUserEnableCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserResetPassword() {
	usersService := service.NewUsersService(nil)
	cooperationUserResetPasswordCommand := &command.CooperationUserResetPasswordCommand{}
	controller.Unmarshal(cooperationUserResetPasswordCommand)
tangxuhui authored
126
	cooperationUserResetPasswordCommand.Operator = controller.GetOperator()
tangxuhui authored
127 128 129
	data, err := usersService.CooperationUserResetPassword(cooperationUserResetPasswordCommand)
	controller.Response(data, err)
}
tangxuhui authored
130 131 132 133 134 135 136 137

//CompanyOrgSelector 组织选择表
func (controller *UsersController) SelectorCompanyOrg() {
	usersService := service.NewUsersService(nil)
	selectorQuery := &query.CompanyOrgSelectorQuery{}
	controller.Unmarshal(selectorQuery)
	selectorQuery.Operator = controller.GetOperator()
	cnt, data, err := usersService.SelectorCompanyOrg(selectorQuery)
yangfu authored
138
	controller.ReturnPageListData(cnt, data, err, selectorQuery.PageNumber)
tangxuhui authored
139
}
tangxuhui authored
140 141 142 143 144 145 146 147

//SelectorCompanyRole 角色选择表
func (controller *UsersController) SelectorCompanyRole() {
	usersService := service.NewUsersService(nil)
	selectorQuery := &query.CompanyRoleSelectorQuery{}
	controller.Unmarshal(selectorQuery)
	selectorQuery.Operator = controller.GetOperator()
	cnt, data, err := usersService.SelectorCompanyRole(selectorQuery)
yangfu authored
148
	controller.ReturnPageListData(cnt, data, err, selectorQuery.PageNumber)
tangxuhui authored
149
}
150 151 152 153 154 155 156 157 158 159

//CompanyOrgSelector 全组织部门选择表
func (controller *UsersController) SelectorCompanyOrgAll() {
	usersService := service.NewUsersService(nil)
	selectorQuery := &query.CompanyOrgSelectorQuery{}
	controller.Unmarshal(selectorQuery)
	selectorQuery.Operator = controller.GetOperator()
	_, data, err := usersService.SelectorCompanyOrgAll(selectorQuery)
	controller.Response(data, err)
}
yangfu authored
160 161 162 163 164 165 166 167 168 169

//CompanyOrgSelector 全组织部门选择表
func (controller *UsersController) SelectorCooperationProjectUsers() {
	usersService := service.NewUsersService(nil)
	selectorQuery := &query.CooperationProjectUsersQuery{}
	controller.Unmarshal(selectorQuery)
	selectorQuery.Operator = controller.GetOperator()
	data, err := usersService.SelectorCooperationProjectUsers(selectorQuery)
	controller.Response(data, err)
}