auth_controller.go 1.3 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)
}