|
@@ -7,30 +7,63 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
|
|
import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
|
|
import cn.com.qmth.examcloud.core.print.repository.ProjectBackupSettingRepository;
|
|
import cn.com.qmth.examcloud.core.print.repository.ProjectBackupSettingRepository;
|
|
import cn.com.qmth.examcloud.core.print.service.ProjectBackupSettingService;
|
|
import cn.com.qmth.examcloud.core.print.service.ProjectBackupSettingService;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+
|
|
|
|
+import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author: fengdesheng
|
|
* @author: fengdesheng
|
|
* @since: 2018/10/17
|
|
* @since: 2018/10/17
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingService {
|
|
public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingService {
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ProjectBackupSettingServiceImpl.class);
|
|
@Autowired
|
|
@Autowired
|
|
private ProjectBackupSettingRepository projectBackupSettingRepository;
|
|
private ProjectBackupSettingRepository projectBackupSettingRepository;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ProjectBackupSetting getProjectBackupSettingById(Long id) {
|
|
|
|
- //todo
|
|
|
|
- return null;
|
|
|
|
|
|
+ public ProjectBackupSetting getProjectBackupSettingById(Long projectId) {
|
|
|
|
+ Check.isNull(projectId, "项目ID不能为空!");
|
|
|
|
+ Specification<ProjectBackupSetting> spec = SearchBuilder.EQ("projectId", projectId);
|
|
|
|
+ ProjectBackupSetting setting = projectBackupSettingRepository.findOne(spec);
|
|
|
|
+ if (setting == null) {
|
|
|
|
+ throw new StatusException(PRT_CODE_500, "当前项目的备份设置信息不存在!");
|
|
|
|
+ }
|
|
|
|
+ return setting;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void saveProjectBackupSetting(ProjectBackupSetting info) {
|
|
public void saveProjectBackupSetting(ProjectBackupSetting info) {
|
|
- //todo
|
|
|
|
|
|
+ Check.isNull(info, "备份设置的信息不能为空!");
|
|
|
|
+ Check.isNull(info.getProjectId(), "备份设置的项目ID不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgPercent(), "每袋备份比例不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgMax(), "每袋备份最大值不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgMin(), "每袋备份最小值不能为空!");
|
|
|
|
+ Check.isNull(info.getGroupType(), "单独备份归集类型不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgSinglePercent(), "单独备份比例不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgSingleMax(), "单独备份最大值不能为空!");
|
|
|
|
+ Check.isNull(info.getPkgSingleMin(), "单独备份最小值不能为空!");
|
|
|
|
+ Specification<ProjectBackupSetting> spec = SearchBuilder.EQ("projectId", info.getProjectId());
|
|
|
|
+ ProjectBackupSetting setting = projectBackupSettingRepository.findOne(spec);
|
|
|
|
+ if (setting != null) {
|
|
|
|
+ //存在记录时,则修改
|
|
|
|
+ info.setId(setting.getId());
|
|
|
|
+ info.setCreationTime(setting.getCreationTime());
|
|
|
|
+ info.setUpdateTime(new Date());
|
|
|
|
+ }
|
|
|
|
+ projectBackupSettingRepository.save(info);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|