Browse Source

套系上下架1.0

sjx 2 years ago
parent
commit
69c9cf5f3b

+ 22 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system;
 
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
@@ -143,4 +144,25 @@ public class PostCollectionsSystemController extends BaseController
         List<PostCollectionsSystem> list= postCollectionsSystemService.selectByTitleAndTime(title,TimeLeft,TimeRight);
         return getDataTable(list);
     }
+
+    /**
+     *  更改套系状态(上架 /下架)
+     * @param status
+     * @param ids
+     * @return
+     */
+    @ApiOperation("更改套系状态(上架 /下架)")
+    @PostMapping("/status/{status}")
+    public AjaxResult changeStatus(@RequestParam("ids")List<Long> ids, @PathVariable String status){
+       List<PostCollectionsSystem> postCollectionsSystemList = postCollectionsSystemService.listByIds(ids);
+
+        postCollectionsSystemList = postCollectionsSystemList.stream().map(
+                (item) ->{
+                    item.setStatus(status);
+                    return item;
+                }
+        ).collect(Collectors.toList());
+
+       return toAjax(postCollectionsSystemService.updateBatchById(postCollectionsSystemList));
+    }
 }

+ 1 - 1
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,7 +6,7 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://120.76.241.226:3306/post?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://120.76.241.226:3306/post?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
                 username: root
                 password: 2719992822Czm.
             # 从库数据源

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

@@ -70,8 +70,11 @@ public interface PostCollectionsSystemMapper
     Integer getCopiesById(Long id);
 
 
-
     // 查询该套系名 数量
     int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
 
+    //通过ids 查询套系
+    List<PostCollectionsSystem> selectPostCollectionsSystemByIds(List<Long> ids);
+
+    int updateBatchById(List<PostCollectionsSystem> postCollectionsSystemList);
 }

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

@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
 import java.util.Date;
 import java.util.List;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.system.domain.PostCollections;
 import com.ruoyi.system.domain.PostCollectionsSystem;
 import com.ruoyi.system.domain.vo.CollectionsVo;
@@ -84,6 +85,21 @@ public interface IPostCollectionsSystemService
      * @param postCollectionsSystem
      */
     int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
+
+    /**
+     * 通过ids 查询套系
+     * @param ids
+     * @return
+     */
+    List<PostCollectionsSystem> listByIds(List<Long> ids);
+
+    /**
+     *  批量更新
+     *
+     * @param postCollectionsSystemList
+     * @return
+     */
+    int updateBatchById(List<PostCollectionsSystem> postCollectionsSystemList);
 }
 
 

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

@@ -194,4 +194,14 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     public int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem) {
         return postCollectionsSystemMapper.selectPostCollectionsSystemByName(postCollectionsSystem);
     }
+
+    @Override
+    public List<PostCollectionsSystem> listByIds(List<Long> ids) {
+        return postCollectionsSystemMapper.selectPostCollectionsSystemByIds(ids);
+    }
+
+    @Override
+    public int updateBatchById(List<PostCollectionsSystem> postCollectionsSystemList) {
+        return postCollectionsSystemMapper.updateBatchById(postCollectionsSystemList);
+    }
 }

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

@@ -111,20 +111,56 @@
     <select id="selectPostListByTitleOrTime" resultType="PostCollectionsSystem" resultMap="PostCollectionsSystemResult">
         <include refid="selectPostCollectionsSystemVo"/>
         <where>
-            <if test="title != null  and title != ''"> and name LIKE CONCAT(CONCAT('%',#{title},'%'))</if>
+            <if test="title != null  and title != ''"> and name LIKE concat('%', #{title}, '%')</if>
             <if test="timeLeft != null and timeRight != null "> and create_time between #{timeLeft} AND #{timeRight}</if>
             and del_flag = '0'
         </where>
     </select>
 
-
+    <!--获取套系 所对应藏品种类 数量-->
     <select id="getCopiesById" parameterType="Long" resultType="Integer">
        SELECT COUNt(system_id) FROM post_collections where system_id = #{id}
     </select>
 
-
     <!--用藏品名称进行查询数量-->
     <select id="selectPostCollectionsSystemByName" parameterType="PostCollectionsSystem" resultType="int">
         SELECT COUNT(name) FROM post_collections_system where name =  #{name} and del_flag = '0'
     </select>
+
+    <!--通过ids 查询套系-->
+    <select id="selectPostCollectionsSystemByIds" parameterType="String" resultMap="PostCollectionsSystemResult">
+        <include refid="selectPostCollectionsSystemVo"/>
+        <where>
+            id IN
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            and del_flag = '0'
+        </where>
+    </select>
+
+    <update id="updateBatchById" parameterType="list">
+        <foreach collection="list" item="item" separator=";">
+            update
+            `post_collections_system`
+            <trim prefix="SET" suffixOverrides=",">
+                <if test="item.type != null">type = #{item.type},</if>
+                <if test="item.name != null">name = #{item.name},</if>
+                <if test="item.createTime != null">create_time = #{item.createTime},</if>
+                <if test="item.startTime != null">start_time = #{item.startTime},</if>
+                <if test="item.endTime != null">end_time = #{item.endTime},</if>
+                <if test="item.status != null">status = #{item.status},</if>
+                <if test="item.image != null">image = #{item.image},</if>
+                <if test="item.giftExchange != null">gift_exchange = #{item.giftExchange},</if>
+                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
+                <if test="item.createBy != null">create_by = #{item.createBy},</if>
+                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
+                <if test="item.delFlag != null">del_flag = #{item.delFlag},</if>
+            </trim>
+            where
+            id = #{item.id}
+
+        </foreach>
+    </update>
+
 </mapper>