ting.yin 7 жил өмнө
parent
commit
9e40571e93

+ 7 - 5
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -1,7 +1,5 @@
 package cn.com.qmth.examcloud.service.examwork.api;
 
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import io.swagger.annotations.ApiOperation;
 
 import java.util.Date;
@@ -11,8 +9,12 @@ import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -25,12 +27,12 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.service.examwork.entity.Exam;
 import cn.com.qmth.examcloud.service.examwork.service.ExamService;
 
-import javax.servlet.http.HttpServletRequest;
-
 /**
  * 考试服务API
  * Created by songyue on 17/1/13.
@@ -57,7 +59,7 @@ public class ExamApi {
         }else{
             return new ResponseEntity(HttpStatus.NOT_FOUND);
         }
-    	return new ResponseEntity(examService.getAllExam(examCriteria,new PageRequest(curPage,pageSize)), HttpStatus.OK);
+    	return new ResponseEntity(examService.getAllExam(examCriteria,new PageRequest(curPage,pageSize, new Sort(Direction.DESC,"id"))), HttpStatus.OK);
     }
 
     @ApiOperation(value="查询所有考试批次(包含有效)",notes = "不分页带查询")

+ 3 - 1
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamService.java

@@ -10,6 +10,8 @@ import org.springframework.data.domain.Example;
 import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
 import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
@@ -50,7 +52,7 @@ public class ExamService {
     	ExampleMatcher exampleMatcher = ExampleMatcher.matching()
                 .withMatcher("name",contains());
         Example<Exam> examExample = Example.of(examCriteria,exampleMatcher);
-        return examRepo.findAll(examExample);
+        return examRepo.findAll(examExample, new Sort(Direction.DESC,"id"));
     }
 
     /**