package ink.wgink.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: TransactionProperties
 * @Description: 事务
 * @Author: WangGeng
 * @Date: 2021/1/24 19:13
 * @Version: 1.0
 **/
@Component
@ConfigurationProperties(prefix = "transaction")
public class TransactionProperties {

    private List<String> saveList;
    private List<String> removeList;
    private List<String> updateList;
    private List<String> otherList;
    private List<String> queryList;

    public List<String> getSaveList() {
        if (saveList == null) {
            return new ArrayList<>();
        }
        return saveList;
    }

    public void setSaveList(List<String> saveList) {
        this.saveList = saveList;
    }

    public List<String> getRemoveList() {
        if (removeList == null) {
            return new ArrayList<>();
        }
        return removeList;
    }

    public void setRemoveList(List<String> removeList) {
        this.removeList = removeList;
    }

    public List<String> getUpdateList() {
        if (updateList == null) {
            return new ArrayList<>();
        }
        return updateList;
    }

    public void setUpdateList(List<String> updateList) {
        this.updateList = updateList;
    }

    public List<String> getOtherList() {
        if (otherList == null) {
            return new ArrayList<>();
        }
        return otherList;
    }

    public void setOtherList(List<String> otherList) {
        this.otherList = otherList;
    }

    public List<String> getQueryList() {
        if (queryList == null) {
            return new ArrayList<>();
        }
        return queryList;
    }

    public void setQueryList(List<String> queryList) {
        this.queryList = queryList;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"saveList\":")
                .append(saveList);
        sb.append(",\"removeList\":")
                .append(removeList);
        sb.append(",\"updateList\":")
                .append(updateList);
        sb.append(",\"otherList\":")
                .append(otherList);
        sb.append(",\"queryList\":")
                .append(queryList);
        sb.append('}');
        return sb.toString();
    }
}
