package org.jeecg.modules.system.service;

import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author liushuai
 * @create 2022-03-10 19:11
 */
@Service
@Slf4j
public class AsyncService {
    @Resource
    private ISysUserService sysUserService;
    @Async("myAsync")
    public void async(SysUser sysUser)  {
        try {
            Thread.sleep(3600000);
            sysUser.setOpePassword("123");
            log.info(sysUser.getUsername());
            sysUserService.updateById(sysUser);
            StpUtil.logout(sysUser.getId());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
