3 次代码提交 bf6153ed7a ... d8e2d57f46

作者 SHA1 备注 提交日期
  zyf12 d8e2d57f46 套系分页显示藏品数量 2 年之前
  zyf12 8c143b323c Merge remote-tracking branch 'origin/yellow' into yellow 2 年之前
  zyf12 870b8e429d 套系分页显示藏品数量 2 年之前

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

@@ -5,6 +5,7 @@ import java.util.List;
 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.security.access.prepost.PreAuthorize;
@@ -42,7 +43,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);
     }
 
@@ -93,10 +94,6 @@ public class PostCollectionsSystemController extends BaseController
             return warn("请设置正确的套系时间");
         }
 
-        //判断套系名称是否重复
-        if (postCollectionsSystemService.selectPostCollectionsSystemByName(postCollectionsSystem) > 0){
-            return warn("该套系名称已存在");
-        }
 
         return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
     }

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

@@ -61,6 +61,7 @@ public interface PostCollectionsSystemMapper
      */
     public int deletePostCollectionsSystemByIds(Long[] ids);
 
+
     //套系搜索功能
     List<PostCollectionsSystem> selectPostListByTitleOrTime(@Param("title") String title,
                                                             @Param("timeLeft") Date timeLeft,
@@ -68,6 +69,5 @@ public interface PostCollectionsSystemMapper
 
     Integer getCopiesById(Long id);
 
-    // 查询该套系名 数量
-    int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
+    List<Long> selectPostCollectionsSystemId(PostCollectionsSystem postCollectionsSystem);
 }

+ 4 - 10
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接口
@@ -14,6 +15,7 @@ import com.ruoyi.system.domain.PostCollectionsSystem;
  */
 public interface IPostCollectionsSystemService
 {
+
     /**
      * 查询藏品套系
      *
@@ -64,17 +66,9 @@ public interface IPostCollectionsSystemService
     //搜索功能
     public List<PostCollectionsSystem> selectByTitleAndTime(String title, Date timeLeft, Date timeRight);
 
-    /**
-     *  获取藏品数量
-     * @param id
-     * @return 该套系下藏品数量
-     */
+
     public int getCopies(Long id);
 
-    /**
-     *  用套系名称进行查询
-     * @param postCollectionsSystem
-     */
-    int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
+    List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem);
 }
 

+ 23 - 6
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;
@@ -20,6 +24,7 @@ import static com.ruoyi.common.utils.SecurityUtils.getUsername;
 @Service
 public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemService
 {
+
     @Autowired
     private PostCollectionsSystemMapper postCollectionsSystemMapper;
 
@@ -76,9 +81,9 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
         }
 
         //补充字段
-        postCollectionsSystem.setCreateUser(getUsername());
+        postCollectionsSystem.setCreateBy(getUsername());
         postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
-        postCollectionsSystem.setUpdateUser(getUsername());
+        postCollectionsSystem.setUpdateBy(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.insertPostCollectionsSystem(postCollectionsSystem);
     }
@@ -93,7 +98,7 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     public int updatePostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
     {
         //补充字段
-        postCollectionsSystem.setUpdateUser(getUsername());
+        postCollectionsSystem.setUpdateBy(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
     }
@@ -139,6 +144,7 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
             }else {
                 //时间为空
                 return postCollectionsSystemMapper.selectPostListByTitleOrTime(title, TimeLeft, TimeRight);
+
             }
         } else {
             //标题为空
@@ -167,8 +173,19 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     }
 
     @Override
-    public int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem) {
-        return postCollectionsSystemMapper.selectPostCollectionsSystemByName(postCollectionsSystem);
+    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;
     }
-
 }

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

@@ -117,7 +117,24 @@
         </where>
     </select>
 
+
     <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>