xiaofei 1 年間 前
コミット
01db8927c1

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientService.java

@@ -48,7 +48,7 @@ public interface ClientService {
 
     boolean updatePassword(Long userId, String password);
 
-    List<BasicSchool> listSchool(String code);
+    List<BasicSchool> listSchool();
 
     List<Map<String, String>> getPaperUrl(Long schoolId, Long printPlanId, Long examTaskId);
 

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -749,8 +749,8 @@ public class ClientServiceImpl implements ClientService {
     }
 
     @Override
-    public List<BasicSchool> listSchool(String code) {
-        return basicSchoolService.listSchool(code);
+    public List<BasicSchool> listSchool() {
+        return basicSchoolService.listSchool(null);
     }
 
     @Override

+ 10 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/client/PrintController.java

@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -274,12 +275,16 @@ public class PrintController {
     @RequestMapping(value = "/school/list", method = RequestMethod.POST)
     @Aac(strict = false, auth = false)
     public Result list(@ApiParam(value = "学校Code") @RequestParam(required = false) String code) {
-        List<BasicSchool> list = clientService.listSchool(code);
+        List<BasicSchool> list = clientService.listSchool();
+        List<BasicSchool> finalList = new ArrayList<>();
         // 指定code后,只返回code对应学校,否则查默认学校,没有默认,返回所有
-        if (CollectionUtils.isNotEmpty(list) && StringUtils.isBlank(code)) {
-            List<BasicSchool> defaultSchools = list.stream().filter(m -> m.getDefaultSchool() != null && m.getDefaultSchool()).collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(defaultSchools)) {
-                return ResultUtil.ok(defaultSchools);
+        if (CollectionUtils.isNotEmpty(list)) {
+            finalList = list.stream().filter(m -> m.getDefaultSchool() != null && m.getDefaultSchool()).collect(Collectors.toList());
+            if(CollectionUtils.isEmpty(finalList) && StringUtils.isNotBlank(code)){
+                finalList = list.stream().filter(m -> m.getCode().equals(code)).collect(Collectors.toList());
+            }
+            if (CollectionUtils.isNotEmpty(finalList)) {
+                return ResultUtil.ok(finalList);
             }
         }
         return ResultUtil.ok(list);