package com.tofly.auth.oauth;

import com.tofly.auth.feign.BaseUserLoginService;
import com.tofly.common.core.constant.SecurityConstants;
import com.tofly.entity.pojo.User;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * @author tuonbed
 * @date 2019/11/4  11:00
 */
@Slf4j
@AllArgsConstructor
public class UserLoginListener {
    private BaseUserLoginService baseUserLoginService;

    @Async
    @Order
    @EventListener(UserLoginEvent.class)
    public void saveSysLog(UserLoginEvent event) {
        User user = (User) event.getSource();
        log.info("baseUserService:{}",baseUserLoginService);
        baseUserLoginService.updateUserInfo(user,SecurityConstants.FROM_IN);
    }
}
