package com.keyware.shandan.dynacmicform.core.db.enums;

import com.keyware.shandan.dynacmicform.core.db.parser.DbDefault;
import com.keyware.shandan.dynacmicform.core.db.pojo.Column;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DbColumns {

    dm((tag)->{
        switch (tag){
            case "input":
            case "password":
            case "select":
            case "radio":
            case "switch":
            case "checkbox":
            case "cron":
                return Column.builder().type("VARCHAR2").length(50).defaultValue("''").build();
            case "textarea":
                return Column.builder().type("TEXT").length(null).defaultValue("''").build();
            case "rate":
            case "slider":
            case "numberInput":
                return Column.builder().type("INTEGER").length(null).build();
            case "date":
                return Column.builder().type("TIMESTAMP").length(6).build();
            default:
                return Column.builder().build();
        }
    }),
    mysql(label -> {
        throw new RuntimeException("暂不支持该数据库");
    });

    private final DbDefault dbDefault;


    public DbDefault getDbDefault() {
        return dbDefault;
    }
}
