@@ -374,6 +374,22 @@ public static String insertIntoTable(Class<?> entityClass, String defaultTableNa
374
374
return sql .toString ();
375
375
}
376
376
377
+ /**
378
+ * insert into tableName - 动态表名
379
+ *
380
+ * @param entityClass
381
+ * @param defaultTableName
382
+ * @param parameterName 动态表名的参数名
383
+ * @return
384
+ */
385
+ public static String insertIntoTable (Class <?> entityClass , String defaultTableName , String parameterName ) {
386
+ StringBuilder sql = new StringBuilder ();
387
+ sql .append ("INSERT INTO " );
388
+ sql .append (getDynamicTableName (entityClass , defaultTableName , parameterName ));
389
+ sql .append (" " );
390
+ return sql .toString ();
391
+ }
392
+
377
393
/**
378
394
* insert table()列
379
395
*
@@ -476,9 +492,9 @@ public static String updateSetColumns(Class<?> entityClass, String entityName, b
476
492
String versionClass = version .nextVersion ().getCanonicalName ();
477
493
//version = ${@tk.mybatis.mapper.version@nextVersionClass("versionClass", version)}
478
494
sql .append (column .getColumn ())
479
- .append (" = ${@tk.mybatis.mapper.version.VersionUtil@nextVersion(" )
480
- .append ("@" ).append (versionClass ).append ("@class, " )
481
- .append (column .getProperty ()).append (")}," );
495
+ .append (" = ${@tk.mybatis.mapper.version.VersionUtil@nextVersion(" )
496
+ .append ("@" ).append (versionClass ).append ("@class, " )
497
+ .append (column .getProperty ()).append (")}," );
482
498
} else if (column == logicDeleteColumn ) {
483
499
sql .append (logicDeleteColumnEqualsValue (column , false )).append ("," );
484
500
} else if (notNull ) {
@@ -883,38 +899,38 @@ public static String exampleCheck(Class<?> entityClass) {
883
899
*/
884
900
public static String exampleWhereClause () {
885
901
return "<if test=\" _parameter != null\" >" +
886
- "<where>\n " +
887
- " ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(_parameter)}" +
888
- " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
889
- " <foreach collection=\" oredCriteria\" item=\" criteria\" >\n " +
890
- " <if test=\" criteria.valid\" >\n " +
891
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criteria)}" +
892
- " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
893
- " <foreach collection=\" criteria.criteria\" item=\" criterion\" >\n " +
894
- " <choose>\n " +
895
- " <when test=\" criterion.noValue\" >\n " +
896
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
897
- " </when>\n " +
898
- " <when test=\" criterion.singleValue\" >\n " +
899
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}\n " +
900
- " </when>\n " +
901
- " <when test=\" criterion.betweenValue\" >\n " +
902
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}\n " +
903
- " </when>\n " +
904
- " <when test=\" criterion.listValue\" >\n " +
905
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
906
- " <foreach close=\" )\" collection=\" criterion.value\" item=\" listItem\" open=\" (\" separator=\" ,\" >\n " +
907
- " #{listItem}\n " +
908
- " </foreach>\n " +
909
- " </when>\n " +
910
- " </choose>\n " +
911
- " </foreach>\n " +
912
- " </trim>\n " +
913
- " </if>\n " +
914
- " </foreach>\n " +
915
- " </trim>\n " +
916
- "</where>" +
917
- "</if>" ;
902
+ "<where>\n " +
903
+ " ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(_parameter)}" +
904
+ " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
905
+ " <foreach collection=\" oredCriteria\" item=\" criteria\" >\n " +
906
+ " <if test=\" criteria.valid\" >\n " +
907
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criteria)}" +
908
+ " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
909
+ " <foreach collection=\" criteria.criteria\" item=\" criterion\" >\n " +
910
+ " <choose>\n " +
911
+ " <when test=\" criterion.noValue\" >\n " +
912
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
913
+ " </when>\n " +
914
+ " <when test=\" criterion.singleValue\" >\n " +
915
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}\n " +
916
+ " </when>\n " +
917
+ " <when test=\" criterion.betweenValue\" >\n " +
918
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}\n " +
919
+ " </when>\n " +
920
+ " <when test=\" criterion.listValue\" >\n " +
921
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
922
+ " <foreach close=\" )\" collection=\" criterion.value\" item=\" listItem\" open=\" (\" separator=\" ,\" >\n " +
923
+ " #{listItem}\n " +
924
+ " </foreach>\n " +
925
+ " </when>\n " +
926
+ " </choose>\n " +
927
+ " </foreach>\n " +
928
+ " </trim>\n " +
929
+ " </if>\n " +
930
+ " </foreach>\n " +
931
+ " </trim>\n " +
932
+ "</where>" +
933
+ "</if>" ;
918
934
}
919
935
920
936
/**
@@ -924,36 +940,36 @@ public static String exampleWhereClause() {
924
940
*/
925
941
public static String updateByExampleWhereClause () {
926
942
return "<where>\n " +
927
- " ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(example)}" +
928
- " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
929
- " <foreach collection=\" example.oredCriteria\" item=\" criteria\" >\n " +
930
- " <if test=\" criteria.valid\" >\n " +
931
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criteria)}" +
932
- " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
933
- " <foreach collection=\" criteria.criteria\" item=\" criterion\" >\n " +
934
- " <choose>\n " +
935
- " <when test=\" criterion.noValue\" >\n " +
936
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
937
- " </when>\n " +
938
- " <when test=\" criterion.singleValue\" >\n " +
939
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}\n " +
940
- " </when>\n " +
941
- " <when test=\" criterion.betweenValue\" >\n " +
942
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}\n " +
943
- " </when>\n " +
944
- " <when test=\" criterion.listValue\" >\n " +
945
- " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
946
- " <foreach close=\" )\" collection=\" criterion.value\" item=\" listItem\" open=\" (\" separator=\" ,\" >\n " +
947
- " #{listItem}\n " +
948
- " </foreach>\n " +
949
- " </when>\n " +
950
- " </choose>\n " +
951
- " </foreach>\n " +
952
- " </trim>\n " +
953
- " </if>\n " +
954
- " </foreach>\n " +
955
- " </trim>\n " +
956
- "</where>" ;
943
+ " ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(example)}" +
944
+ " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
945
+ " <foreach collection=\" example.oredCriteria\" item=\" criteria\" >\n " +
946
+ " <if test=\" criteria.valid\" >\n " +
947
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criteria)}" +
948
+ " <trim prefix=\" (\" prefixOverrides=\" and |or \" suffix=\" )\" >\n " +
949
+ " <foreach collection=\" criteria.criteria\" item=\" criterion\" >\n " +
950
+ " <choose>\n " +
951
+ " <when test=\" criterion.noValue\" >\n " +
952
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
953
+ " </when>\n " +
954
+ " <when test=\" criterion.singleValue\" >\n " +
955
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}\n " +
956
+ " </when>\n " +
957
+ " <when test=\" criterion.betweenValue\" >\n " +
958
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}\n " +
959
+ " </when>\n " +
960
+ " <when test=\" criterion.listValue\" >\n " +
961
+ " ${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}\n " +
962
+ " <foreach close=\" )\" collection=\" criterion.value\" item=\" listItem\" open=\" (\" separator=\" ,\" >\n " +
963
+ " #{listItem}\n " +
964
+ " </foreach>\n " +
965
+ " </when>\n " +
966
+ " </choose>\n " +
967
+ " </foreach>\n " +
968
+ " </trim>\n " +
969
+ " </if>\n " +
970
+ " </foreach>\n " +
971
+ " </trim>\n " +
972
+ "</where>" ;
957
973
}
958
974
959
975
}
0 commit comments