UserUtils.java 1004 Bytes
package com.glsx.common.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.glsx.common.constants.Constants;


/**
 * 
 * @Title UserUtils.java
 * @Package com.glsx.common.utils
 * @Description TODO 获取当前用户工具类
 * @author zhanghj
 * @date 2019年2月12日 上午11:35:30
 * @version 1.0.0
 */
public class UserUtils {

	private static final Logger LOGGER = LoggerFactory.getLogger(UserUtils.class.getName());

	
	public static String getUserName(HttpServletRequest request) {
		HttpSession session = request.getSession();
		String username = (String) session.getAttribute(Constants.SESSION_USERNAME_KEY);
		return username;
	}
	
	public static Integer getUserId(HttpServletRequest request) {
		HttpSession session = request.getSession();
		Integer userId = (Integer)session.getAttribute(Constants.SESSION_USERID_KEY);
		return userId;
	}
}