package com.style24.scm.support.controller;

import java.util.Collection;

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

import com.style24.core.support.controller.TscBaseController;
import com.style24.persistence.domain.Menu;
import com.style24.persistence.domain.User;
import com.style24.scm.support.security.session.TssSession;

import lombok.extern.slf4j.Slf4j;

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

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

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

}
