package com.ff.quartz.task;

import com.ff.base.datasource.DynamicDataSourceContextHolder;
import com.ff.base.utils.StringUtils;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.util.Map;

/**
 * 定时任务调度测试
 *
 * @author ff
 */
@Component("ryTask")
public class RyTask {
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
        Map<Object, DataSource> resolvedDataSources = DynamicDataSourceContextHolder.getAllDataSource();
        for (Map.Entry<Object, DataSource> entry : resolvedDataSources.entrySet()) {
            Object key = entry.getKey();
            // 设置数据源类型
            DynamicDataSourceContextHolder.setDataSourceType(key.toString());
            System.out.println("执行无参方法");
        }
    }
}
