|
@@ -1,9 +1,13 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -13,11 +17,13 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.CountStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.SaveStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.UnbindStudentCodeReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.UpdatePasswordReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.UpdateStudentStatusReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.CountStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.UnbindStudentCodeResp;
|
|
@@ -238,4 +244,24 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "统计学生")
|
|
|
+ @PostMapping("countStudent")
|
|
|
+ @Override
|
|
|
+ public CountStudentResp countStudent(@RequestBody CountStudentReq req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+
|
|
|
+ Specification<StudentEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ long count = studentRepo.count(specification);
|
|
|
+
|
|
|
+ CountStudentResp resp = new CountStudentResp();
|
|
|
+ resp.setCount(count);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
}
|