package com.td.Dawa.util;

import com.td.Dawa.sys.syssettingtask.vo.SysSettingTaskVo;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 系统设置工具类
 * 系统启动时获取数据库数据，设置到公用静态集合sysSettingMap
 * 更新系统设置时同步更新公用静态集合sysSettingMap
 */
public class SysSettingTaskUtil {

    //使用线程安全的ConcurrentHashMap来存储系统设置
    private static ConcurrentHashMap<String, SysSettingTaskVo> sysSettingTaskMap = new ConcurrentHashMap<>();

    //从公用静态集合sysSettingTaskMap获取系统设置
    public static SysSettingTaskVo getSysSettingTask(){
        return sysSettingTaskMap.get("sysSettingTask");
    }

    //更新公用静态集合sysSettingTaskMap
    public static void setSysSettingTaskMap(SysSettingTaskVo sysSettingTaskVo){
        if(sysSettingTaskMap.isEmpty()){
            sysSettingTaskMap.put("sysSettingTask",sysSettingTaskVo);
        }else{
            sysSettingTaskMap.replace("sysSettingTask",sysSettingTaskVo);
        }
    }
}
