|
@@ -1,8 +1,17 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.service.impl;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamStageRepo;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStageEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.ExamStageService;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @Description 场次
|
|
|
* @Author lideyin
|
|
@@ -12,4 +21,23 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class ExamStageServiceImpl implements ExamStageService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExamStageRepo examStageRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<Long, ExamStageEntity> getExamStageMapsByIds(Set<Long> examStageIds) {
|
|
|
+ if (CollectionUtils.isEmpty(examStageIds)) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ Specification<ExamStageEntity> spec = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(root.get("id").in(examStageIds));
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ List<ExamStageEntity> entities = examStageRepo.findAll(spec);
|
|
|
+ return entities.stream().collect(Collectors.toMap(v -> v.getId(), v -> v, (k, v) -> v));
|
|
|
+ }
|
|
|
+
|
|
|
}
|