deason 6 lat temu
rodzic
commit
b368f2dba3

+ 9 - 0
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/repository/ProjectBackupSettingRepository.java

@@ -10,9 +10,18 @@ package cn.com.qmth.examcloud.core.print.repository;
 import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 @Repository
 public interface ProjectBackupSettingRepository extends JpaRepository<ProjectBackupSetting, Long>, JpaSpecificationExecutor<ProjectBackupSetting> {
 
+    @Transactional
+    @Modifying
+    @Query("delete from ProjectBackupSetting where projectId=:projectId")
+    int deleteByProjectId(@Param("projectId") Long projectId);
+
 }

+ 7 - 0
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/ProjectBackupSettingController.java

@@ -44,4 +44,11 @@ public class ProjectBackupSettingController extends ControllerSupport {
         return success();
     }
 
+    @PostMapping("/delete/{projectId}")
+    @ApiOperation(value = "清除某个项目的备份设置信息")
+    public Result delete(@PathVariable Long projectId) {
+        projectBackupSettingService.removeProjectBackupSettingById(projectId);
+        return success();
+    }
+
 }

+ 5 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/ProjectBackupSettingService.java

@@ -25,4 +25,9 @@ public interface ProjectBackupSettingService {
      */
     void saveProjectBackupSetting(ProjectBackupSetting info);
 
+    /**
+     * 清除某个项目的备份设置信息
+     */
+    void removeProjectBackupSettingById(Long projectId);
+
 }

+ 6 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/ProjectBackupSettingServiceImpl.java

@@ -67,4 +67,10 @@ public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingServ
         projectBackupSettingRepository.save(info);
     }
 
+    @Override
+    public void removeProjectBackupSettingById(Long projectId) {
+        Check.isNull(projectId, "项目ID不能为空!");
+        projectBackupSettingRepository.deleteByProjectId(projectId);
+    }
+
 }

+ 5 - 0
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/ProjectSettingServiceTest.java

@@ -48,6 +48,11 @@ public class ProjectSettingServiceTest extends BaseTest {
         System.out.println(jsonMapper.toJson(setting));
     }
 
+    @Test
+    public void removeProjectBackupSettingTest() throws Exception {
+        projectBackupSettingService.removeProjectBackupSettingById(1L);
+    }
+
     @Test
     public void saveProjectOtherSettingTest() throws Exception {
         ProjectOtherSetting setting = new ProjectOtherSetting();