package com.tykj.model.create_util;

import com.tykj.base.result.ApiException;
import com.tykj.model.entity.vo.ColumnVO;
import com.tykj.model.entity.vo.TableVO;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author huangjiafu
 * @version V1.0
 * @data 2021/7/15 10:43
 **/
public class MysqlCreateTableUtil extends BaseCreateUtil {

    @Override
    String addGenerator(TableVO tableVO) {
        String result = "";
        result += " <id name=\"ID\" type=\"java.lang.Integer\" length=\"11\" unsaved-value=\"null\"  >\n" +
                "  <generator  class=\"increment\"  >\n" +
                "</generator>" +
                "        </id>\n";
        return result;
    }

    @Override
    String addDefaultTime(TableVO tableVO) {
        String result = "";
        result+=" <property name =\"CREATE_TIME\" type =\"java.util.Date\" generated=\"always\"   insert=\"false\" update=\"false\" access=\"field\" >" +
                "<column name=\"CREATE_TIME\" sql-type=\"timestamp\" not-null=\"true\" default=\"CURRENT_TIMESTAMP\" />\n"+
                "</property> " ;

        result+=" <property name =\"UPDATE_TIME\" type =\"java.util.Date\" generated=\"always\"  insert=\"false\" update=\"false\" access=\"field\" >" +
                "<column name=\"UPDATE_TIME\" sql-type=\"timestamp\" default=\"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\" />\n"+
                "</property> " ;
        return result;

    }
}
