Browse Source

显示藏品数量分页

zyf12 2 years ago
parent
commit
bf78d1fdc9

+ 6 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -1,12 +1,16 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.vo.CollectionsVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -42,7 +46,7 @@ public class PostCollectionsSystemController extends BaseController
     public TableDataInfo list(PostCollectionsSystem postCollectionsSystem)
     {
         startPage();
-        List<PostCollectionsSystem> list = postCollectionsSystemService.selectPostCollectionsSystemList(postCollectionsSystem);
+        List<CollectionsVo> list = postCollectionsSystemService.selectPostCollectionsSystemListPage(postCollectionsSystem);
         return getDataTable(list);
     }
 
@@ -53,7 +57,7 @@ public class PostCollectionsSystemController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:system:export')")
     @Log(title = "藏品套系", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, PostCollectionsSystem postCollectionsSystem)
+    public void export(HttpServletResponse response, PostCollectionsSystem postCollectionsSystem,int type)
     {
         List<PostCollectionsSystem> list = postCollectionsSystemService.selectPostCollectionsSystemList(postCollectionsSystem);
         ExcelUtil<PostCollectionsSystem> util = new ExcelUtil<PostCollectionsSystem>(PostCollectionsSystem.class);

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/CollectionsVo.java

@@ -2,6 +2,8 @@ package com.ruoyi.system.domain.vo;
 
 import com.ruoyi.system.domain.PostCollectionsSystem;
 
+import java.util.List;
+
 /**
  *  藏品数量
  */

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsSystemMapper.java

@@ -65,6 +65,8 @@ public interface PostCollectionsSystemMapper
     List<PostCollectionsSystem> selectPostListByTitleOrTime(@Param("title") String title,
                                                             @Param("timeLeft") Date timeLeft,
                                                             @Param("timeRight") Date timeRight);
-
+    //获取藏品数量
     Integer getCopiesById(Long id);
+
+    Long selectPostCollectionsSystemId(PostCollectionsSystem postCollectionsSystem);
 }

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

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

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

@@ -1,8 +1,13 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.Collections;
 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 +171,19 @@ 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)->{
+            Long id=postCollectionsSystemMapper.selectPostCollectionsSystemId(postCollectionsSystem);
+            CollectionsVo collectionsVo=new CollectionsVo();
+            BeanUtils.copyProperties(item,collectionsVo);
+            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>