auth_controller.go 3.2 KB
package mobile_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/auth/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/auth/service"
)

type AuthController struct {
	baseController
}

func (controller *AuthController) Login() {
	authService := service.AuthService{}
	loginCmd := &command.LoginCommand{}
	err := controller.Unmarshal(loginCmd)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	data, err := authService.AuthLogin(loginCmd)
	controller.Response(data, err)
}

func (controller *AuthController) GetAuthAccessToken() {
	authService := service.AuthService{}
	accessTokenCommand := &command.AccessTokenCommand{}
	err := controller.Unmarshal(accessTokenCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	data, err := authService.GetAuthAccessToken(accessTokenCommand)
	controller.Response(data, err)
}

func (controller *AuthController) RefreshAuthAccessToken() {
	authService := service.AuthService{}
	refreshTokenCmd := &command.RefreshTokenCommand{}
	err := controller.Unmarshal(refreshTokenCmd)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	data, err := authService.RefreshAuthAccessToken(refreshTokenCmd)
	controller.Response(data, err)
}

func (controller *AuthController) GetUserInfo() {
	authService := service.AuthService{}
	userInfoCommand := &command.UserInfoCommand{}
	err := controller.Unmarshal(userInfoCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	userInfoCommand.Operator = controller.GetOperator()
	data, err := authService.GetUserInfo(userInfoCommand)
	controller.Response(data, err)
}

func (controller *AuthController) GetUserMenus() {
	authService := service.AuthService{}
	userMenusCommand := &command.UserMenusCommand{}
	err := controller.Unmarshal(userMenusCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	userMenusCommand.Operator = controller.GetOperator()
	data, err := authService.GetUserMenus(userMenusCommand)
	controller.Response(data, err)
}

func (controller *AuthController) GetUserOrg() {
	authService := service.AuthService{}
	userOrgCommand := &command.UserOrgCommand{}
	err := controller.Unmarshal(userOrgCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	userOrgCommand.Operator = controller.GetOperator()
	data, err := authService.GetUserOrg(userOrgCommand)
	controller.Response(data, err)
}

func (controller *AuthController) CompanySignUp() {
	authService := service.AuthService{}
	userOrgCommand := &command.CompanySignUpCommand{}
	err := controller.Unmarshal(userOrgCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	//userOrgCommand.Operator = controller.GetOperator()
	data, err := authService.CompanySignUp(userOrgCommand)
	controller.Response(data, err)
}

func (controller *AuthController) ResetPassword() {
	authService := service.AuthService{}
	userOrgCommand := &command.ResetPasswordCommand{}
	err := controller.Unmarshal(userOrgCommand)
	if err != nil {
		controller.Response(nil, err)
		return
	}
	//userOrgCommand.Operator = controller.GetOperator()
	data, err := authService.ResetPassword(userOrgCommand)
	controller.Response(data, err)
}