Browse Source

批量更新

suochencheng 7 years ago
parent
commit
eb6212e95e

+ 4 - 3
src/main/java/com/izouma/awesomeadmin/dao/ProductInfoMapper.java

@@ -1,9 +1,10 @@
 package com.izouma.awesomeadmin.dao;
 
-import java.util.*;
-import com.izouma.awesomeadmin.datasource.DataSource;
-import org.springframework.stereotype.Repository;
 import com.izouma.awesomeadmin.model.ProductInfo;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
 
 
 /**

+ 15 - 1
src/main/java/com/izouma/awesomeadmin/dao/ProductInfoMapper.xml

@@ -281,7 +281,15 @@
                 price= #{price,jdbcType=DECIMAL},
             </if>
         </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 (${idStr})
+        </if>
+
     </update>
     <select id="queryProductInfoByPage" parameterType="java.util.Map"
             resultType="com.izouma.awesomeadmin.model.ProductInfo">
@@ -293,6 +301,9 @@
             <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                 and id = #{record.id}
             </if>
+            <if test="record.idStr != null and !&quot;&quot;.equals(record.idStr)">
+                and id in (${record.idStr})
+            </if>
             <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                 and del_flag = #{record.delFlag}
             </if>
@@ -430,6 +441,9 @@
             <if test="id != null and !&quot;&quot;.equals(id)">
                 and id = #{id}
             </if>
+            <if test="idStr != null and !&quot;&quot;.equals(idStr)">
+                and id in (${idStr})
+            </if>
             <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                 and del_flag = #{delFlag}
             </if>

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/ProductInfo.java

@@ -32,6 +32,8 @@ public class ProductInfo {
     private Integer salesVolume;
     private BigDecimal price;
 
+    private String idStr;
+
     private List<ProductImage> productImageList;
 
     private List<ProductPrice> productPriceList;
@@ -265,5 +267,13 @@ public class ProductInfo {
     public void setStoreInfo(StoreInfo storeInfo) {
         this.storeInfo = storeInfo;
     }
+
+    public String getIdStr() {
+        return idStr;
+    }
+
+    public void setIdStr(String idStr) {
+        this.idStr = idStr;
+    }
 }
 

+ 1 - 0
src/main/java/com/izouma/awesomeadmin/service/ProductInfoService.java

@@ -23,5 +23,6 @@ public interface ProductInfoService{
     boolean deleteProductInfo(String id);
 
     boolean updateProductInfo(ProductInfo record);
+
 }
 

+ 1 - 0
src/main/java/com/izouma/awesomeadmin/service/impl/ProductInfoServiceImpl.java

@@ -133,5 +133,6 @@ public class ProductInfoServiceImpl implements ProductInfoService{
 
         return false;
     }
+
 }
 

+ 23 - 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,15 @@
     </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}">

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

@@ -55,12 +55,23 @@
             </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 +145,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 +231,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;
+}
+
 }