package com.jiayue.ssi.config;

import com.jiayue.ssi.entity.SysUser;
import com.jiayue.ssi.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;


/**
 * 程序启动做些事情
 *
 * @author xsl
 * @version 3.0
 */
@Configuration
@Slf4j
public class StartDoSomethingConfig {

    @Autowired
    SysUserService sysUserService;

    /**
     * 将所有用户在线状态设置为“离线”
     */
    @Bean
    public void setOffLine() {
        List<SysUser> userList = sysUserService.list();
        for (SysUser sysUser:userList){
            sysUser.setOnlineStatus("1");
        }
        sysUserService.saveOrUpdateBatch(userList);
    }
}
