Переглянути джерело

完成上下架 上下链接口

zhangyang 2 роки тому
батько
коміт
7fcc83bee0

+ 58 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoTetherController.java

@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.data.repository.query.Param;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
@@ -158,8 +159,15 @@ public class PoTetherController extends BaseController
     {
         //校验是否有操作的权限
         poUserService.checkUserAllowed(poUser);
-        //校验是否可以访问到数据
-        poUserService.checkUserDataScope(poUser.getUserId());
+
+        TetherVo tetherVo1 = poTetherService.selectPoTetherByTetherIdWithCollection(tetherVo.getTetherId());
+
+        if (tetherVo1 == null){
+            return error("没有对应的数据");
+        }
+        if (tetherVo1.getCochain() == 0){
+            return error("已经上链");
+        }
 
         if (UserConstants.NOT_UNIQUE.equals(poTetherService.checkPostTetherNameUnique(tetherVo))){
             return AjaxResult.error("修改失败"+tetherVo.getTetherName()+"已经存在");
@@ -188,8 +196,56 @@ public class PoTetherController extends BaseController
         if (!getUsername().equals("admin")){
             return AjaxResult.error("删除消息失败当前用户不是管理员");
         }
+        TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdsWithCollection(tetherIds);
+        if (tetherVo == null){
+            return error("想要删除的套系不存在");
+        }
+        if (tetherVo.getCochain() == 0){
+            return error("想要删除的套系已经上链");
+        }
         return toAjax(poTetherService.deletePoTetherByTetherIdsWithCollection(tetherIds));
     }
 
+    /**
+     * 修改状态 是否上链
+     */
+    @PreAuthorize("@ss.hasPermi('system:tether:isCochain')")
+    @PostMapping("/isCochain/{cochain}/{tetherId}")
+    public AjaxResult isCochain( @PathVariable("cochain") Integer cochain , @PathVariable("tetherId") Long tetherId){
+
+        if (!getUsername().equals("admin")){
+            return AjaxResult.error("不是管理员不可以修改上下链状态");
+        }
+
+        TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdWithCollection(tetherId);
+        if (tetherVo.getCochain() == 0){
+            return error("禁止重复上链");
+        }
+        return toAjax(poTetherService.updatePoTetherIsCochain(cochain,tetherId));
+    }
+    /**
+     * 修改状态 是否上架
+     */
+    @PreAuthorize("@ss.hasPermi('system:tether:isGrounding')")
+    @PostMapping("/isGrounding/{grounding}/{tetherId}")
+    public AjaxResult isGrounding( @PathVariable("grounding") Integer grounding , @PathVariable("tetherId") Long tetherId){
+
+        if (!getUsername().equals("admin")){
+            return AjaxResult.error("不是管理员不可以修改上下架状态");
+        }
+        TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdWithCollection(tetherId);
+
+        if (tetherVo.getCochain() == 0 ){
+
+            return error("此套系为上链状态禁止上架");
+        }
+        if (tetherVo.getGrounding() == 0){
+            return error("禁止重复上架");
+        }
+        return toAjax(poTetherService.updatePoTetherIsGrounding(grounding,tetherId));
+    }
+
+
+
 }
 

+ 18 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoTetherMapper.java

@@ -108,7 +108,7 @@ public interface PoTetherMapper
      * @param tetherId
      * @return
      */
-    PoTether checkPostTetherTitleUnique(Long tetherId);
+    PoTether checkPostTetherTitleUnique(String tetherId);
 
     /**
      * 检验图片是否重复
@@ -117,4 +117,21 @@ public interface PoTetherMapper
      */
     PoTether checkPostTetherImageUnique(String image);
 
+    PoTether selectPoTetherByTetherIds(Long[] tetherIds);
+
+    /**
+     * 修改状态 是否上链
+     * @param cochain
+     * @param tetherId
+     * @return
+     */
+    boolean updatePoTetherIsCochain( @Param("cochain") Integer cochain, @Param("tetherId") Long tetherId);
+
+    /**
+     * 状态修改 是否上架
+     * @param grounding
+     * @param tetherId
+     * @return
+     */
+    boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId);
 }

+ 24 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoTetherService.java

@@ -84,6 +84,8 @@ public interface IPoTetherService
 
     boolean updatePoTetherWithCollection(TetherVo tetherVo);
 
+
+
     /**
      * 同时删除套系和藏品的关联关系
      * @param tetherIds
@@ -105,5 +107,27 @@ public interface IPoTetherService
      */
     String checkPostTetherImageUnique(TetherVo tetherVo);
 
+    /**
+     * 批量查询套系信息
+     * @param tetherIds
+     * @return
+     */
+    TetherVo selectPoTetherByTetherIdsWithCollection(Long[] tetherIds);
+
+    /**
+     * 修改状态 是否上链
+     * @param cochain
+     * @param tetherId
+     * @return
+     */
+    boolean updatePoTetherIsCochain(Integer cochain, Long tetherId);
+
+    /**
+     * 修改状态 是否上架
+     * @param grounding
+     * @param tetherId
+     * @return
+     */
+    boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId);
 }
 

+ 49 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoTetherServiceImpl.java

@@ -163,7 +163,9 @@ public class PoTetherServiceImpl implements IPoTetherService
         //查询套系基本信息 po_tether
         PoTether poTether = this.poTetherMapper.selectPoTetherByTetherId(tetherId);
         TetherVo tetherVo = new TetherVo();
-        BeanUtils.copyProperties(poTether,tetherVo);
+        if (poTether != null) {
+            BeanUtils.copyProperties(poTether, tetherVo);
+        }
         //查询当前套系对应的藏品信息
         //后续添加代码
         return  tetherVo;
@@ -183,6 +185,7 @@ public class PoTetherServiceImpl implements IPoTetherService
         return true;
     }
 
+
     /**
      * 同时删除套系和藏品的关联关系
      * @param tetherIds
@@ -201,16 +204,16 @@ public class PoTetherServiceImpl implements IPoTetherService
      * @param tetherVo
      * @return
      */
+
     @Override
     public String checkPostTetherNameUnique(TetherVo tetherVo) {
         Long tetherId = StringUtils.isNull(tetherVo.getTetherId()) ? -1L : tetherVo.getTetherId();
-        PoTether info = poTetherMapper.checkPostTetherTitleUnique(tetherVo.getTetherId());
+        PoTether info = poTetherMapper.checkPostTetherTitleUnique(tetherVo.getTetherName());
         if (StringUtils.isNotNull(info) && info.getTetherId() != tetherId) {
             return UserConstants.NOT_UNIQUE;
         }
             return UserConstants.UNIQUE;
     }
-
     /**
      * 检验图片是否重复
      * @param tetherVo
@@ -229,5 +232,48 @@ public class PoTetherServiceImpl implements IPoTetherService
 
     }
 
+    /**
+     * 批量查询套系信息
+     * @param tetherIds
+     * @return
+     */
+    @Override
+    public TetherVo selectPoTetherByTetherIdsWithCollection(Long[] tetherIds) {
+
+        //查询套系基本信息 po_tether
+        PoTether poTether = this.poTetherMapper.selectPoTetherByTetherIds(tetherIds);
+        TetherVo tetherVo = new TetherVo();
+        if (poTether != null) {
+            BeanUtils.copyProperties(poTether, tetherVo);
+        }
+        //查询当前套系对应的藏品信息
+        //后续添加代码
+        return  tetherVo;
+    }
+
+    /**
+     * 修改状态 是否上链
+     * @param cochain
+     * @param tetherId
+     * @return
+     */
+    @Override
+    public boolean updatePoTetherIsCochain(Integer cochain, Long tetherId) {
+
+       return  poTetherMapper.updatePoTetherIsCochain(cochain,tetherId);
+
+    }
+
+    /**
+     * 修改状态 是否上架
+     * @param grounding
+     * @param tetherId
+     * @return
+     */
+    @Override
+    public boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId) {
+        return poTetherMapper.updatePoTetherIsGrounding(grounding,  tetherId);
+    }
+
 }
 

+ 21 - 3
ruoyi-system/src/main/resources/mapper/system/PoTetherMapper.xml

@@ -141,15 +141,24 @@
     </select>
 
 <!--    检验标题是否重复-->
-    <select id="checkPostTetherTitleUnique" resultType="PoTether" resultMap="PoTetherResult">
+    <select id="checkPostTetherTitleUnique" resultType="String" resultMap="PoTetherResult">
         select tether_id, tether_name from po_tether where tether_name = #{tetherName} and del_flag = '0' limit 1
     </select>
 
 <!--    检验图片是否重复-->
-    <select id="checkPostTetherImageUnique" resultType="PoTether" resultMap="PoTetherResult">
+    <select id="checkPostTetherImageUnique" resultType="String" resultMap="PoTetherResult">
         select tether_id,image from po_tether where image = #{image} and del_flag = '0' limit 1
     </select>
 
+<!--    通过id批量查询套系信息-->
+    <select id="selectPoTetherByTetherIds" resultType="PoTether">
+        <include refid="selectPoTetherVo"/>
+        where tether_id in
+        <foreach item="tetherId" collection="array" open="(" separator="," close=")">
+            #{tetherId}
+        </foreach>
+    </select>
+
     <!--新增-->
     <insert id="insertPoTether" parameterType="PoTether" useGeneratedKeys="true" keyProperty="tetherId">
         insert into po_tether
@@ -208,7 +217,7 @@
         where tether_id = #{tetherId}
     </update>
 
-
+<!--通过Id删除-->
     <delete id="deletePoTetherByTetherId" parameterType="Long">
         delete from po_tether where tether_id = #{tetherId}
     </delete>
@@ -220,5 +229,14 @@
             #{tetherId}
         </foreach>
     </update>
+
+<!--    修改状态 是否上链-->
+    <update id="updatePoTetherIsCochain" parameterType="PoTether">
+        update po_tether set cochain = #{cochain} where tether_id = #{tetherId}
+    </update>
+<!--    修改状态 是否上架-->
+    <update id="updatePoTetherIsGrounding" parameterType="PoTether">
+        update po_tether set grounding = #{grounding} where tether_id = #{tetherId}
+    </update>
 </mapper>