Эх сурвалжийг харах

藏品批量增加实现

Signed-off-by: hamjin <335908093@qq.com>
hamjin 2 жил өмнө
parent
commit
180bfea0a1

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoCollectionMapper.java

@@ -45,6 +45,14 @@ public interface PoCollectionMapper {
      */
     int insertPoCollection(PoCollection collections);
 
+    /**
+     * 新增藏品
+     *
+     * @param collections 藏品信息
+     * @return 结果
+     */
+    int batchInsertPoCollection(List<PoCollection> collections);
+
     /**
      * 修改藏品
      *

+ 11 - 8
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoCollectionService.java

@@ -9,12 +9,12 @@ import java.util.List;
  */
 public interface IPoCollectionService {
     /**
-     * 查询藏品
+     * 批量查询藏品
      *
-     * @param collectionIdList
+     * @param collectionList
      * @return
      */
-    public List<PoCollection> selectPoCollectionByCollectionIds(Long[] collectionIdList);
+    public List<PoCollection> selectPoCollectionsByCollections(List<PoCollection> collectionList);
 
 
     /**
@@ -41,6 +41,14 @@ public interface IPoCollectionService {
      */
     public int insertCollection(PoCollection collection);
 
+    /**
+     * 批量增加
+     *
+     * @param collection 藏品信息
+     * @return 操作状态
+     */
+    public int batchInsertCollection(List<PoCollection> collection);
+
     /**
      * 修改
      *
@@ -64,10 +72,5 @@ public interface IPoCollectionService {
      * @return 结果
      */
     public int deletePoCollectionByCollectionId(Long collectionId);
-
-
-
-
-
 }
 

+ 30 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoCollectionServiceImpl.java

@@ -6,7 +6,10 @@ import com.ruoyi.system.service.IPoCollectionService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @Service
 public class PoCollectionServiceImpl implements IPoCollectionService {
@@ -16,13 +19,19 @@ public class PoCollectionServiceImpl implements IPoCollectionService {
     /**
      * 查询藏品
      *
-     * @param collectionIdList
+     * @param collectionList
      * @return
      */
     @Override
-    public List<PoCollection> selectPoCollectionByCollectionIds(Long[] collectionIdList)
-    {
-        return null;
+    public List<PoCollection> selectPoCollectionsByCollections(List<PoCollection> collectionList) {
+        List<PoCollection> result = new ArrayList<>();
+        for (PoCollection collection1 : collectionList) {
+            List<PoCollection> list = poCollectionMapper.selectPoCollectionList(collection1);
+            if (list == null || list.isEmpty())
+                continue;
+            result = Stream.of(result, list).flatMap(List::stream).distinct().collect(Collectors.toList());
+        }
+        return result;
     }
 
     /**
@@ -64,6 +73,23 @@ public class PoCollectionServiceImpl implements IPoCollectionService {
         return poCollectionMapper.insertPoCollection(collection);
     }
 
+    /**
+     * 批量增加
+     *
+     * @param collection 藏品信息
+     * @return 操作状态
+     */
+    @Override
+    public int batchInsertCollection(List<PoCollection> collection) {
+        for (PoCollection collection1 : collection) {
+            List<PoCollection> list = poCollectionMapper.selectPoCollectionList(collection1);
+            if (list == null || list.isEmpty())
+                continue;
+            return -1;
+        }
+        return poCollectionMapper.batchInsertPoCollection(collection);
+    }
+
     /**
      * 修改
      *

+ 36 - 0
ruoyi-system/src/main/resources/mapper/system/PoCollectionMapper.xml

@@ -103,6 +103,42 @@
         )
     </insert>
 
+    <insert id="batchInsertPoCollection" parameterType="PoCollection">
+        insert into po_collection (
+        <if test="collectionTitle != null and collectionTitle != '' ">collection_title,</if>
+        <if test="collectionType != null and collectionType != '' ">collection_type,</if>
+        <if test="status != null and status != '' ">status,</if>
+        <if test="remark != null and remark != ''">remark,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        <if test="publisherName != null and publisherName != ''">publisher_name,</if>
+        <if test="formwork != null and formwork != ''">formwork,</if>
+        <if test="price != null and price != ''">price,</if>
+        <if test="story != null and story != ''">story,</if>
+        <if test="grouding != null and grouding != ''">grounding,</if>
+        <if test="cochain != null and cochain != ''">cochain,</if>
+        <if test="tetherId != null and tetherId != ''">tether_id,</if>
+        del_flag,
+        create_time
+        )values(
+        <foreach collection="collections" item="PoCollection" separator=",">
+            <if test="collectionTitle != null and collectionTitle != ''">#{collectionTitle},</if>
+            <if test="collectionType != null and collectionType != ''">#{collectionType},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="remark != null and remark != ''">#{remark},</if>
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
+            <if test="publisherName != null and publisherName != ''">#{publisherName},</if>
+            <if test="formwork != null and formwork != ''">#{formwork},</if>
+            <if test="price != null and price != ''">#{price},</if>
+            <if test="story != null and story != ''">#{story},</if>
+            <if test="grouding != null and grouding != ''">#{grounding},</if>
+            <if test="cochain != null and cochain != ''">#{cochain},</if>
+            <if test="tetherId != null and tetherId != ''">#{tetherId},</if>
+            0,
+            sysdate()
+        </foreach>
+        )
+    </insert>
+
     <update id="updatePoCollection" parameterType="PoCollection">
         update po_collection
         <set>