/**
 * date : 2022. 4. 26.
 * auth : ckr
 * desc : 공통
 */
package kr.co.uplus.ez.api.comm;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import kr.co.uplus.ez.api.comm.dto.AuthResDto;
import kr.co.uplus.ez.api.comm.dto.CodeReqDto;
import kr.co.uplus.ez.api.comm.dto.CodeResDto;
import kr.co.uplus.ez.api.comm.dto.MenuResDto;
import kr.co.uplus.ez.api.comm.dto.RefreshTokenReqDto;
import kr.co.uplus.ez.api.comm.dto.RefreshTokenResDto;

/**
 * 공통관리 Controller.
 *
 * @author rejoice
 *
 */
@RestController
@RequestMapping(value = "api/v1/bo/comm")
public class CommController {

	@Autowired
	CommService commService;

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 메뉴 목록 조회
	 *
	 * @return MenuResDto
	 */
	@ApiOperation(value = "getMenu", notes = "메뉴 목록 조회")
	@ApiResponses({
		@ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS")
	})
	@RequestMapping(value = "/getMenu" , method = {RequestMethod.POST})
	@ResponseBody
	public MenuResDto getMenu() {
		return commService.getMenu();
	}

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 공통 코드 조회
	 *
	 * @param codeReqDto
	 * @return CodeResDto
	 */
	@ApiOperation(value = "getCode", notes = "공통 코드 조회")
	@ApiResponses({
		@ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS")
	})
	@RequestMapping(value = "/getCode" , method = {RequestMethod.POST})
	@ResponseBody
	public CodeResDto getCode(@RequestBody CodeReqDto codeReqDto) {
		return commService.getCode(codeReqDto);
	}

	/**
	 * date : 2022. 4. 26.
	 * auth : ckr
	 * desc : 토큰연장
	 *
	 * @param refreshTokenReqDto
	 * @return RefreshTokenResDto
	 */
	@ApiOperation(value = "refreshToken", notes = "토큰연장")
	@ApiResponses({
		@ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS")
	})
	@RequestMapping(value = "/refreshToken" , method = {RequestMethod.POST})
	@ResponseBody
	public RefreshTokenResDto refreshToken(@RequestBody RefreshTokenReqDto refreshTokenReqDto) {
		return commService.refreshToken(refreshTokenReqDto);
	}

	/**
	 * 권한 코드 조회.
	 *
	 * @return
	 */
	@ApiOperation(value = "getAuth", notes = "권한 코드 조회")
	@ApiResponses({
		@ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS")
	})
	@RequestMapping(value = "/getAuth" , method = {RequestMethod.POST})
	@ResponseBody
	public AuthResDto getAuth() {
		return commService.getAuth();
	}
}