package com.gyee.wisdom.alarm.sharding.config;

import com.gyee.wisdom.common.utils.DateUtil;
import com.gyee.wisdom.common.utils.StringUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Date;

@Data
@Component
@ConfigurationProperties("sharding.config")
public class ConfigProperties {

    //分表开始时间
    private String startDate;

    private Date setupDate;

    public Date getSetupDate() {

        if (setupDate != null)
            return setupDate;

        else {
            try {
                setupDate = DateUtil.parseDate(startDate);
            } catch (Exception ex) {
                setupDate = new Date(2018, 8, 1);
            }
            return setupDate;
        }


    }
}
