All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mybatis.generator.api.plus.MybatisUtilCommon Maven / Gradle / Ivy

The newest version!
package org.mybatis.generator.api.plus;

import com.alibaba.fastjson.JSON;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author wangfupeng
 */
public class MybatisUtilCommon {

    public static Random random = new Random();

    public static Integer COLUMN_FIELD_LENGTH = 2000;

    private static FullyQualifiedJavaType stringType;
    private static FullyQualifiedJavaType integerType;
    private static FullyQualifiedJavaType booleanType;
    private static FullyQualifiedJavaType byteType;
    private static FullyQualifiedJavaType doubleType;
    private static FullyQualifiedJavaType floatType;
    private static FullyQualifiedJavaType longType;
    private static FullyQualifiedJavaType shortType;
    private static FullyQualifiedJavaType bigDecimalType;
    private static FullyQualifiedJavaType dateType;
    private static FullyQualifiedJavaType characterType;

    static {
        stringType = new FullyQualifiedJavaType("java.lang.String");
        integerType = new FullyQualifiedJavaType("java.lang.Integer");
        booleanType = new FullyQualifiedJavaType("java.lang.Boolean");
        byteType = new FullyQualifiedJavaType("java.lang.Byte");
        doubleType = new FullyQualifiedJavaType("java.lang.Double");
        floatType = new FullyQualifiedJavaType("java.lang.Float");
        longType = new FullyQualifiedJavaType("java.lang.Long");
        shortType = new FullyQualifiedJavaType("java.lang.Short");
        bigDecimalType = new FullyQualifiedJavaType("java.lang.BigDecimal");
        dateType = new FullyQualifiedJavaType("java.util.Date");
        characterType = new FullyQualifiedJavaType("java.lang.Character");
    }

    public static String toLowerCaseAtFirstCharacter(String tableName) {
        StringBuilder sb = new StringBuilder(tableName);
        sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
        return sb.toString();
    }

    public static String toUpperCaseAtFirstCharacter(String tableName) {
        StringBuilder sb = new StringBuilder(tableName);
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        return sb.toString();
    }

    public static void addParameterForPrimaryKeyColumnsInMethodSelectByPrimaryKey(Method method, IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (fullyQualifiedJavaType.isPrimitive()) {
                    if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(booleanType, columnName));
                    } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(byteType, columnName));
                    } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(doubleType, columnName));
                    } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(floatType, columnName));
                    } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(integerType, columnName));
                    } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(longType, columnName));
                    } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(shortType, columnName));
                    } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(characterType, columnName));
                    }
                } else if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(booleanType, columnName));
                } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(byteType, columnName));
                } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(doubleType, columnName));
                } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(integerType, columnName));
                } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(longType, columnName));
                } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(shortType, columnName));
                } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(bigDecimalType, columnName));
                } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(dateType, columnName));
                } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(stringType, columnName));
                }
            }
        }
    }

    public static String getParameterWithAnnotationForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String parameter = "";
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (fullyQualifiedJavaType.isPrimitive()) {
                    if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Boolean " + columnName + ",";
                    } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")  Byte " + columnName + ",";
                    } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Double " + columnName + ",";
                    } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Float " + columnName + ",";
                    } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Integer " + columnName + ",";
                    } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Long " + columnName + ",";
                    } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Short " + columnName + ",";
                    } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Character " + columnName + ",";
                    }
                } else if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Boolean " + columnName + ",";
                } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Byte " + columnName + ",";
                } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Double " + columnName + ",";
                } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Integer " + columnName + ",";
                } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Long " + columnName + ",";
                } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Short " + columnName + ",";
                } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") BigDecimal " + columnName + ",";
                } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") Date " + columnName + ",";
                } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\") String " + columnName + ",";
                }
            }
        }
        return parameter.substring(0, parameter.length() - 1);
    }


    public static String getParameterWithoutAnnotationForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String parameter = "";
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (fullyQualifiedJavaType.isPrimitive()) {
                    if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Boolean " + columnName + ",";
                    } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Byte " + columnName + ",";
                    } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Double " + columnName + ",";
                    } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Float " + columnName + ",";
                    } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Integer " + columnName + ",";
                    } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Long " + columnName + ",";
                    } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Short " + columnName + ",";
                    } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        parameter = parameter + " Character " + columnName + ",";
                    }
                } else if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Boolean " + columnName + ",";
                } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Byte " + columnName + ",";
                } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Double " + columnName + ",";
                } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Integer " + columnName + ",";
                } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Long " + columnName + ",";
                } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Short " + columnName + ",";
                } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " BigDecimal " + columnName + ",";
                } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " Date " + columnName + ",";
                } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    parameter = parameter + " String " + columnName + ",";
                }
            }
        }
        return parameter.substring(0, parameter.length() - 1);
    }

    public static String getParameterWithoutAnnotationWithoutTypeForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String parameter = "";
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                parameter = parameter.equals("") ? columnName : parameter + ", " + columnName;
            }
        }
        return parameter.substring(0, parameter.length() - 1);
    }


    public static void addParameterWithAnnotationForPrimaryKeyColumnsInMethodSelectByPrimaryKey(Method method, IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (fullyQualifiedJavaType.isPrimitive()) {
                    if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(booleanType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(byteType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(doubleType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(floatType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(integerType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(longType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(shortType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addParameter(new Parameter(characterType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                    }
                } else if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(booleanType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(byteType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(doubleType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(integerType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(longType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(shortType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(bigDecimalType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(dateType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                    method.addParameter(new Parameter(stringType, columnName, " @ApiParam(value = \"" + columnName + "\") @PathVariable(value=\"" + columnName + "\")"));
                }
            }
        }
    }

    public static boolean getExistNonePrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        List introspectedColumnsAll = introspectedTable.getAllColumns();
        if (introspectedColumns.size() == introspectedColumnsAll.size()) {
            return false;
        }
        return true;
    }


    public static String getPathParameterForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String pathString = "";
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                pathString += "\"/\"+getUrlSplit(\"" + toLowerCaseAtFirstCharacter(introspectedTable.getFullyQualifiedTable().getDomainObjectName()) + "" + toUpperCaseAtFirstCharacter(columnName) + "=\")";
            }
        }
        return pathString;
    }

    public static String getPathForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String pathString = "";
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                pathString += "/{" + columnName + "}";
            }
        }
        return pathString;
    }

    public static String getParameterValueForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String pathString = "";
        boolean isFirstParameter = true;
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (isFirstParameter) {
                    pathString += columnName;
                    isFirstParameter = false;
                } else {
                    pathString += ", " + columnName;
                }
            }
        }
        return pathString;
    }

    public static String getParameterWithModelPointValueForPrimaryKeyColumns(IntrospectedTable introspectedTable, String modelName) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String pathString = "";
        boolean isFirstParameter = true;
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (isFirstParameter) {
                    pathString += modelName + ".get" + toUpperCaseAtFirstCharacter(columnName) + "()";
                    isFirstParameter = false;
                } else {
                    pathString += ", " + modelName + ".get" + toUpperCaseAtFirstCharacter(columnName) + "()";
                }
            }
        }
        return pathString;
    }


    public static String getParameterTypeAndValueForPrimaryKeyColumns(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getPrimaryKeyColumns();
        Iterator iterator = introspectedColumns.iterator();
        String pathString = "";
        boolean isFirstParameter = true;
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (isFirstParameter) {
                    pathString += introspectedColumn.getFullyQualifiedJavaType() + " " + columnName;
                    isFirstParameter = false;
                } else {
                    pathString += ", " + introspectedColumn.getFullyQualifiedJavaType() + " " + columnName;
                }
            }
        }
        return pathString;
    }


    public static void addParameterForColumnsWithMaxMinPrefixSuffixLike(Method method, IntrospectedTable introspectedTable) {
//        if(introspectedTable.getFullyQualifiedTable().getIntrospectedTableName().equals(""))
        List introspectedColumns;
        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
            introspectedColumns = introspectedTable.getNonBLOBColumns();
        } else {
            introspectedColumns = introspectedTable.getAllColumns();
        }
        Iterator iterator = introspectedColumns.iterator();
        List columnNames = new ArrayList<>();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                        .getFullyQualifiedJavaType();
                String columnName = introspectedColumn.getJavaProperty();
                if (columnNames.contains(columnName)) {
                } else {
                    columnNames.add(columnName);
                    if (fullyQualifiedJavaType.isPrimitive()) {
                        if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(booleanType, columnName, " @ApiParam(value = \"" + columnName
                                    + "=true/false\") @RequestParam(value = \"" + columnName + "\", required = false)"));
                        } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(characterType, columnName, " @ApiParam(value = \"" + columnName
                                    + "=此值\") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(characterType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(byteType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(doubleType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(floatType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(integerType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(longType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(shortType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        }
                    } else {
                        if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(booleanType, columnName, " @ApiParam(value = \"" + columnName
                                    + "=true/false\") @RequestParam(value = \"" + columnName + "\", required = false)"));
                        } else if ("java.lang.Character".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(characterType, columnName, " @ApiParam(value = \"" + columnName
                                    + "=此值\") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(characterType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(byteType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(byteType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(doubleType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(doubleType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(floatType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(floatType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(integerType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(integerType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(longType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(longType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(shortType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(shortType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(bigDecimalType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(bigDecimalType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(bigDecimalType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(bigDecimalType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(dateType, columnName + "_max", " @ApiParam(value = \"" + columnName
                                    + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false)"));
                            method.addParameter(new Parameter(dateType, columnName + "_min", " @ApiParam(value = \"" + columnName
                                    + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false)"));
                            method.addParameter(new Parameter(dateType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(dateType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            method.addParameter(new Parameter(stringType, columnName + "_prefix", " @ApiParam(value = \"" + columnName
                                    + " like '%此值' \") @RequestParam(value = \"" + columnName + "_prefix\", required = false)"));
                            method.addParameter(new Parameter(stringType, columnName + "_suffix", " @ApiParam(value = \"" + columnName
                                    + " like '此值%' \") @RequestParam(value = \"" + columnName + "_suffix\", required = false)"));
                            method.addParameter(new Parameter(stringType, columnName + "_like", " @ApiParam(value = \"" + columnName
                                    + " like '%此值%' \") @RequestParam(value = \"" + columnName + "_like\", required = false)"));
                            method.addParameter(new Parameter(stringType, columnName + "", " @ApiParam(value = \"" + columnName
                                    + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false)"));
                            method.addParameter(new Parameter(stringType, columnName + "_not", " @ApiParam(value = \"" + columnName
                                    + "!=此值\") @RequestParam(value = \"" + columnName + "_not\", required = false)"));
                        }
                    }
                }
            }
        }
    }

    public static String getParameterWithAnnotationForColumnsWithMaxMinPrefixSuffixLike(IntrospectedTable introspectedTable) {
        String parameter = "";
        List introspectedColumns;
        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
            introspectedColumns = introspectedTable.getNonBLOBColumns();
        } else {
            introspectedColumns = introspectedTable.getAllColumns();
        }
        Iterator iterator = introspectedColumns.iterator();
        List columnNames = new ArrayList<>();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                        .getFullyQualifiedJavaType();
                String columnName = introspectedColumn.getJavaProperty();
                if (columnNames.contains(columnName)) {
                } else {
                    columnNames.add(columnName);
                    if (fullyQualifiedJavaType.isPrimitive()) {
                        if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + "=true/false\") @RequestParam(value = \"" + columnName + "\", required = false) Boolean " + columnName + ",\n";
                        } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + "=此值\") @RequestParam(value = \"" + columnName + "\", required = false) Character " + columnName + ",\n";
                        } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Byte");
                        } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Double");
                        } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Float");
                        } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Integer");
                        } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Long");
                        } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Short");
                        }
                    } else {
                        if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + "=true/false\") @RequestParam(value = \"" + columnName + "\", required = false) Boolean " + columnName + ",\n";
                        } else if ("java.lang.Character".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + "=此值\") @RequestParam(value = \"" + columnName + "\", required = false) Character " + columnName + ",\n";
                        } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Byte");
                        } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Double");
                        } else if ("java.lang.Float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Float");
                        } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Integer");
                        } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Long");
                        } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Short");
                        } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "BigDecimal");
                        } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterForSpecialType(columnName, "Date");
                        } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + " like '%此值' \") @RequestParam(value = \"" + columnName + "_prefix\", required = false) String " + columnName + "_prefix,\n";
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + " like '此值%' \") @RequestParam(value = \"" + columnName + "_suffix\", required = false) String " + columnName + "_suffix,\n";
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + " like '%此值%' \") @RequestParam(value = \"" + columnName + "_like\", required = false) String " + columnName + "_like,\n";
                            parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                                    + " =此值 \") @RequestParam(value = \"" + columnName + "\", required = false) String " + columnName + ",\n";
                        }
                    }
                }
            }
        }
        return parameter.substring(0, parameter.length() - 2);
    }

    public static String addParameterForSpecialType(String columnName, String type) {
        String parameter = "";
        parameter = parameter + " @ApiParam(value = \"" + columnName
                + "<=此值 \") @RequestParam(value = \"" + columnName + "_max\", required = false) " + type + " " + columnName + "_max" + ",\n";
        parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                + ">=此值 \") @RequestParam(value = \"" + columnName + "_min\", required = false) " + type + " " + columnName + "_min" + ",\n";
        parameter = parameter + "                             " + " @ApiParam(value = \"" + columnName
                + "=此值 \") @RequestParam(value = \"" + columnName + "\", required = false) " + type + " " + columnName + ",\n";
        return parameter;
    }

    public static String getParameterWithoutAnnotationForColumnsWithMaxMinPrefixSuffixLike(IntrospectedTable introspectedTable) {
        String parameter = "";
        List introspectedColumns;
        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
            introspectedColumns = introspectedTable.getNonBLOBColumns();
        } else {
            introspectedColumns = introspectedTable.getAllColumns();
        }
        Iterator iterator = introspectedColumns.iterator();
        List columnNames = new ArrayList<>();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                        .getFullyQualifiedJavaType();
                String columnName = introspectedColumn.getJavaProperty();
                if (columnNames.contains(columnName)) {
                } else {
                    columnNames.add(columnName);
                    if (fullyQualifiedJavaType.isPrimitive()) {
                        if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " Boolean " + columnName + ",\n";
                        } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " Character " + columnName + ",\n";
                        } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Byte");
                        } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Double");
                        } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Float");
                        } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Integer");
                        } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Long");
                        } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Short");
                        }
                    } else {
                        if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " Boolean " + columnName + ",\n";
                        } else if ("java.lang.Character".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " Character " + columnName + ",\n";
                        } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Byte");
                        } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Double");
                        } else if ("java.lang.Float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Float");
                        } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Integer");
                        } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Long");
                        } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Short");
                        } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "BigDecimal");
                        } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + addParameterWithoutAnnotationForSpecialType(columnName, "Date");
                        } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "                             " + " String " + columnName + "_prefix,\n";
                            parameter = parameter + "                             " + " String " + columnName + "_suffix,\n";
                            parameter = parameter + "                             " + " String " + columnName + "_like,\n";
                            parameter = parameter + "                             " + " String " + columnName + ",\n";
                        }
                    }
                }
            }
        }
        return parameter.substring(0, parameter.length() - 2);
    }

    public static String addParameterWithoutAnnotationForSpecialType(String columnName, String type) {
        String parameter = "";
        parameter = parameter + " " + type + " " + columnName + "_max" + ",\n";
        parameter = parameter + "                              " + type + " " + columnName + "_min" + ",\n";
        parameter = parameter + "                              " + type + " " + columnName + ",\n";
        return parameter;
    }

    public static String getParameterWithoutAnnotationWithoutTypeForColumnsWithMaxMinPrefixSuffixLike(IntrospectedTable introspectedTable) {
        String parameter = "";
        List introspectedColumns;
        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
            introspectedColumns = introspectedTable.getNonBLOBColumns();
        } else {
            introspectedColumns = introspectedTable.getAllColumns();
        }
        Iterator iterator = introspectedColumns.iterator();
        List columnNames = new ArrayList<>();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                        .getFullyQualifiedJavaType();
                String columnName = introspectedColumn.getJavaProperty();
                if (columnNames.contains(columnName)) {
                } else {
                    columnNames.add(columnName);
                    if (fullyQualifiedJavaType.isPrimitive()) {
                        if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + " " + columnName + ",\n";
                        } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + " " + columnName + ",\n";
                        } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("int".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        }
                    } else {
                        if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + " " + columnName + ",\n";
                        } else if ("java.lang.Character".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + " " + columnName + ",\n";
                        } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.Float".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + addParameterWithoutAnnotationWithoutTypeForSpecialType(columnName);
                        } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                            parameter = parameter + "               " + " " + columnName + "_prefix,\n";
                            parameter = parameter + "               " + " " + columnName + "_suffix,\n";
                            parameter = parameter + "               " + " " + columnName + "_like,\n";
                            parameter = parameter + "               " + " " + columnName + ",\n";
                        }
                    }
                }
            }
        }
        return parameter.substring(0, parameter.length() - 2);
    }

    public static String addParameterWithoutAnnotationWithoutTypeForSpecialType(String columnName) {
        String parameter = "";
        parameter = parameter + " " + columnName + "_max" + ",\n";
        parameter = parameter + "                " + columnName + "_min" + ",\n";
        parameter = parameter + "                " + columnName + ",\n";
        return parameter;
    }

    public static void addCriteriaForColumnsInMethod(Method method, IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getAllColumns();
        Iterator iterator = introspectedColumns.iterator();
        while (iterator.hasNext()) {
            IntrospectedColumn introspectedColumn = iterator.next();
            FullyQualifiedJavaType fullyQualifiedJavaType = introspectedColumn
                    .getFullyQualifiedJavaType();
            String columnName = introspectedColumn.getJavaProperty();
            if (introspectedColumn.isBLOBColumn()) {
            } else {
                if (fullyQualifiedJavaType.isPrimitive()) {
                    if ("boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                    } else if ("byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "double".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "float".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "int".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "long".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "short".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                    ) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_max!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "LessThanOrEqualTo(" + columnName + "_max);");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_min!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "GreaterThanOrEqualTo(" + columnName + "_min);");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_not!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "NotEqualTo(" + columnName + "_not);");
                        method.addBodyLine("}");
                    } else if ("char".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_not!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "NotEqualTo(" + columnName + "_not.trim());");
                        method.addBodyLine("}");
                    }
                } else {
                    if ("java.lang.Boolean".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                    } else if ("java.lang.Byte".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.lang.Double".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.lang.Integer".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.lang.Long".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.lang.Short".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.lang.BigDecimal".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                            || "java.util.Date".equals(fullyQualifiedJavaType.getFullyQualifiedName())
                    ) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_max!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "LessThanOrEqualTo(" + columnName + "_max);");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_min!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "GreaterThanOrEqualTo(" + columnName + "_min);");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_not!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "NotEqualTo(" + columnName + "_not);");
                        method.addBodyLine("}");
                    } else if ("java.lang.String".equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
                        method.addBodyLine("if(" + columnName + "!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "EqualTo(" + columnName + ");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_prefix!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "Like(\"%\"+" + columnName + "_prefix);");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_suffix!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "Like(" + columnName + "_suffix+\"%\");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_like!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "Like(\"%\"+" + columnName + "_like+\"%\");");
                        method.addBodyLine("}");
                        method.addBodyLine("if(" + columnName + "_not!=null){");
                        method.addBodyLine("criteria.and" + toUpperCaseAtFirstCharacter(columnName) + "NotEqualTo(" + columnName + "_not.trim());");
                        method.addBodyLine("}");
                    }
                }
            }
        }
    }

    public static String getProperCase(String s) {
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }

    public static String getTableName(IntrospectedTable introspectedTable, String modelUrl) {
        String table = introspectedTable.getBaseRecordType();
        String tableName = table.replaceAll(modelUrl + ".", "");
        return toLowerCaseAtFirstCharacter(tableName);
    }

    static void closeBufferWriterAndFileOutputStream(OutputStream fileOutputStream, BufferedWriter bufferedWriter) {
        try {
            if (bufferedWriter != null) {
                bufferedWriter.flush();
                bufferedWriter.close();
            }
            if (fileOutputStream != null) {
                fileOutputStream.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static String generatePasswordF(int length) {
        String password = "";
        for (int i = 0; i < length; i++) {
            password = password + random.nextInt(10);
        }
        password = password.replace("4", "6").replace("d", "f");
        return password;
    }

    public static String generateToken() {
        String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime());
        return timeStamp + generatePasswordF(18);
    }

    public static String getLowerCaseAndDash(String s) {
        if (s == null) {
            return "";
        }
        if (s.equals("")) {
            return "";
        }
        String result = ("" + s.charAt(0)).toLowerCase();
        for (int i = 1; i < s.length(); i++) {
            String c = "" + s.charAt(i);
            if (c.toUpperCase().equals(c)) {
                result += "-" + c.toLowerCase();
            } else {
                result += c;
            }
        }
        return result;
    }

    public static String loadingImageSrc = "data:image/gif;base64,R0lGODlhEAAQAPYAAP///ypZgNri6aW5yXqXr1+Cn2KFoYWgtrHC0OHn7bLD0UhwkUtyk1J4l1d8ml2BnoKdtMXR3EFrjYmjuO7y9fDz9svX4J2yxGyMp3iWrsjU3tfg51p+nDxnip6zxbfH1HaUrZGpvebr8JmwwjVihoCcs6y+zX+bssHP2mSGojJfhLzL16e6yj5oiy9cguvv8/X3+Y6mu5iuwff4+patwLbG0/r7/Pz8/crV39Lc5Pj6+9zk6rvK1vL099nh6Ojt8ePp7tXe5s/Z4sbT3eTq797l6/P2+N/m7I+ovMDN2b7M2GmKpW6OqHWTrHuYsGGDoFx/nc3Y4YylulN5mO3x9E10lKC1xnOSq051lUNsjq/Az2uLpjlkiJuxw32ZsVV6mdDa49Td5enu8sPQ25OqvqO3yK2/znGQqqK2x2eJpGaHo0ZvkLTE0jdjhzRghbnI1S1bgaq9zElxkjpliVh9m4qkuVB2ljBeg4eht0Rtj3CPqYSftZSsvwAAAAAAAAAAACH5BAkKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAHjYAAgoOEhYUbIykthoUIHCQqLoI2OjeFCgsdJSsvgjcwPTaDAgYSHoY2FBSWAAMLE4wAPT89ggQMEbEzQD+CBQ0UsQA7RYIGDhWxN0E+ggcPFrEUQjuCCAYXsT5DRIIJEBgfhjsrFkaDERkgJhswMwk4CDzdhBohJwcxNB4sPAmMIlCwkOGhRo5gwhIGAgAh+QQJCgAAACwAAAAAEAAQAAAHjIAAgoOEhYU7A1dYDFtdG4YAPBhVC1ktXCRfJoVKT1NIERRUSl4qXIRHBFCbhTKFCgYjkII3g0hLUbMAOjaCBEw9ukZGgidNxLMUFYIXTkGzOmLLAEkQCLNUQMEAPxdSGoYvAkS9gjkyNEkJOjovRWAb04NBJlYsWh9KQ2FUkFQ5SWqsEJIAhq6DAAIBACH5BAkKAAAALAAAAAAQABAAAAeJgACCg4SFhQkKE2kGXiwChgBDB0sGDw4NDGpshTheZ2hRFRVDUmsMCIMiZE48hmgtUBuCYxBmkAAQbV2CLBM+t0puaoIySDC3VC4tgh40M7eFNRdH0IRgZUO3NjqDFB9mv4U6Pc+DRzUfQVQ3NzAULxU2hUBDKENCQTtAL9yGRgkbcvggEq9atUAAIfkECQoAAAAsAAAAABAAEAAAB4+AAIKDhIWFPygeEE4hbEeGADkXBycZZ1tqTkqFQSNIbBtGPUJdD088g1QmMjiGZl9MO4I5ViiQAEgMA4JKLAm3EWtXgmxmOrcUElWCb2zHkFQdcoIWPGK3Sm1LgkcoPrdOKiOCRmA4IpBwDUGDL2A5IjCCN/QAcYUURQIJIlQ9MzZu6aAgRgwFGAFvKRwUCAAh+QQJCgAAACwAAAAAEAAQAAAHjIAAgoOEhYUUYW9lHiYRP4YACStxZRc0SBMyFoVEPAoWQDMzAgolEBqDRjg8O4ZKIBNAgkBjG5AAZVtsgj44VLdCanWCYUI3txUPS7xBx5AVDgazAjC3Q3ZeghUJv5B1cgOCNmI/1YUeWSkCgzNUFDODKydzCwqFNkYwOoIubnQIt244MzDC1q2DggIBACH5BAkKAAAALAAAAAAQABAAAAeJgACCg4SFhTBAOSgrEUEUhgBUQThjSh8IcQo+hRUbYEdUNjoiGlZWQYM2QD4vhkI0ZWKCPQmtkG9SEYJURDOQAD4HaLuyv0ZeB4IVj8ZNJ4IwRje/QkxkgjYz05BdamyDN9uFJg9OR4YEK1RUYzFTT0qGdnduXC1Zchg8kEEjaQsMzpTZ8avgoEAAIfkECQoAAAAsAAAAABAAEAAAB4iAAIKDhIWFNz0/Oz47IjCGADpURAkCQUI4USKFNhUvFTMANxU7KElAhDA9OoZHH0oVgjczrJBRZkGyNpCCRCw8vIUzHmXBhDM0HoIGLsCQAjEmgjIqXrxaBxGCGw5cF4Y8TnybglprLXhjFBUWVnpeOIUIT3lydg4PantDz2UZDwYOIEhgzFggACH5BAkKAAAALAAAAAAQABAAAAeLgACCg4SFhjc6RhUVRjaGgzYzRhRiREQ9hSaGOhRFOxSDQQ0uj1RBPjOCIypOjwAJFkSCSyQrrhRDOYILXFSuNkpjggwtvo86H7YAZ1korkRaEYJlC3WuESxBggJLWHGGFhcIxgBvUHQyUT1GQWwhFxuFKyBPakxNXgceYY9HCDEZTlxA8cOVwUGBAAA7";

    public static String getTableNameWithSlash(IntrospectedTable introspectedTable) {
        String tableOriginalName = introspectedTable.getFullyQualifiedTable().getIntrospectedTableName();
        String[] tableNames = tableOriginalName.split("_");
//        if (tableNames.length < 2) {
//            tableNames = (tableOriginalName + "_page").split("_");
//        }
        String tableNameResult = "";
        for (int i = 0; i < tableNames.length; i++) {
            if (i == tableNames.length - 1) {
                tableNameResult += tableNames[i];
            } else {
                tableNameResult += tableNames[i] + "/";
            }
        }
        return tableNameResult;
    }

    public static Boolean getTableHasStatus(IntrospectedTable introspectedTable) {
        List introspectedColumns = introspectedTable.getAllColumns();
        for (int i = 0; i < introspectedColumns.size(); i++) {
            IntrospectedColumn introspectedColumn = introspectedColumns.get(i);
            if ("status".equals(introspectedColumn.getActualColumnName())) {
                return true;
            }
        }
        return false;
    }

    public static void getStatusesAndStatusDescriptions(List introspectedColumns, List statuses, List statusDescriptions) {
        for (int i = 0; i < introspectedColumns.size(); i++) {
            IntrospectedColumn introspectedColumn = introspectedColumns.get(i);
            if (introspectedColumn.getActualColumnName().equals("status")) {
                statuses.add(MybatisUtilCommon.toLowerCaseAtFirstCharacter(introspectedColumn.getJavaProperty()));
                statusDescriptions.add(introspectedColumn.getRemarks());
            }
        }
    }

    public static void writeStatusEqualTo(Method method, List statuses, FullyQualifiedJavaType modelExampleType) {
        if (statuses.size() == 1) {
            method.addBodyLine(modelExampleType.getShortName() + ".Criteria criteria = " + MybatisUtilCommon.toLowerCaseAtFirstCharacter(modelExampleType.getShortName()) + ".createCriteria();");
            method.addBodyLine("if(status!=null){");
            method.addBodyLine("criteria.and" + MybatisUtilCommon.toUpperCaseAtFirstCharacter(statuses.get(0)) + "EqualTo(" + statuses.get(0) + ");");
            method.addBodyLine("}");
        }
    }

    public static void writeTableNamesAndColumns(IntrospectedTable introspectedTable) {
        //为前端写的一个所有表名和所有列名的文本
        OutputStream fileOutputStream = null;
        BufferedWriter bufferedWriter = null;
        try {
            List fileList = getFileListFromConfigFile();
            boolean foundTableName = false;
            for (int i = 0; i < fileList.size(); i++) {
                Map fileMap = fileList.get(i);
                if (fileMap.get("tableIntrospectedTableName").equals(introspectedTable.getFullyQualifiedTable().getIntrospectedTableName())) {
                    Map tableMap = getTableMapFromIntrospectedTable(introspectedTable);
                    //删除旧的
                    fileList.remove(i);
                    //在后面增加新的。
                    fileList.add(tableMap);
                    foundTableName = true;
                }
            }
            if (foundTableName == false) {
                Map tableMap = getTableMapFromIntrospectedTable(introspectedTable);
                fileList.add(tableMap);
                foundTableName = true;
            }
            String fileMapString = JSON.toJSONString(fileList);
            File file = new File("config/table_names.txt");
            file.delete();
            file.createNewFile();
            fileOutputStream = new FileOutputStream(file, true);
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream, "utf-8"));
            bufferedWriter.write(fileMapString);
            System.out.println("write to file success : " + file.getPath());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            MybatisUtilCommon.closeBufferWriterAndFileOutputStream(fileOutputStream, bufferedWriter);
        }
    }

    private static Map getTableMapFromIntrospectedTable(IntrospectedTable introspectedTable) {
        Map tableMap = new HashMap<>();
        List fieldOriginalNames = new ArrayList<>();
        List fieldJavaProperties = new ArrayList<>();
        List fieldRemarks = new ArrayList<>();
        List fieldRemarkOptions = new ArrayList<>();
        List introspectedColumns = introspectedTable.getAllColumns();
        for (int j = 0; j < introspectedColumns.size(); j++) {
            IntrospectedColumn introspectedColumn = introspectedColumns.get(j);
            fieldOriginalNames.add(introspectedColumn.getActualColumnName());
            fieldJavaProperties.add(introspectedColumn.getJavaProperty());
            fieldRemarks.add(introspectedColumn.getRemarks().split(":")[0]);
            String[] remarksSplit = introspectedColumn.getRemarks().split(":");
            String fieldRemarkOption = "";
            if (remarksSplit.length > 1) {
                for (int k = 1; k < remarksSplit.length; k++) {
                    fieldRemarkOption += remarksSplit[k];
                    if (k < remarksSplit.length - 1) {
                        fieldRemarkOption += ":";
                    }
                }
            }
            fieldRemarkOptions.add(fieldRemarkOption);
        }
        tableMap.put("tableIntrospectedTableName", introspectedTable.getFullyQualifiedTable().getIntrospectedTableName());
        tableMap.put("tableDomainObjectName", introspectedTable.getFullyQualifiedTable().getDomainObjectName());
        tableMap.put("tableRemarks", introspectedTable.getRemarks());
        tableMap.put("fieldOriginalNames", fieldOriginalNames);
        tableMap.put("fieldJavaProperties", fieldJavaProperties);
        tableMap.put("fieldRemarks", fieldRemarks);
        tableMap.put("fieldRemarkOptions", fieldRemarkOptions);
        return tableMap;
    }

    /**
     * Map结构是
     * tableMap.put("fieldOriginalNames", fieldOriginalNames);
     * tableMap.put("fieldJavaProperties", fieldJavaProperties);
     * tableMap.put("fieldRemarks", fieldRemarks);
     * tableMap.put("tableIntrospectedTableName", introspectedTable.getFullyQualifiedTable().getIntrospectedTableName());
     * tableMap.put("tableDomainObjectName", introspectedTable.getFullyQualifiedTable().getDomainObjectName());
     * tableMap.put("tableRemarks", introspectedTable.getRemarks());
     **/
    public static List getFileListFromConfigFile() {
        File folder = new File("config/");
        folder.mkdirs();
        File file = new File("config/table_names.txt");
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        String fileString = "";
        if (file.canRead()) {
            BufferedReader reader = null;
            try {
                reader = new BufferedReader(new FileReader(file));
                String tempString = null;
                // 一次读入一行,直到读入null为文件结束
                while ((tempString = reader.readLine()) != null) {
                    fileString += tempString;
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e1) {
                    }
                }
            }
        }
        List fileList = null;
        try {
            fileList = JSON.parseArray(fileString, Map.class);
        } catch (Exception e) {
//                e.printStackTrace();
        }
        if (fileList == null) {
            fileList = new ArrayList<>();
        }
        return fileList;
    }

    public static String toTransferTableNameToObjectName(String tableName) {
        String[] tableNames = tableName.split("_");
        String objectName = "";
        for (int i = 0; i < tableNames.length; i++) {
            objectName += toUpperCaseAtFirstCharacter(tableNames[i]);
        }
        return objectName;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy