Browse Source

获取学校样式时,如果学校无则使用默认

wn0920
王宁 2 years ago
parent
commit
4fb0dc2265

+ 19
- 1
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolStypeService.java View File

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
13 13
 import javax.annotation.Resource;
14 14
 import java.util.ArrayList;
15 15
 import java.util.List;
16
+import java.util.Map;
16 17
 import java.util.stream.Collectors;
17 18
 
18 19
 /**
@@ -110,6 +111,23 @@ public class SchoolStypeService {
110 111
 
111 112
     //根据学校id获取列表
112 113
     public List <TSchoolStype> listAll2(TSchoolStype stype) {
113
-        return schoolStypeMapper.findAll2(stype);
114
+        List<TSchoolStype> lst = schoolStypeMapper.findAll2(stype);
115
+        List<TSchoolStype> rtnlst = new ArrayList<>();
116
+        //获取学校样式,如果学校未设置使用default设置的内容
117
+        Map<String,List<TSchoolStype>> map = lst.stream().collect(Collectors.groupingBy(TSchoolStype :: getSchooltype,Collectors.toList()));
118
+        for(Map.Entry<String, List<TSchoolStype>> entry : map.entrySet()){
119
+            List<TSchoolStype> maplist = entry.getValue();
120
+            if(maplist.size() == 1){
121
+                rtnlst.add(maplist.get(0));
122
+            }else if(maplist.size()>1){
123
+                for(TSchoolStype s : maplist){
124
+                    if(!s.getSchooldomain().equals("default")){
125
+                        rtnlst.add(s);
126
+                        break;
127
+                    }
128
+                }
129
+            }
130
+        }
131
+        return rtnlst;
114 132
     }
115 133
 }

Loading…
Cancel
Save