roles_controller.go 4.3 KB
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/roles/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/roles/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/roles/service"
)

type RolesController struct {
	baseController
}

func (controller *RolesController) RoleAdd() {
	rolesService := service.NewRolesService(nil)
	roleAddCommand := &command.RoleAddCommand{}
	controller.Unmarshal(roleAddCommand)
	roleAddCommand.Operator = controller.GetOperator()
	data, err := rolesService.RoleAdd(roleAddCommand)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUpdate() {
	rolesService := service.NewRolesService(nil)
	roleUpdateCommand := &command.RoleUpdateCommand{}
	controller.Unmarshal(roleUpdateCommand)
	roleId := controller.GetString(":roleId")
	roleUpdateCommand.RoleId = roleId
	roleUpdateCommand.Operator = controller.GetOperator()
	data, err := rolesService.RoleEdit(roleUpdateCommand)
	controller.Response(data, err)
}

func (controller *RolesController) RoleList() {
	rolesService := service.NewRolesService(nil)
	roleListQuery := &query.RoleListQuery{}
	controller.Unmarshal(roleListQuery)
	roleListQuery.Operator = controller.GetOperator()
	cnt, data, err := rolesService.RoleList(roleListQuery)
	controller.returnPageListData(cnt, data, err, roleListQuery.PageNumber)
}

func (controller *RolesController) RoleGet() {
	rolesService := service.NewRolesService(nil)
	roleGetQuery := &query.RoleGetQuery{}
	roleId := controller.GetString(":roleId")
	roleGetQuery.RoleId = roleId
	roleGetQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleGet(roleGetQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUserInfo() {
	rolesService := service.NewRolesService(nil)
	roleUserInfoQuery := &query.RoleUserInfoQuery{}
	roleId, _ := controller.GetInt64(":roleId")
	roleUserInfoQuery.RoleId = roleId
	roleUserInfoQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleUserInfo(roleUserInfoQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUserAdd() {
	rolesService := service.NewRolesService(nil)
	roleUserAddQuery := &command.RoleUserAddCommand{}
	controller.Unmarshal(roleUserAddQuery)
	roleUserAddQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleUserAdd(roleUserAddQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUserDelete() {
	rolesService := service.NewRolesService(nil)
	roleUserDeleteQuery := &command.RoleUserDeleteCommand{}
	controller.Unmarshal(roleUserDeleteQuery)
	roleUserDeleteQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleUserDelete(roleUserDeleteQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUserBeforeEdit() {
	rolesService := service.NewRolesService(nil)
	roleUserBeforeEditQuery := &query.RoleUserBeforeEditQuery{}
	roleUserBeforeEditQuery.Operator = controller.GetOperator()
	roleId := controller.GetString("roleId")
	roleUserBeforeEditQuery.RoleId = roleId
	data, err := rolesService.RoleUserBeforeEdit(roleUserBeforeEditQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleMenuBeforeEdit() {
	rolesService := service.NewRolesService(nil)
	roleMenuBeforeEditQuery := &query.RoleMenuBeforeEditQuery{}
	roleMenuBeforeEditQuery.Operator = controller.GetOperator()
	controller.Unmarshal(roleMenuBeforeEditQuery)
	data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleMenuEdit() {
	rolesService := service.NewRolesService(nil)
	roleMenuEditQuery := &command.RoleMenuEditCommand{}
	controller.Unmarshal(roleMenuEditQuery)
	roleId := controller.GetString(":roleId")
	roleMenuEditQuery.RoleId = roleId
	roleMenuEditQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleMenuEdit(roleMenuEditQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleDelete() {
	rolesService := service.NewRolesService(nil)
	roleRemoveCommand := &command.RoleRemoveCommand{}
	controller.Unmarshal(roleRemoveCommand)
	roleRemoveCommand.Operator = controller.GetOperator()
	data, err := rolesService.RoleRemove(roleRemoveCommand)
	controller.Response(data, err)
}