users_controller.go 4.3 KB
package web_client

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/service"
)

type UsersController struct {
	beego.BaseController
}

func (controller *UsersController) CompanyUserAdd() {
	usersService := service.NewUsersService(nil)
	companyUserAddCommand := &command.CompanyUserAddCommand{}
	controller.Unmarshal(companyUserAddCommand)
	data, err := usersService.CompanyUserAdd(companyUserAddCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserUpdate() {
	usersService := service.NewUsersService(nil)
	companyUserUpdateCommand := &command.CompanyUserUpdateCommand{}
	controller.Unmarshal(companyUserUpdateCommand)
	data, err := usersService.CompanyUserUpdate(companyUserUpdateCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserList() {
	usersService := service.NewUsersService(nil)
	companyUserListQuery := &query.CompanyUserListQuery{}
	cnt, data, err := usersService.CompanyUserList(companyUserListQuery)
	_ = cnt
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserGet() {
	usersService := service.NewUsersService(nil)
	companyUserGetQuery := &query.CompanyUserGetQuery{}
	userId, _ := controller.GetInt64(":userId")
	companyUserGetQuery.UsersId = userId
	data, err := usersService.CompanyUserGet(companyUserGetQuery)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserEnable() {
	usersService := service.NewUsersService(nil)
	companyUserEnableCommand := &command.CompanyUserEnableCommand{}
	controller.Unmarshal(companyUserEnableCommand)
	data, err := usersService.CompanyUserEnable(companyUserEnableCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CompanyUserResetPassword() {
	usersService := service.NewUsersService(nil)
	companyUserResetPasswordCommand := &command.CompanyUserResetPasswordCommand{}
	controller.Unmarshal(companyUserResetPasswordCommand)
	data, err := usersService.CompanyUserResetPassword(companyUserResetPasswordCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserAdd() {
	usersService := service.NewUsersService(nil)
	cooperationUserAddCommand := &command.CooperationUserAddCommand{}
	controller.Unmarshal(cooperationUserAddCommand)
	data, err := usersService.CooperationUserAdd(cooperationUserAddCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserUpdate() {
	usersService := service.NewUsersService(nil)
	cooperationUserUpdateCommand := &command.CooperationUserUpdateCommand{}
	controller.Unmarshal(cooperationUserUpdateCommand)
	data, err := usersService.CooperationUserUpdate(cooperationUserUpdateCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserList() {
	usersService := service.NewUsersService(nil)
	cooperationUserListQuery := &query.CooperationUserListQuery{}
	cnt, data, err := usersService.CooperationUserList(cooperationUserListQuery)
	_ = cnt
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserGet() {
	usersService := service.NewUsersService(nil)
	cooperationUserGetQuery := &query.CooperationUserGetQuery{}
	userId, _ := controller.GetInt64(":userId")
	cooperationUserGetQuery.UsersId = userId
	data, err := usersService.CooperationUserGet(cooperationUserGetQuery)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserEnable() {
	usersService := service.NewUsersService(nil)
	cooperationUserEnableCommand := &command.CooperationUserEnableCommand{}
	controller.Unmarshal(cooperationUserEnableCommand)
	data, err := usersService.CooperationUserEnable(cooperationUserEnableCommand)
	controller.Response(data, err)
}

func (controller *UsersController) CooperationUserResetPassword() {
	usersService := service.NewUsersService(nil)
	cooperationUserResetPasswordCommand := &command.CooperationUserResetPasswordCommand{}
	controller.Unmarshal(cooperationUserResetPasswordCommand)
	data, err := usersService.CooperationUserResetPassword(cooperationUserResetPasswordCommand)
	controller.Response(data, err)
}