user_controller.go 2.8 KB
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)
}