package com.yonge.cooleshow.cms.interceptor;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.toolset.log.interceptor.AuditLogInterceptor;

@Component
public class OperationLogInterceptor extends AuditLogInterceptor {

	@Autowired
	@Lazy
	private SysUserFeignService sysUserFeignService;

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException, IOException {
		SysUser sysUser = sysUserFeignService.queryUserInfo();
		if (sysUser != null) {
			setUsername(sysUser.getRealName(),sysUser.getId());
		}
		return true;
	}

}
