Browse Source

套系藏品 批量删除1.1

sjx 2 years ago
parent
commit
f8be763798

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

@@ -71,4 +71,6 @@ public interface PostCollectionsMapper
     //批量修改藏品状态status
     Long updatePostCollectionsStatus(PostCollections postCollections);
 
+
+    void deletePostCollectionsBySystemIds(Long[] ids);
 }

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

@@ -85,4 +85,5 @@ public interface PostCollectionsSystemMapper
 
     Date getEndTime(Long id);
 
+    public List<PostCollectionsSystem>  selectListEqStatus(Long[] ids);
 }

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

@@ -3,17 +3,23 @@ package com.ruoyi.system.service.impl;
 import java.sql.Time;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.vo.CollectionsVo;
 import com.ruoyi.system.mapper.PostCollectionsMapper;
 import com.ruoyi.system.service.IPostCollectionsService;
+import com.ruoyi.system.utils.CollectionStatusJudgment;
+import com.sun.xml.internal.ws.api.message.ExceptionHasMessage;
 import org.apache.commons.lang3.builder.ToStringExclude;
 import org.apache.ibatis.type.LocalDateTimeTypeHandler;
+import org.apache.poi.ss.formula.functions.Count;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -39,6 +45,9 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     @Autowired
     private PostCollectionsSystemMapper postCollectionsSystemMapper;
 
+    @Autowired
+    private PostCollectionsMapper postCollectionsMapper;
+
     /**
      * 查询藏品套系
      *
@@ -154,8 +163,17 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
      * @return 结果
      */
     @Override
-    public int deletePostCollectionsSystemByIds(Long[] ids)
-    {
+    public int deletePostCollectionsSystemByIds(Long[] ids) {
+
+
+        List<PostCollectionsSystem> postCollectionsSystemList = postCollectionsSystemMapper.selectListEqStatus(ids);
+        if (postCollectionsSystemList.size()!= 0){
+            throw new BaseException("套系已上架");
+        }
+
+        postCollectionsMapper.deletePostCollectionsBySystemIds(ids);
+
+
         return postCollectionsSystemMapper.deletePostCollectionsSystemByIds(ids);
     }
 

+ 8 - 0
ruoyi-system/src/main/resources/mapper/system/PostCollectionsMapper.xml

@@ -122,4 +122,12 @@
         update post_collections set status = '4',update_time = #{updateTime}, update_by = #{updateBy} where system_id=#{systemId} and del_flag = '0'
     </update>
 
+    <!--通过套系id 进行批量删除-->
+    <delete id="deletePostCollectionsBySystemIds" parameterType="String">
+        UPDATE post_collections SET del_flag = '1'  WHERE del_flag = '0' AND system_id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
 </mapper>

+ 15 - 3
ruoyi-system/src/main/resources/mapper/system/PostCollectionsSystemMapper.xml

@@ -163,7 +163,7 @@
                 <if test="item.delFlag != null">del_flag = #{item.delFlag},</if>
             </trim>
             where
-            id = #{item.id}
+            id = #{item.id}  and del_flag = '0'
 
         </foreach>
     </update>
@@ -180,14 +180,26 @@
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
         </trim>
-        where id = #{id}
+        where id = #{id}  and del_flag = '0'
     </update>
 
     <!--获取套系id 所对应截至时间-->
     <select id="getEndTime" parameterType="Long" resultType="Date">
-        SELECT end_time FROM post_collections_system where id= #{id}
+        SELECT end_time FROM post_collections_system where id= #{id}  and del_flag = '0'
     </select>
 
+    <!--获取已上架的套系-->
+    <select id="selectListEqStatus" parameterType="String" resultMap="PostCollectionsSystemResult">
+        <include refid="selectPostCollectionsSystemVo"/>
+        <where>
+            id IN
+            <foreach item="id" collection="array" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            and status='1'
+            and del_flag = '0'
+        </where>
+    </select>