roles_controller.go 5.0 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"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)

type RolesController struct {
	baseController
}

func (controller *RolesController) RoleAdd() {
	rolesService := service.NewRolesService(nil)
	roleAddCommand := &command.RoleAddCommand{}
	err := controller.Unmarshal(roleAddCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	roleAddCommand.Operator = controller.GetOperator()
	data, err := rolesService.RoleAdd(roleAddCommand)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUpdate() {
	rolesService := service.NewRolesService(nil)
	roleUpdateCommand := &command.RoleUpdateCommand{}
	err := controller.Unmarshal(roleUpdateCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	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{}
	err := controller.Unmarshal(roleListQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	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{}
	err := controller.Unmarshal(roleUserAddQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	roleUserAddQuery.Operator = controller.GetOperator()
	data, err := rolesService.RoleUserAdd(roleUserAddQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleUserDelete() {
	rolesService := service.NewRolesService(nil)
	roleUserDeleteQuery := &command.RoleUserDeleteCommand{}
	err := controller.Unmarshal(roleUserDeleteQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	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()
	err := controller.Unmarshal(roleMenuBeforeEditQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	roleId := controller.GetString(":roleId")
	roleMenuBeforeEditQuery.RoleId = roleId
	data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery)
	controller.Response(data, err)
}

func (controller *RolesController) RoleMenuEdit() {
	rolesService := service.NewRolesService(nil)
	roleMenuEditQuery := &command.RoleMenuEditCommand{}
	err := controller.Unmarshal(roleMenuEditQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	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{}
	err := controller.Unmarshal(roleRemoveCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	roleRemoveCommand.Operator = controller.GetOperator()
	data, err := rolesService.RoleRemove(roleRemoveCommand)
	controller.Response(data, err)
}