package com.style24.admin.support.controller;

import java.util.Collection;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.style24.admin.support.security.session.TsaSession;
import com.style24.core.support.controller.TscBaseController;
import com.style24.persistence.domain.Menu;
import com.style24.persistence.domain.User;

import lombok.extern.slf4j.Slf4j;

/**
 * Controller Advice
 * 
 * @author gagamel
 * @since 2020. 10. 5
 */
@ControllerAdvice
@Slf4j
public class TsaBaseController extends TscBaseController {

	/**
	 * Get 세션 정보
	 * 1.View 단에서 사용법
	 * th:value="${sessionInfo.userId}"
	 * 2.Java 단에서 사용법
	 * super.getSession().getUserId()
	 * 
	 * @return
	 */
	@ModelAttribute("sessionInfo")
	public User getSession() {
		return TsaSession.getInfo();
	}

	/**
	 * Get 로그인 메뉴 목록
	 * 
	 * @return
	 */
	@ModelAttribute("loginMenuList")
	public Collection<Menu> getLoginMenuList() {
		return TsaSession.getLoginMenuList();
	}

}
