admin
2021-10-12 664cc2fd39177fd3daa6d3988396c704d130882c
src/main/java/org/yeshi/utils/generater/mybatis/MyBatisMapperUtil.java
@@ -85,16 +85,16 @@
                }
                if (type.equalsIgnoreCase("Date")) {
                    String tempProperty = "min" + property.substring(0, 1).toUpperCase() + property.substring(1);
                    buffer.append(String.format("\tpublic %s %s", type, tempProperty));
                    queryColumnData.add(new MybatisColumnData(columnName, tempProperty, type));
                    buffer.append(String.format("\tpublic %s %s;", type, tempProperty));
                    queryColumnData.add(new MybatisColumnData(columnName, tempProperty, type,ColumnParseUtil.getJDBCType(genericType)));
                    buffer.append("\n\t");
                    tempProperty = "max" + property.substring(0, 1).toUpperCase() + property.substring(1);
                    buffer.append(String.format("\tpublic %s %s", type, tempProperty));
                    queryColumnData.add(new MybatisColumnData(columnName, tempProperty, type));
                    buffer.append(String.format("\tpublic %s %s;", type, tempProperty));
                    queryColumnData.add(new MybatisColumnData(columnName, tempProperty, type,ColumnParseUtil.getJDBCType(genericType)));
                    buffer.append("\n\t");
                } else {
                    buffer.append(String.format("\tpublic %s %s", type, property));
                    queryColumnData.add(new MybatisColumnData(columnName, property, type));
                    buffer.append(String.format("\tpublic %s %s;", type, property));
                    queryColumnData.add(new MybatisColumnData(columnName, property, type,ColumnParseUtil.getJDBCType(genericType)));
                    buffer.append("\n\t");
                }
            }
@@ -115,6 +115,8 @@
        return queryColumnData;
    }
    public static void createMapper(Class<?> clz) {
        // 生成mapper java文件
        String pks = getDaoPackageName(clz);
@@ -126,12 +128,13 @@
        buffer.append(String.format("public interface %sMapper extends BaseMapper<%s> {", clz.getSimpleName(), clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("%s selectByPrimaryKeyForUpdate(@Param(\"id\") id);",clz.getSimpleName()));
        //TODO 确定ID类型
        buffer.append(String.format("%s selectByPrimaryKeyForUpdate(@Param(\"id\") Long id);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("List<%s> list(@Param(\"query\") query);", clz.getSimpleName()));
        buffer.append(String.format("List<%s> list(@Param(\"query\") DaoQuery query);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append("long count(@Param(\"query\") query);");
        buffer.append("long count(@Param(\"query\") DaoQuery query);");
        buffer.append("\n\n\t");
        List<MybatisColumnData> queryColumnData = createMapperDaoQuery(importPosition, buffer, clz);
@@ -236,7 +239,7 @@
            select.addText("select");
            org.dom4j.Element include = select.addElement("include");
            include.addAttribute("refid", "Base_Column_List");
            select.addText(String.format("from %s where %s = #{%s,jdbcType=BIGINT}", tableName, idKeys.column,
            select.addText(String.format(" from %s where %s = #{%s,jdbcType=BIGINT}", tableName, idKeys.column,
                    idKeys.attribute));
@@ -247,7 +250,7 @@
            select.addText("select");
            include = select.addElement("include");
            include.addAttribute("refid", "Base_Column_List");
            select.addText(String.format("from %s where %s = #{%s,jdbcType=BIGINT} for update", tableName, idKeys.column,
            select.addText(String.format(" from %s where %s = #{%s,jdbcType=BIGINT} for update", tableName, idKeys.column,
                    idKeys.attribute));
            //添加sql
@@ -274,7 +277,7 @@
            select.addText("select");
            include = select.addElement("include");
            include.addAttribute("refid", "Base_Column_List");
            select.addText(String.format("from %s where 1=1", tableName));
            select.addText(String.format(" from %s where 1=1", tableName));
            include = select.addElement("include");
            include.addAttribute("refid", "listWhereSQL");