Browse Source

套系分页显示藏品数量

zyf12 2 years ago
parent
commit
870b8e429d

+ 1 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -97,10 +97,7 @@ public class PostCollectionsSystemController extends BaseController
             return warn("请设置正确的套系时间");
         }
 
-        //判断套系名称是否重复
-        if (postCollectionsSystemService.selectPostCollectionsSystemByName(postCollectionsSystem) > 0){
-            return warn("该套系名称已存在");
-        }
+
 
         return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
     }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsSystemMapper.java

@@ -67,4 +67,6 @@ public interface PostCollectionsSystemMapper
                                                             @Param("timeRight") Date timeRight);
 
     Integer getCopiesById(Long id);
+
+    List<Long> selectPostCollectionsSystemId(PostCollectionsSystem postCollectionsSystem);
 }

+ 5 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/IPostCollectionsSystemService.java

@@ -5,6 +5,7 @@ import java.util.List;
 
 import com.ruoyi.system.domain.PostCollections;
 import com.ruoyi.system.domain.PostCollectionsSystem;
+import com.ruoyi.system.domain.vo.CollectionsVo;
 
 /**
  * 藏品套系Service接口
@@ -64,10 +65,9 @@ public interface IPostCollectionsSystemService
     //搜索功能
     public List<PostCollectionsSystem> selectByTitleAndTime(String title, Date timeLeft, Date timeRight);
 
-    /**
-     *  获取藏品数量
-     * @param postCollections
-     * @return 该套系下藏品数量
-     */
+
     public int getCopies(Long id);
+
+    List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem);
 }
+

+ 21 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsSystemServiceImpl.java

@@ -2,7 +2,11 @@ package com.ruoyi.system.service.impl;
 
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
+
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.vo.CollectionsVo;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.PostCollectionsSystemMapper;
@@ -166,4 +170,21 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     public int getCopies(Long id) {
         return postCollectionsSystemMapper.getCopiesById(id);
     }
+
+    @Override
+    public List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem) {
+        List<PostCollectionsSystem> list = postCollectionsSystemMapper.selectPostCollectionsSystemList(postCollectionsSystem);
+        List<CollectionsVo> collectionsVos=list.stream().map((item)->{
+            List<Long> ids=postCollectionsSystemMapper.selectPostCollectionsSystemId(postCollectionsSystem);
+            CollectionsVo collectionsVo=new CollectionsVo();
+            BeanUtils.copyProperties(item,collectionsVo);
+            for (Long id: ids
+                 ) {
+                Integer list1= postCollectionsSystemMapper.getCopiesById(id);
+                collectionsVo.setCopies(list1);
+            }
+            return collectionsVo;
+        }).collect(Collectors.toList());
+        return collectionsVos;
+    }
 }

+ 16 - 0
ruoyi-system/src/main/resources/mapper/system/PostCollectionsSystemMapper.xml

@@ -120,4 +120,20 @@
     <select id="getCopiesById" parameterType="Long" resultType="Integer">
        SELECT SUM(collections_number) FROM post_collections where system_id = #{id}
     </select>
+
+    <select id="selectPostCollectionsSystemId" parameterType="PostCollectionsSystem" resultType="Long">
+        select id from post_collections_system
+        <where>
+            <if test="type != null "> and type = #{type}</if>
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="startTime != null "> and start_time = #{startTime}</if>
+            <if test="endTime != null "> and end_time = #{endTime}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="image != null  and image != ''"> and image = #{image}</if>
+            <if test="giftExchange != null "> and gift_exchange = #{giftExchange}</if>
+            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
+            <if test="updateUser != null  and updateUser != ''"> and update_user = #{updateUser}</if>
+            and del_flag = '0'
+        </where>
+    </select>
 </mapper>