/**
 * Copyright (c) 2016-2019 雷掣 All rights reserved.
 *
 * https://www.lc_crm.com
 *
 * 版权所有，侵权必究！
 */

package io.renren.controller;

import io.renren.common.exception.UnauthorizedException;
import io.renren.dto.AppSysUserDTO;
import io.renren.interceptor.ThreadLocalLoginUser;

/**
 * Controller公共组件
 *
 * @author Mark sunlightcs@gmail.com
 */
public abstract class AbstractController {
	
	protected AppSysUserDTO getUser() {
		AppSysUserDTO appSysUser = ThreadLocalLoginUser.get();
		if(null == appSysUser) {
			throw new UnauthorizedException("token失效，请重新登录");
		}
		return appSysUser;
	}

	protected Long getUserId() {
		return getUser().getId();
	}

	protected String getUserName() {
		return getUser().getRealName();
	}
}
