#
luxiaotao1123
2024-02-17 c05fa8a85061355577aba11107932bb85df3517c
zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/BetterGenerator.java
@@ -41,6 +41,7 @@
    public String username;
    public String password;
    public String table;
    public String tableName;
    public String packagePath;
    public boolean controller = true;
    public boolean service = true;
@@ -71,6 +72,7 @@
    private String systemPackage;
    private String itemName;
    private String tableColumns;
    private String formEditColumns;
    public void build() throws Exception {
        init();
@@ -163,6 +165,7 @@
        }
        itemName = packagePathSplit[packagePathSplit.length - 1];
        tableColumns = createTableColumns();
        formEditColumns = createFormEditColumns();
    }
    private String readFile(String template){
@@ -190,6 +193,7 @@
        if(!writerFile.exists()){
            content=content.
                    replaceAll("@\\{TABLENAME}", table)
                    .replaceAll("@\\{TABLEDESC}", tableName)
                    .replaceAll("@\\{ENTITYIMPORT}", entityImport)
                    .replaceAll("@\\{ENTITYCONTENT}", entityContent)
                    .replaceAll("@\\{ENTITYNAME}", fullEntityName)
@@ -212,6 +216,7 @@
                    .replaceAll("@\\{UPCASEMARJORCOLUMN}", GeneratorUtils.firstCharConvert(primaryKeyColumn, false))
                    .replaceAll("@\\{SYSTEMPACKAGE}",systemPackage)
                    .replaceAll("@\\{TABLECOLUMNS}", tableColumns)
                    .replaceAll("@\\{FORMEDITCOLUMNS}", formEditColumns)
            ;
            writerFile.createNewFile();
            BufferedWriter writer=new BufferedWriter(new FileWriter(writerFile));
@@ -227,7 +232,13 @@
    private void gainDbInfo() throws Exception {
        Connection conn;
        if (null == this.sqlOsType) {
            throw new RuntimeException("请指定数据库类型!");
            throw new RuntimeException("请选择sqlOsType!");
        }
        if (null == this.table) {
            throw new RuntimeException("请输入table!");
        }
        if (null == this.tableName) {
            throw new RuntimeException("请输入tableName!");
        }
        switch (this.sqlOsType) {
            case MYSQL:
@@ -840,7 +851,25 @@
    /************************************** Edit动态字段 ********************************************/
    /**********************************************************************************************/
    private String createFormEditColumns() {
        StringBuilder sb = new StringBuilder();
        int times = 0;
        for (Column column : columns) {
            if (column.isPrimaryKey()
                    || column.getHumpName().equals("deleted")
                    || column.getHumpName().equals("hostId")
            ) {
                continue;
            }
            if (times%2 == 0) {
            }
            times++;
        }
        return sb.toString();
    }