suochencheng 7 yıl önce
ebeveyn
işleme
d6ba29a2bc

+ 22 - 2
src/main/resources/templates/MapperXmlSqlServerTemplate.vm

@@ -59,7 +59,14 @@
                 #end
             #end
         </set>
-        where id = #{id,jdbcType=INTEGER}
+        where
+        <if test="id != null and !&quot;&quot;.equals(id)">
+            id = #{id,jdbcType=INTEGER}
+        </if>
+
+        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+            id in (${esc.d}{idStr})
+        </if>
     </update>
     <select id="query${model.className}ByPage" parameterType="java.util.Map"
             resultType="com.izouma.awesomeadmin.model.${model.className}">
@@ -68,6 +75,9 @@
         from ${model.tableName}
         <where>
             and 1 = 1
+            <if test="record.idStr != null and !&quot;&quot;.equals(record.idStr)">
+                and id in (${esc.d}{record.idStr})
+            </if>
             #foreach($field in $model.fields)
                 <if test="record.$field.modelName != null and !&quot;&quot;.equals(record.$field.modelName)">
                     and  ${field.name} = #{record.$field.modelName}
@@ -129,6 +139,9 @@
         from ${model.tableName}
         <where>
             and 1 = 1
+            <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+                and id in (${esc.d}{idStr})
+            </if>
             #foreach($field in $model.fields)
                 <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
                     and  ${field.name} = #{$field.modelName}
@@ -200,7 +213,14 @@
     </select>
     <delete id="delete">
         delete from ${model.tableName}
-        where id = #{id,jdbcType=INTEGER}
+        where
+        <if test="id != null and !&quot;&quot;.equals(id)">
+            id = #{id,jdbcType=INTEGER}
+        </if>
+
+        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+            id in (${esc.d}{idStr})
+        </if>
     </delete>
 
     <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">

+ 22 - 4
src/main/resources/templates/MapperXmlTemplate.vm

@@ -55,12 +55,22 @@
             </if>
          #end
         </set>
-        where id = #{id,jdbcType=INTEGER}
+        where
+        <if test="id != null and !&quot;&quot;.equals(id)">
+            id = #{id,jdbcType=INTEGER}
+        </if>
+
+        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+            id in (${esc.d}{idStr})
+        </if>
     </update>
     <select id="query${model.className}ByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
         select <include refid="Base_Column_List"/> from ${model.tableName}
         <where>
             and del_flag = 'N'
+            <if test="record.idStr != null and !&quot;&quot;.equals(record.idStr)">
+                and id in (${esc.d}{record.idStr})
+            </if>
         #foreach($field in $model.fields)
             <if test="record.$field.modelName != null and !&quot;&quot;.equals(record.$field.modelName)">
                 and  ${field.name} = #{record.$field.modelName}
@@ -134,6 +144,9 @@
         select <include refid="Base_Column_List"/> from ${model.tableName}
         <where>
             and del_flag = 'N'
+            <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+                and id in (${esc.d}{idStr})
+            </if>
         #foreach($field in $model.fields)
             <if test="$field.modelName != null and !&quot;&quot;.equals($field.modelName)">
                 and  ${field.name} = #{$field.modelName}
@@ -217,9 +230,14 @@
     </select>
     <update id="delete">
         UPDATE ${model.tableName} SET del_flag = 'Y'
-        <where>
-            AND id = #{id}
-        </where>
+        where
+        <if test="id != null and !&quot;&quot;.equals(id)">
+            id = #{id,jdbcType=INTEGER}
+        </if>
+
+        <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+            id in (${esc.d}{idStr})
+        </if>
     </update>
     <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
         select <include refid="Base_Column_List"/> from ${model.tableName}

+ 10 - 0
src/main/resources/templates/ModelTemplate.vm

@@ -15,6 +15,8 @@ public class $model.className{
     private $field.javaType $field.modelName;
 #end
 
+private String idStr;
+
 private String searchKey;
 
 /**
@@ -61,5 +63,13 @@ public void setOrderByStr(String orderByStr) {
     this.orderByStr = orderByStr;
 }
 
+public String getIdStr() {
+    return idStr;
+}
+
+public void setIdStr(String idStr) {
+    this.idStr = idStr;
+}
+
 }