yangdamao 2 жил өмнө
parent
commit
f248a60de0

+ 0 - 39
run-prod.sh

@@ -1,42 +1,3 @@
-#!/usr/bin/env bash
-# 定义应用组名
-group_name='zhongzheng'
-# 定义应用名称
-app_name='zhongzheng-saas-api'
-# 定义应用版本
-app_version='1.0-SNAPSHOT'
-# 定义应用环境
-profile_active='prod'
-echo '----copy jar----'
-docker stop ${app_name}
-echo '----stop container----'
-docker rm ${app_name}
-echo '----rm container----'
-docker rmi ${group_name}/${app_name}:${app_version}
-echo '----rm image----'
-# 打包编译docker镜像
-docker build -f /mydata/maven/build/Dockerfile -t ${group_name}/${app_name}:${app_version} .
-echo '----build image----'
-docker run -p 5055:5055 --name ${app_name} \
---restart=always \
--e 'spring.profiles.active'=${profile_active} \
--e TZ="Asia/Shanghai" \
--m 10240m \
---cpus=3 \
---log-opt max-size=50m \
---log-opt max-file=3 \
--v /etc/localtime:/etc/localtime \
--v /usr/share/fonts:/usr/share/fonts \
--v /data/logs/prod_api:/logs \
--v /mydata/app/${app_name}/logs:/var/logs \
--d ${group_name}/${app_name}:${app_version}
-echo '----start container----'
-
-echo "开始等待20秒..."
-# 1-10秒内随机
-sleep 5
-echo "等待后继续"
-
 #!/usr/bin/env bash
 # 定义应用组名
 group_admin_name='zhongzheng'

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseHandoutsMapper.java

@@ -40,4 +40,6 @@ public interface CourseHandoutsMapper extends BaseMapper<CourseHandouts> {
     @InterceptorIgnore(tenantLine = "true")
     void removeHandoutsFile(@Param("handoutsId") Long handoutsId,@Param("tenantId") Long tenantId);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<CourseHandouts> getHandoutsListByTenant(@Param("encoder") String encoder,@Param("handoutsName") String handoutsName,@Param("tenantId") Long tenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseHandoutsService.java

@@ -60,4 +60,6 @@ public interface ICourseHandoutsService extends IService<CourseHandouts> {
     List<Long> getGoodsIds(Long handoutsId, Long tenantId);
 
 	void removeHandouts(Long handoutsId, Long tenantId);
+
+    List<CourseHandouts> getHandoutsListByTenant(String encoder, String handoutsName, Long tenantId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseHandoutsServiceImpl.java

@@ -337,5 +337,10 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
         baseMapper.removeHandoutsFile(handoutsId, tenantId);
     }
 
+    @Override
+    public List<CourseHandouts> getHandoutsListByTenant(String encoder, String handoutsName, Long tenantId) {
+        return baseMapper.getHandoutsListByTenant(encoder, handoutsName, tenantId);
+    }
+
 
 }

+ 22 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -4899,10 +4899,25 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             if (ObjectUtils.isNull(goodsTwo)){
                 continue;
             }
-           List<Long> goodsIds = iCourseHandoutsService.getGoodsIds(goodsTwo.getHandoutsId(),tenantId);
-            if (goodsIds.stream().allMatch(x -> x.equals(goodsTwo.getGoodsId()))){
-                //删除讲义
-                iCourseHandoutsService.removeHandouts(goodsTwo.getHandoutsId(),tenantId);
+            Set<Long> goodsIds = new HashSet<>();
+            goodsIds.add(goodsTwo.getGoodsId());
+//            if (goodsIds.stream().allMatch(x -> x.equals(goodsTwo.getGoodsId()))){
+//                //删除讲义
+//                iCourseHandoutsService.removeHandouts(goodsTwo.getHandoutsId(),tenantId);
+//            }
+
+            //如果存在先删除掉之前的讲义
+            List<CourseHandouts> handoutsList = iCourseHandoutsService.getHandoutsListByTenant(handouts.getEncoder(),handouts.getHandoutsName(),tenantId);
+
+            if (CollectionUtils.isNotEmpty(handoutsList)){
+                handoutsList.forEach(item -> {
+                    List<Long> goodsIdsTwo = iCourseHandoutsService.getGoodsIds(item.getHandoutsId(), tenantId);
+                    if (CollectionUtils.isNotEmpty(goodsIdsTwo)){
+                        goodsIds.addAll(goodsIdsTwo);
+                    }
+                    iCourseHandoutsService.removeHandouts(item.getHandoutsId(),tenantId);
+                });
+
             }
 
             //新增
@@ -4939,7 +4954,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 handleCourseFile(courseFileList,newId,tenantId);
             }
 
-            updateHandoutsId(goodsTwo.getGoodsId(),tenantId,newId);
+            goodsIds.forEach(goodsId -> {
+                updateHandoutsId(goodsId,tenantId,newId);
+            });
         }
         return true;
     }

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseHandoutsMapper.xml

@@ -143,4 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         DELETE FROM course_file WHERE handouts_id = #{handoutsId} AND tenant_id = #{tenantId}
     </delete>
 
+    <select id="getHandoutsListByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseHandouts" >
+        SELECT * FROM `course_handouts` WHERE encoder = #{encoder} AND handouts_name = #{handoutsName} AND tenant_id = #{tenantId}
+    </select>
 </mapper>