From b299ae012119e8ddbdf004e1c29e5c0c94f2ad94 Mon Sep 17 00:00:00 2001 From: seer Date: Mon, 17 Apr 2017 10:21:27 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=B8=BAhipac=E5=AE=9A=E5=88=B6=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../plugin/mydalgen/plugins/mybatis/IWalletTable.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index b6e7939..b29bd28 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.smartboot.maven.plugin maven-mydalgen-plugin - 1.0.4 + 1.0.4-hipac ${project.artifactId} smartboot-mybatisdalgen diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java index 7924464..5d60243 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java @@ -43,11 +43,11 @@ import Zql.ZUpdate; * @version IWalletTable.java, v 0.1 2015年7月25日 上午10:22:34 Seer Exp. */ public class IWalletTable extends JavaTable { - public static final String DO_PATTERN = "{0}DO"; - public static final String DAO_PATTERN = "{0}DAO"; + public static final String DO_PATTERN = "{0}"; + public static final String DAO_PATTERN = "{0}Mapper"; public static final String IBATIS_PATTERN = "{0}DaoImpl"; - public static final String DO_PACKAGE = "dataobject"; - public static final String DAO_PACKAGE = "dao"; + public static final String DO_PACKAGE = "entity"; + public static final String DAO_PACKAGE = "mapper"; public static final String IBATIS_PACKAGE = "dao.impl"; public static final String RESULT_MAP_PREFIX = "RM-"; -- Gitee From 8c40d8fb1d08ef951fb73dcf3ab2c2729a418d07 Mon Sep 17 00:00:00 2001 From: seer Date: Mon, 17 Apr 2017 10:33:00 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=B8=BAhipac=E5=AE=9A=E5=88=B6=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index b29bd28..a31661e 100644 --- a/pom.xml +++ b/pom.xml @@ -100,14 +100,18 @@ scm:git:ssh://git.oschina.net:smartboot/maven-mybatisdalgen-plugin.git master + - ossrh - https://oss.sonatype.org/content/repositories/snapshots + + yangt + snapshots Repository + http://maven.hipac.cn/nexus/content/repositories/snapshots - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + yangt + releases Repository + http://maven.hipac.cn/nexus/content/repositories/releases/ @@ -133,17 +137,7 @@ 1.6 - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - true - - + org.apache.maven.plugins maven-source-plugin @@ -174,20 +168,7 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - + org.apache.maven.plugins maven-release-plugin -- Gitee From 92c9f11b12c5a7a937b1af5cee6ea2fa0bfd2843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=88=80?= Date: Fri, 10 Jul 2020 11:16:30 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 470 +++++++++--------- .../maven/plugin/mydalgen/ColumnMap.java | 81 --- .../plugins/mybatis/IWalletTable.java | 4 +- 3 files changed, 237 insertions(+), 318 deletions(-) delete mode 100644 src/main/java/org/smartboot/maven/plugin/mydalgen/ColumnMap.java diff --git a/pom.xml b/pom.xml index a31661e..ccdf5ee 100644 --- a/pom.xml +++ b/pom.xml @@ -1,236 +1,236 @@ - - 4.0.0 - org.smartboot.maven.plugin - maven-mydalgen-plugin - 1.0.4-hipac - - ${project.artifactId} - smartboot-mybatisdalgen - https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin - - maven-plugin - - - org.apache.commons - commons-digester3 - 3.2 - - - org.apache.commons - commons-collections4 - 4.1 - - - org.apache.velocity - velocity - 1.7 - - - - commons-io - commons-io - 2.5 - - - org.apache.commons - commons-lang3 - 3.5 - - - - org.apache.maven - maven-plugin-api - 3.3.9 - - - mysql - mysql-connector-java - 5.1.40 - - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.5 - provided - - - - org.apache.maven.shared - maven-plugin-testing-harness - 1.1 - test - - - junit - junit - 4.12 - test - - - - - - The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - - Seer - 三刀 - zhengjunweimail@163.com - - SmartBoot作者 - - https://git.oschina.net/smartdms/ - GMT+8 - - https://git.oschina.net/uploads/75/351975_smartdms.jpg - - - - - - https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin - scm:git:https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin.git - scm:git:ssh://git.oschina.net:smartboot/maven-mybatisdalgen-plugin.git - master - - - - - - yangt - snapshots Repository - http://maven.hipac.cn/nexus/content/repositories/snapshots - - - yangt - releases Repository - http://maven.hipac.cn/nexus/content/repositories/releases/ - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 3.4 - - - - - true - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.6 - 1.6 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - true - -Xdoclint:none - - - - attach-javadocs - - jar - - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5 - - true - false - release - deploy - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - - - maven-plugin-plugin - - - [3.4,) - - - descriptor - - - - - - - - - - - - - - - - - alimaven - aliyun maven - http://maven.aliyun.com/nexus/content/groups/public/ - - - - - alimaven - aliyun maven - http://maven.aliyun.com/nexus/content/groups/public/ - - + + 4.0.0 + org.smartboot.maven.plugin + maven-mydalgen-plugin + 1.0.6-hipac + + ${project.artifactId} + smartboot-mybatisdalgen + https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin + + maven-plugin + + + org.apache.commons + commons-digester3 + 3.2 + + + org.apache.commons + commons-collections4 + 4.1 + + + org.apache.velocity + velocity + 1.7 + + + + commons-io + commons-io + 2.5 + + + org.apache.commons + commons-lang3 + 3.5 + + + + org.apache.maven + maven-plugin-api + 3.3.9 + + + mysql + mysql-connector-java + 5.1.40 + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.5 + provided + + + + org.apache.maven.shared + maven-plugin-testing-harness + 1.1 + test + + + junit + junit + 4.12 + test + + + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + + Seer + 三刀 + zhengjunweimail@163.com + + SmartBoot作者 + + https://git.oschina.net/smartdms/ + GMT+8 + + https://git.oschina.net/uploads/75/351975_smartdms.jpg + + + + + + https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin + scm:git:https://git.oschina.net/smartboot/maven-mybatisdalgen-plugin.git + scm:git:ssh://git.oschina.net:smartboot/maven-mybatisdalgen-plugin.git + master + + + + + + yangt + snapshots Repository + http://maven.hipac.cn/nexus/content/repositories/snapshots + + + yangt + releases Repository + http://maven.hipac.cn/nexus/content/repositories/releases/ + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.4 + + + + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + true + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5 + + true + false + release + deploy + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-plugin-plugin + + + [3.4,) + + + descriptor + + + + + + + + + + + + + + + + + alimaven + aliyun maven + http://maven.aliyun.com/nexus/content/groups/public/ + + + + + alimaven + aliyun maven + http://maven.aliyun.com/nexus/content/groups/public/ + + \ No newline at end of file diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/ColumnMap.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/ColumnMap.java deleted file mode 100644 index 7429c23..0000000 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/ColumnMap.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2001, Aslak Hellesøy, BEKK Consulting - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of BEKK Consulting nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ -package org.smartboot.maven.plugin.mydalgen; - -/** - * @author Aslak Helles - * @created 19. mai 2002 - */ -public class ColumnMap { - /** - * @todo-javadoc Describe the field - */ - private final String _primaryKey; - /** - * @todo-javadoc Describe the field - */ - private final String _foreignKey; - - - /** - * Describe what the ColumnMap constructor does - * - * @todo-javadoc Write javadocs for constructor - * @todo-javadoc Write javadocs for method parameter - * @todo-javadoc Write javadocs for method parameter - * @param primaryKey Describe what the parameter does - * @param foreignKey Describe what the parameter does - */ - public ColumnMap(String primaryKey, String foreignKey) { - _primaryKey = primaryKey; - _foreignKey = foreignKey; - } - - - /** - * Gets the PrimaryKey attribute of the ColumnMap object - * - * @return The PrimaryKey value - */ - public String getPrimaryKey() { - return _primaryKey; - } - - - /** - * Gets the ForeignKey attribute of the ColumnMap object - * - * @return The ForeignKey value - */ - public String getForeignKey() { - return _foreignKey; - } -} diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java index 5d60243..bc81d9b 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletTable.java @@ -43,8 +43,8 @@ import Zql.ZUpdate; * @version IWalletTable.java, v 0.1 2015年7月25日 上午10:22:34 Seer Exp. */ public class IWalletTable extends JavaTable { - public static final String DO_PATTERN = "{0}"; - public static final String DAO_PATTERN = "{0}Mapper"; + public static final String DO_PATTERN = "{0}DO"; + public static final String DAO_PATTERN = "{0}DAO"; public static final String IBATIS_PATTERN = "{0}DaoImpl"; public static final String DO_PACKAGE = "entity"; public static final String DAO_PACKAGE = "mapper"; -- Gitee From 0a5d6027e390ae44dbdd4889fcc71fe9464523d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=88=80?= Date: Wed, 14 Oct 2020 09:18:21 +0800 Subject: [PATCH 4/8] =?UTF-8?q?insert=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../mybatis/operation/IWalletInsert.java | 224 +++++++++--------- 2 files changed, 114 insertions(+), 112 deletions(-) diff --git a/pom.xml b/pom.xml index ccdf5ee..5f83510 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.smartboot.maven.plugin maven-mydalgen-plugin - 1.0.6-hipac + 1.0.7-hipac ${project.artifactId} smartboot-mybatisdalgen diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletInsert.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletInsert.java index d08ef0f..851f42f 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletInsert.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletInsert.java @@ -18,115 +18,117 @@ import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.util.DalUtil; */ public class IWalletInsert extends IWalletOperation { - public static final String OP_TYPE = "insert"; - - /** - * Constructor for IWalletInsert. - */ - - public IWalletInsert(IWalletOperationConfig opConfig) { - - super(opConfig); - - // 向下兼容,当没有配置机密性及完整性时,不进行SQL拼接 - if (opConfig.getTableConfig().getConfidentiality() != null - || opConfig.getTableConfig().getIntegrity() != null) { - getFinalSql(opConfig); - } - - paramType = PARAM_TYPE_OBJECT; - - multiplicity = MULTIPLICITY_ONE; - } - - /** - * 机密性和完整性方案,获得配置后的SQL语句 - * - * @param opConfig - */ - private void getFinalSql(IWalletOperationConfig opConfig) { - // add by yuanxiao ------------- - // 获得传入的SQL - String sql = opConfig.getSqlParser().getSql(); - - // 获得insert语句中第一个右括号 - int indexFParenthesisStart = StringUtils.indexOfAny(sql, ")"); - - StringBuffer sb = new StringBuffer(); - - // 取第一个括号前的子串 - String firstString = StringUtils.substring(sql, 0, indexFParenthesisStart); - - // 截取第一个括号到第二个括号前的 - String secondString = StringUtils.substring(sql, indexFParenthesisStart, sql.length() - 2); - - sb.append(firstString); - - if (opConfig.getTableConfig().getConfidentiality() != null) { - sb.append(",").append(opConfig.getTableConfig().getConfidentiality()).append("_confidentiality"); - } - if (opConfig.getTableConfig().getIntegrity() != null) { - sb.append(",").append(opConfig.getTableConfig().getIntegrity()).append("_integrity"); - } - sb.append(secondString); - - sb.append(",").append("?").append(",").append("?").append(");"); - - String finalSql = sb.toString(); - - opConfig.setSql(finalSql); - } - - /** - * @return - * - * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.Operation#getReturnTypeName() - */ - public String getSimpleReturnType() { - String returnType = DalUtil.getSimpleJavaType(getReturnType());//自定义的主键设置为void - return "String".equals(returnType) ? "void" : returnType; - } - - public String getReturnType() { - if (getTable().getPkColumn() == null) { - // add by zhaoxu 2007-10-26 - // 当无主键或多主键时,使用虚拟主键 - String dummyPk = opConfig.getTableConfig().getDummyPk(); - if (StringUtils.isNotBlank(dummyPk)) { - Column dummyPkColumn = getTable().getColumn(dummyPk); - if (dummyPkColumn != null) { - return ((IWalletColumn) dummyPkColumn).getJavaType(); - } - } - throw new IllegalStateException(getTable().getSqlName() + "无主键或多主键,可在table属性中指定虚拟主键dummypk。"); - } else { - return ((IWalletColumn) getTable().getPkColumn()).getJavaType(); - } - } - - /** - * @return - * - * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.Operation#getTemplateSuffix() - */ - public String getTemplateSuffix() { - return OP_TYPE; - } - - /** - * @param t - * - * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.IWalletOperation#setTable(org.smartboot.maven.plugin.mydalgen.Table) - */ - @Override - public void setTable(Table t) { - super.setTable(t); - } - - /** - * @return - */ - public String getMappedStatementType() { - return OP_TYPE; - } + public static final String OP_TYPE = "insert"; + + /** + * Constructor for IWalletInsert. + */ + + public IWalletInsert(IWalletOperationConfig opConfig) { + + super(opConfig); + + // 向下兼容,当没有配置机密性及完整性时,不进行SQL拼接 + if (opConfig.getTableConfig().getConfidentiality() != null + || opConfig.getTableConfig().getIntegrity() != null) { + getFinalSql(opConfig); + } + + if (PARAM_TYPE_PRIMITIVE.equals(opConfig.getParamType())) { + paramType = PARAM_TYPE_PRIMITIVE; + } else { + // default + paramType = PARAM_TYPE_OBJECT; + } + + multiplicity = MULTIPLICITY_ONE; + } + + /** + * 机密性和完整性方案,获得配置后的SQL语句 + * + * @param opConfig + */ + private void getFinalSql(IWalletOperationConfig opConfig) { + // add by yuanxiao ------------- + // 获得传入的SQL + String sql = opConfig.getSqlParser().getSql(); + + // 获得insert语句中第一个右括号 + int indexFParenthesisStart = StringUtils.indexOfAny(sql, ")"); + + StringBuffer sb = new StringBuffer(); + + // 取第一个括号前的子串 + String firstString = StringUtils.substring(sql, 0, indexFParenthesisStart); + + // 截取第一个括号到第二个括号前的 + String secondString = StringUtils.substring(sql, indexFParenthesisStart, sql.length() - 2); + + sb.append(firstString); + + if (opConfig.getTableConfig().getConfidentiality() != null) { + sb.append(",").append(opConfig.getTableConfig().getConfidentiality()).append("_confidentiality"); + } + if (opConfig.getTableConfig().getIntegrity() != null) { + sb.append(",").append(opConfig.getTableConfig().getIntegrity()).append("_integrity"); + } + sb.append(secondString); + + sb.append(",").append("?").append(",").append("?").append(");"); + + String finalSql = sb.toString(); + + opConfig.setSql(finalSql); + } + + /** + * @return + * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.Operation#getReturnTypeName() + */ + public String getSimpleReturnType() { + String returnType = DalUtil.getSimpleJavaType(getReturnType());//自定义的主键设置为void + return "String".equals(returnType) ? "void" : returnType; + } + + public String getReturnType() { + if (getTable().getPkColumn() == null) { + // add by zhaoxu 2007-10-26 + // 当无主键或多主键时,使用虚拟主键 + String dummyPk = opConfig.getTableConfig().getDummyPk(); + if (StringUtils.isNotBlank(dummyPk)) { + Column dummyPkColumn = getTable().getColumn(dummyPk); + if (dummyPkColumn != null) { + return ((IWalletColumn) dummyPkColumn).getJavaType(); + } + } + throw new IllegalStateException(getTable().getSqlName() + "无主键或多主键,可在table属性中指定虚拟主键dummypk。"); + } else { + return ((IWalletColumn) getTable().getPkColumn()).getJavaType(); + } + } + + /** + * @return + * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.Operation#getTemplateSuffix() + */ + public String getTemplateSuffix() { + return OP_TYPE; + } + + /** + * @param t + * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.IWalletOperation#setTable(org.smartboot.maven.plugin.mydalgen.Table) + */ + @Override + public void setTable(Table t) { + super.setTable(t); + } + + /** + * @return + */ + public String getMappedStatementType() { + return OP_TYPE; + } } -- Gitee From 1ce2da33eded38740c0798524b7a39062a2760d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A9?= Date: Mon, 21 Dec 2020 17:57:47 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=BF=87=E6=BB=A4idea=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9f355fb..e0658ce 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /.project /.DS_Store /.idea/ +*.iml -- Gitee From a102405841448834784ede5102c06d6c597223ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A9?= Date: Tue, 22 Dec 2020 10:51:35 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=9D=E6=8C=81=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/SUMMARY.md | 2 +- doc/configreference/element-operation.md | 2 +- doc/configreference/element-param.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/SUMMARY.md b/doc/SUMMARY.md index 22d27a2..99c124b 100644 --- a/doc/SUMMARY.md +++ b/doc/SUMMARY.md @@ -17,4 +17,4 @@ * [<sqlmap>](configreference/element-sqlmap.md) -* [案例]() \ No newline at end of file +* [案例]() diff --git a/doc/configreference/element-operation.md b/doc/configreference/element-operation.md index 2264f4a..1a186d7 100644 --- a/doc/configreference/element-operation.md +++ b/doc/configreference/element-operation.md @@ -31,4 +31,4 @@ operation为table的子标签,与resultMap标签同级,MyBatis的一条SQL *** -``` \ No newline at end of file +``` diff --git a/doc/configreference/element-param.md b/doc/configreference/element-param.md index ca4fa5f..3ae8c14 100644 --- a/doc/configreference/element-param.md +++ b/doc/configreference/element-param.md @@ -23,4 +23,4 @@ None *** -``` \ No newline at end of file +``` -- Gitee From aa22057e0a7e39289a7ead89891463e16feea7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A9?= Date: Tue, 22 Dec 2020 15:31:31 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0result=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=EF=BC=8C=E7=94=9F=E6=88=90=E5=B8=A6=E6=B3=9B=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +- .../plugins/mybatis/IWalletOperation.java | 2 +- .../plugins/mybatis/config/IWalletConfig.java | 5 ++ .../config/IWalletOperationConfig.java | 15 +++++ .../mybatis/config/IWalletResultConfig.java | 51 +++++++++++++++++ .../mybatis/operation/IWalletSelect.java | 57 ++++++++++++------- 6 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletResultConfig.java diff --git a/pom.xml b/pom.xml index 5f83510..cbb309e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.smartboot.maven.plugin maven-mydalgen-plugin - 1.0.7-hipac + 1.0.8-hipac-SNAPSHOT ${project.artifactId} smartboot-mybatisdalgen @@ -158,6 +158,7 @@ true -Xdoclint:none + /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/javadoc @@ -233,4 +234,4 @@ http://maven.aliyun.com/nexus/content/groups/public/ - \ No newline at end of file + diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletOperation.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletOperation.java index a75ca73..591a707 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletOperation.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/IWalletOperation.java @@ -96,7 +96,7 @@ public abstract class IWalletOperation extends PreferenceAware implements Operat } /** - * @param table + * @param t */ public void setTable(Table t) { table = t; diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletConfig.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletConfig.java index 8fe1c76..126f856 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletConfig.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletConfig.java @@ -182,6 +182,11 @@ public class IWalletConfig { digester.addSetProperties("table/operation/extraparams/param", "generictype", "genericType"); digester.addSetNext("table/operation/extraparams/param", "addExtraParam"); + digester.addObjectCreate("table/operation/result", IWalletResultConfig.class); + digester.addSetProperties("table/operation/result", "javatype", "javaType"); + digester.addSetProperties("table/operation/result", "generictype", "genericType"); + digester.addSetNext("table/operation/result", "addResult"); + digester.addCallMethod("table/operation/sql", "setSql", 0); digester.addCallMethod("table/operation/sqlmap", "setSqlmap", 0); // added by yangyanzhao 2010-02-08 diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletOperationConfig.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletOperationConfig.java index 2747278..913c040 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletOperationConfig.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletOperationConfig.java @@ -51,6 +51,9 @@ public class IWalletOperationConfig { /** extra params */ private List extraParams = new ArrayList(); + /** result */ + private IWalletResultConfig result = new IWalletResultConfig(); + /** * the sql statement of the operation. * @@ -270,6 +273,18 @@ public class IWalletOperationConfig { extraParams.add(paramConfig); } + public IWalletResultConfig getResult(){ + return result; + } + + /** + * add result + * @param resultConfig + */ + public void addResult(IWalletResultConfig resultConfig){ + result = resultConfig; + } + /** * @return Returns the append. */ diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletResultConfig.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletResultConfig.java new file mode 100644 index 0000000..05ef2d7 --- /dev/null +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/config/IWalletResultConfig.java @@ -0,0 +1,51 @@ +/** + * www.hipac.cn Inc. + * Copyright (c) 2004-2020 All Rights Reserved. + */ +package org.smartboot.maven.plugin.mydalgen.plugins.mybatis.config; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * result标签属性配置 + * + * @author jingtianer + * @version maven-mydalgen-plugin, v 0.1 2020-12-22 11:08 jingtianer Exp $ + */ +public class IWalletResultConfig { + + /** 参数类型 */ + private String javaType; + + /** 泛型类型 */ + private String genericType; + + public IWalletResultConfig(){ + super(); + } + + public String getJavaType() { + return javaType; + } + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + public String getGenericType() { + return genericType; + } + + public void setGenericType(String genericType) { + this.genericType = genericType; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + +} diff --git a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletSelect.java b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletSelect.java index 213e37c..01c9863 100644 --- a/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletSelect.java +++ b/src/main/java/org/smartboot/maven/plugin/mydalgen/plugins/mybatis/operation/IWalletSelect.java @@ -11,6 +11,7 @@ import org.smartboot.maven.plugin.mydalgen.Table; import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.IWalletOperation; import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.IWalletTable; import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.config.IWalletOperationConfig; +import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.config.IWalletResultConfig; import org.smartboot.maven.plugin.mydalgen.plugins.mybatis.util.DalUtil; import Zql.ZQuery; @@ -161,6 +162,11 @@ public class IWalletSelect extends IWalletOperation { public String getReturnType() { if (MULTIPLICITY_MANY.equals(multiplicity)) { addImprotForGenericType(); + // 配置了result标签,则导入result标签中的javaType + IWalletResultConfig resultConfig = opConfig.getResult(); + if(null != resultConfig && StringUtils.isNotBlank(resultConfig.getJavaType())){ + return resultConfig.getJavaType(); + } return DEFAULT_MANY_RETURN_TYPE_NO_PAGING; } @@ -192,27 +198,40 @@ public class IWalletSelect extends IWalletOperation { * @see org.smartboot.maven.plugin.mydalgen.plugins.mybatis.Operation#getSimpleReturnType() */ public String getSimpleReturnType() { - String simpleReturnType = DalUtil.getSimpleJavaType(getReturnType()); - if (StringUtils.equals("List", simpleReturnType)) { - String itemType = getColumnType(); - if (StringUtils.equals(itemType, "long")) { - itemType = "Long"; - } else if (StringUtils.equals(itemType, "int")) { - itemType = "Integer"; - } else if (StringUtils.equals(itemType, "map")) { - itemType = "java.util.Map"; - } else { - itemType = DalUtil.getSimpleJavaType(itemType); + IWalletResultConfig resultConfig = opConfig.getResult(); + // 未配置result标签,则走老的逻辑 + if(null == resultConfig || StringUtils.isBlank(resultConfig.getJavaType())){ + String simpleReturnType = DalUtil.getSimpleJavaType(getReturnType()); + if (StringUtils.equals("List", simpleReturnType)) { + String itemType = getColumnType(); + if (StringUtils.equals(itemType, "long")) { + itemType = "Long"; + } else if (StringUtils.equals(itemType, "int")) { + itemType = "Integer"; + } else if (StringUtils.equals(itemType, "map")) { + itemType = "java.util.Map"; + } else { + itemType = DalUtil.getSimpleJavaType(itemType); + } + + simpleReturnType += "<" + itemType + ">"; + } + if (StringUtils.equals(simpleReturnType, "map")) { + simpleReturnType = "java.util.Map"; + } + return simpleReturnType; + }else{ + String javaType = resultConfig.getJavaType(); + int index = javaType.lastIndexOf("."); + if (index >= 0) { + javaType = javaType.substring(index + 1); + } + if(StringUtils.isNotBlank(resultConfig.getGenericType())){ + return javaType + "<" + resultConfig.getGenericType() + ">"; + }else{ + return javaType; } - - simpleReturnType += "<" + itemType + ">"; - } - - if (StringUtils.equals(simpleReturnType, "map")) { - simpleReturnType = "java.util.Map"; } - - return simpleReturnType; } /** -- Gitee From f12531fbab9ee80288fd7984b27eab3371ba4546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=AF=E5=A4=A9?= Date: Wed, 23 Dec 2020 16:45:07 +0800 Subject: [PATCH 8/8] =?UTF-8?q?1.0.8=E6=AD=A3=E5=BC=8F=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cbb309e..7635b26 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.smartboot.maven.plugin maven-mydalgen-plugin - 1.0.8-hipac-SNAPSHOT + 1.0.8-hipac ${project.artifactId} smartboot-mybatisdalgen -- Gitee