Эх сурвалжийг харах

Merge branch 'blue' of http://39.105.160.25:10880/post-project-api/post into blue

tangzetong 2 жил өмнө
parent
commit
caa33d817a

+ 1 - 0
docker-compose.yml

@@ -1,3 +1,4 @@
+version: "3"
 services:
   post-project-api:
     image: ${BRANCH_NAME}:${BUILD_NUMBER}

+ 23 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SpringTaskConfig.java

@@ -0,0 +1,23 @@
+package com.ruoyi.web.controller.common;
+
+
+import com.ruoyi.system.mapper.PoTetherMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.util.Date;
+
+@Configuration
+@EnableScheduling
+public class SpringTaskConfig {
+    @Autowired
+    PoTetherMapper poTetherMapper;
+
+    @Scheduled(cron = "0/5 * * * * ?")
+    public  void cron() {
+      Integer i =  poTetherMapper.updateSellStatus();
+      System.out.println(i);
+    }
+}

+ 13 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoTetherController.java

@@ -62,7 +62,7 @@ public class PoTetherController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:tether:list')")
     @GetMapping("/list")
-    @ApiOperation("查询套系列表 在售")
+    @ApiOperation("查询套系列表 数量")
     public TableDataInfo Total(PoTether poTether)
     {
         startPage();
@@ -218,6 +218,8 @@ public class PoTetherController extends BaseController
             //已经上架只可以修改展示结束的时间
             poTetherService.updateShowTimeEnd(tetherVo);
         }else{
+            tetherVo.setUpdateBy(getUsername());
+            tetherVo.setUpdateTime(new Date());
             poTetherService.updatePoTetherWithCollection(tetherVo);
         }
         return success("修改成功");
@@ -251,9 +253,13 @@ public class PoTetherController extends BaseController
         }
 
         TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdWithCollection(tetherId);
-        if (tetherVo.getCochain() == 0){
+        if (tetherVo.getCochain() == 0 && cochain == 0){
             return error("禁止重复上链");
         }
+        if (tetherVo.getCochain() == 1 && cochain == 1){
+            return error("禁止重复下链");
+        }
+
         return toAjax(poTetherService.updatePoTetherIsCochain(cochain,tetherId));
     }
     /**
@@ -269,13 +275,16 @@ public class PoTetherController extends BaseController
         }
         TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdWithCollection(tetherId);
 
-        if (tetherVo.getCochain() == 0 ){
+        if (tetherVo.getCochain() == 0){
 
             return error("此套系为上链状态禁止上架");
         }
-        if (tetherVo.getGrounding() == 0){
+        if (tetherVo.getGrounding() == 0  && grounding == 0 ){
             return error("禁止重复上架");
         }
+        if (tetherVo.getGrounding() == 1  && grounding == 1 ){
+            return error("禁止重复下架");
+        }
         return toAjax(poTetherService.updatePoTetherIsGrounding(grounding,tetherId));
     }
 

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

@@ -136,7 +136,7 @@ public interface PoTetherMapper extends BaseMapper<PoTether>
      * @param tetherId
      * @return
      */
-    boolean updatePoTetherIsGrounding(Integer grounding, Long tetherId);
+    boolean updatePoTetherIsGrounding(@Param("grounding")Integer grounding,@Param("tetherId") Long tetherId);
 
     /**
      * 更新种类
@@ -156,4 +156,6 @@ public interface PoTetherMapper extends BaseMapper<PoTether>
      * @param tetherVo
      */
     void updateShowTimeEnd(TetherVo tetherVo);
+
+    Integer updateSellStatus();
 }

+ 38 - 27
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoTetherServiceImpl.java

@@ -156,18 +156,25 @@ public class PoTetherServiceImpl extends ServiceImpl<PoTetherMapper,PoTether> im
     @Override
     @Transactional
     public void insertPoTetherWithCollection(TetherVo tetherVo) {
-        //保存套系的基本数据到套系表tether
-        this.poTetherMapper.insertPoTether(tetherVo);
-        //套系包含藏品
-        //保存藏品数据到中间表 批量增加
-        System.out.println(tetherVo.getPoTetherandcollections().size());
-        for (int i = 0 ; i < tetherVo.getPoTetherandcollections().size();i++) {
-            System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
-            PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
-            poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
-            poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
-            poTetherandcollection1.setTetherId(tetherVo.getTetherId());
-            poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+        if (tetherVo.getPoTetherandcollections() == null){
+            //保存套系的基本数据到套系表tether
+            this.poTetherMapper.insertPoTether(tetherVo);
+        }else {
+
+            this.poTetherMapper.insertPoTether(tetherVo);
+            //套系包含藏品
+            //保存藏品数据到中间表 批量增加
+            System.out.println(tetherVo.getPoTetherandcollections().size());
+
+
+            for (int i = 0; i < tetherVo.getPoTetherandcollections().size(); i++) {
+                System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+                PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
+                poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+                poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
+                poTetherandcollection1.setTetherId(tetherVo.getTetherId());
+                poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+            }
         }
     }
     /**
@@ -194,24 +201,28 @@ public class PoTetherServiceImpl extends ServiceImpl<PoTetherMapper,PoTether> im
     @Override
     @Transactional
     public void updatePoTetherWithCollection(TetherVo tetherVo) {
-        //更新po_tether表基本信息
-        this.poTetherMapper.updatePoTether(tetherVo);
-        //清理po_collection表数据
-        LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(PoTetherandcollection::getTetherId,tetherVo.getTetherId());
-        poTetherandcollectionService.remove(lambdaQueryWrapper);
-//        //添加当前提交过来的藏品数据--po_Tetherandcollection表的insert操作
+        if (tetherVo.getPoTetherandcollections() == null){
+            //更新po_tether表基本信息
+            this.poTetherMapper.updatePoTether(tetherVo);
+        }
+       else {
 
-        for (int i = 0 ; i < tetherVo.getPoTetherandcollections().size();i++) {
+            this.poTetherMapper.updatePoTether(tetherVo);
+            //清理po_collection表数据
+            LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(PoTetherandcollection::getTetherId, tetherVo.getTetherId());
+            poTetherandcollectionService.remove(lambdaQueryWrapper);
+//        //添加当前提交过来的藏品数据--po_Tetherandcollection表的insert操作
 
-            System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
-            PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
-            poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
-            poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
-            poTetherandcollection1.setTetherId(tetherVo.getTetherId());
-            poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+            for (int i = 0; i < tetherVo.getPoTetherandcollections().size(); i++) {
+                System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+                PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
+                poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+                poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
+                poTetherandcollection1.setTetherId(tetherVo.getTetherId());
+                poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+            }
         }
-
     }
 
 

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

@@ -296,5 +296,13 @@
         </trim>
         where tether_id = #{tetherId}
     </update>
+
+    <update id="updateSellStatus">
+        update po_tether set sell_status =
+            case when now() > show_time_end then 2
+                 when show_time_start > now() then 1
+                 when now() > show_time_start and show_time_end > now() then 0
+                 END;
+    </update>
 </mapper>