This commit is contained in:
2026-08-31 10:21:52 +08:00
parent 7c6f93e68d
commit d3a9930751
8 changed files with 475 additions and 0 deletions
@@ -0,0 +1,51 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchTeacher;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
import com.yunhai.bschclassmanage.service.ISchTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** Compatibility endpoints used by BestSchool.IBaseClass.BLL.DbClass consumers. */
@RestController
@RequestMapping(Config.OAPI + "/DbClass/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class DbClassController {
@Autowired private ISchTeacherService schTeacherService;
@Autowired private ISchInfoService schInfoService;
@GetMapping("GetSchteaList")
public ResponseEntity<List<Map<String, Object>>> getSchteaList(@RequestParam("Group") Integer group) {
if (group == null || group <= 0) return ResponseEntity.badRequest().build();
SchInfoVO school = schInfoService.GetSchFirst(group);
String schSerId = school == null ? null : school.getSchSerId();
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(group);
if (teachers == null || teachers.isEmpty()) return ResponseEntity.ok(Collections.emptyList());
List<Map<String, Object>> result = teachers.stream().map(teacher -> {
Map<String, Object> row = new LinkedHashMap<>();
row.put("SchSerID", schSerId);
row.put("TeaTel", teacher.getTel());
row.put("TeaName", teacher.getName());
row.put("UserTeaSerID", teacher.getTeaId());
row.put("TeaIDCard", teacher.getIdCard());
row.put("TeaNo", teacher.getSort());
return row;
}).collect(Collectors.toList());
return ResponseEntity.ok(result);
}
}
@@ -0,0 +1,20 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.config.Config;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
@RequestMapping(Config.OAPI+"/Common/FamCom/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class FamilyCompatController {
@PostMapping("GetStuUserFamIDList")
public ResponseEntity<List<String>> getStuUserFamIdList(@RequestBody(required=false) String stuIds) {
return ResponseEntity.ok(Collections.emptyList());
}
@PostMapping("GetAllStuFamMem")
public ResponseEntity<List<Map<String,Object>>> getAllStuFamMem(@RequestBody(required=false) String stuIds) {
return ResponseEntity.ok(Collections.emptyList());
}
}
@@ -0,0 +1,51 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.entity.*;
import java.util.*;
final class OaCompatSupport {
private OaCompatSupport() { }
static List<Integer> ints(String value) {
if (value == null || value.trim().isEmpty()) return Collections.emptyList();
List<Integer> out = new ArrayList<>();
for (String token : value.split(",")) try { out.add(Integer.valueOf(token.trim())); } catch (NumberFormatException ignored) { }
return out;
}
static List<String> strings(String value) {
if (value == null || value.trim().isEmpty()) return Collections.emptyList();
List<String> out = new ArrayList<>();
for (String token : value.split(",")) if (!token.trim().isEmpty()) out.add(token.trim());
return out;
}
static Map<String,Object> student(SchStudent s, String schSerId, String classId) {
Map<String,Object> m = new LinkedHashMap<>();
m.put("Account", s.getAccount()); m.put("UserStuSerID", s.getStuId()); m.put("StuName", s.getName());
m.put("StuIDCard", s.getIdCard()); m.put("StuSex", s.getGender() == null ? null : String.valueOf(s.getGender()));
m.put("StuStatus", s.getStatus() == null ? null : String.valueOf(s.getStatus())); m.put("ClassID", classId);
m.put("ClassStuID", s.getStuClassNo()); m.put("GroupID", s.getGroupId()); m.put("StuPhoto", null);
m.put("CardID", null); m.put("StuCurrentTel", null); m.put("invitecode", s.getInvitationCode());
m.put("SchSerID", schSerId == null ? null : schSerId.toLowerCase(Locale.ROOT)); m.put("Graduated", false); m.put("isjiedu", 0);
return m;
}
static Map<String,Object> electiveStudent(SchStudent s, String schSerId, String classId) {
Map<String,Object> m = student(s, schSerId, classId);
m.put("StuSex", s.getGender()); m.put("electiveId", 0); m.put("schoolId", s.getSchId());
return m;
}
static Map<String,Object> classInfo(SchClass c, String schSerId) {
Map<String,Object> m = new LinkedHashMap<>();
m.put("Id", c.getId()); m.put("Name", c.getName()); m.put("OwnerId", c.getSchId()); m.put("Levell", c.getGradeId());
m.put("sx", c.getSort()); m.put("SchSerID", schSerId); m.put("ClassID", c.getClassId()); m.put("UserClassID", c.getClassId());
m.put("Schooling", null); m.put("MajorCode", null); m.put("ClassCode", c.getCode()); m.put("ClassMotto", null);
m.put("ClassName", c.getCname() == null ? c.getName() : c.getCname()); m.put("StartDate", null);
m.put("FirstTeaUserID", c.getFirstTeacherId()); m.put("SecondTeaUserID", c.getSecondTeacherId());
m.put("UpgradeYear", null); m.put("CurrentIndex", c.getSort()); m.put("CreationTime", c.getCreateDate());
m.put("GradtionTime", c.getGraduateDate()); m.put("GreduatedYear", c.getEnrollYear()); m.put("Graduated", Boolean.TRUE.equals(c.getGraduate()));
return m;
}
static Map<String,Object> teaching(SchClassTeach t, String schSerId) {
Map<String,Object> m = new LinkedHashMap<>(); m.put("SerID", t.getId()); m.put("SchSerID", schSerId);
m.put("UserTeaSerID", t.getTeaId()); m.put("SubID", t.getSubId()); m.put("ClassID", t.getClassId());
m.put("UserClassID", t.getClassId()); m.put("CreationTime", t.getCreateDate()); m.put("static", false); return m;
}
}
@@ -0,0 +1,58 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
import com.yunhai.bschclassmanage.service.ISchDicSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/SubInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchSubController {
@Autowired private ISchDicSubjectService subjectService;
@Autowired private SchInfoRepository schInfoRepository;
@Autowired private SchClassTeachRepository teachRepository;
@GetMapping("GetSchSublist")
public ResponseEntity<List<Map<String,Object>>> GetSchSublist(@RequestParam(required=false) String SchID, @RequestParam(required=false) Integer schooling, @RequestParam(required=false) Integer gradeId) {
if (SchID == null || SchID.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList());
Optional<SchInfo> school = schInfoRepository.findBySchSerId(SchID);
if (!school.isPresent()) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(subjectService.getSchSubList(school.get().getSchId(), schooling).stream().map(s -> subject(s, school.get().getSchSerId())).collect(Collectors.toList()));
}
@GetMapping("GetSchIdsSublist")
public ResponseEntity<List<Map<String,Object>>> GetSchIdsSublist(@RequestParam(required=false) String SchIds) {
if (SchIds == null || SchIds.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList());
List<String> ids = OaCompatSupport.strings(SchIds);
List<Map<String,Object>> out = new ArrayList<>();
for (String id : ids) schInfoRepository.findBySchSerId(id).ifPresent(s -> subjectService.getSchSubList(s.getSchId(), null).forEach(sub -> out.add(subject(sub, s.getSchSerId()))));
return ResponseEntity.ok(out);
}
@GetMapping("GetSchTeaSublist")
public ResponseEntity<List<String>> GetSchTeaSublist(@RequestParam(required=false) String UserTeaSerID) {
if (UserTeaSerID == null) return ResponseEntity.ok(Collections.emptyList());
try {
Integer teaId = Integer.valueOf(UserTeaSerID);
return ResponseEntity.ok(teachRepository.findAll().stream().filter(t -> Objects.equals(t.getTeaId(), teaId)).map(SchClassTeach::getSubId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
} catch (NumberFormatException e) { return ResponseEntity.ok(Collections.emptyList()); }
}
@GetMapping("GetSchTeachSublist")
public ResponseEntity<List<String>> GetSchTeachSublist(@RequestParam(required=false) String SchID) {
if (SchID == null) return ResponseEntity.ok(Collections.emptyList());
Optional<SchInfo> school = schInfoRepository.findBySchSerId(SchID);
if (!school.isPresent()) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(teachRepository.findAll().stream().filter(t -> Objects.equals(t.getSchId(), school.get().getSchId())).map(SchClassTeach::getSubId).filter(Objects::nonNull).map(s -> s.toLowerCase(Locale.ROOT)).distinct().collect(Collectors.toList()));
}
private Map<String,Object> subject(SchDicSubject s, String schSerId) {
Map<String,Object> m = new LinkedHashMap<>(); m.put("SchSerID", schSerId); m.put("SubID", s.getCode() == null ? String.valueOf(s.getId()) : s.getCode()); m.put("SubName", s.getName()); m.put("No", s.getSort()); return m;
}
}
@@ -0,0 +1,81 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
import com.yunhai.bschclassmanage.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/Schoolen/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchoolingController {
@Autowired private ISchInfoService schInfoService;
@Autowired private IBaseSchsystemGradeService gradeService;
@Autowired private BaseSchsystemGradeRepository gradeRepository;
@Autowired private BaseSchsystemRepository schoolingRepository;
@Autowired private SchInfoRepository schInfoRepository;
@Autowired private SchClassRepository classRepository;
@Autowired private SchClassTeachRepository teachingRepository;
@Autowired private SchTeacherRepository teacherRepository;
@Autowired private SchDicSubjectRepository subjectRepository;
@GetMapping("GetSchLenLevellist")
public ResponseEntity<List<Map<String,Object>>> GetSchLenLevellist(@RequestParam(required=false) String SchSerID) {
if (SchSerID == null || SchSerID.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList());
SchInfoVOHolder school = findSchool(SchSerID);
if (school == null) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(gradeService.getSchGradeCacheList(school.id, null, null).stream().map(this::grade).collect(Collectors.toList()));
}
@GetMapping("GetLevelIdlist")
public ResponseEntity<List<Map<String,Object>>> GetLevelIdlist(@RequestParam(required=false) Integer Schooling) {
if (Schooling == null || Schooling == 0) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(gradeRepository.findBySchSystemId(Schooling).stream().map(this::grade).collect(Collectors.toList()));
}
@GetMapping("GetSchLenLevelFirst")
public ResponseEntity<Map<String,Object>> GetSchLenLevelFirst(@RequestParam(required=false) String GradeId) {
if (GradeId == null) return ResponseEntity.ok(null);
try {
Integer id = Integer.valueOf(GradeId);
return ResponseEntity.ok(gradeRepository.findById(id).map(this::grade).orElse(null));
} catch (NumberFormatException e) { return ResponseEntity.ok(null); }
}
@GetMapping("GetSchLenlist")
public ResponseEntity<List<Map<String,Object>>> GetSchLenlist(@RequestParam(required=false) String SchSerID) {
if (SchSerID == null || SchSerID.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList());
SchInfoVOHolder school = findSchool(SchSerID);
if (school == null) return ResponseEntity.ok(Collections.emptyList());
List<Integer> ids = gradeService.getSchGradeCacheList(school.id, null, null).stream().map(BaseSchsystemGrade::getSchSystemId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
return ResponseEntity.ok(schoolingRepository.findAllById(ids).stream().map(this::schooling).collect(Collectors.toList()));
}
@GetMapping("GetAllClassSubject")
public ResponseEntity<List<Map<String,Object>>> GetAllClassSubject(@RequestParam(required=false) Integer schId, @RequestParam(required=false) String schserid, @RequestParam(required=false) String startTime) {
return ResponseEntity.ok(Collections.emptyList());
}
private String schoolSer(Integer id) { return id == null ? null : schInfoRepository.findBySchId(id).map(SchInfo::getSchSerId).orElse(null); }
private Map<String,Object> grade(BaseSchsystemGrade g) {
Map<String,Object> m = new LinkedHashMap<>(); m.put("Id", g.getGradeId()); m.put("Name", g.getGradeNickname());
m.put("OwnerId", g.getSchSystemId()); m.put("Levell", g.getGradeId()); m.put("code", g.getGradeId()); m.put("sx", g.getGradeId()); return m;
}
private Map<String,Object> schooling(BaseSchsystem s) {
Map<String,Object> m = new LinkedHashMap<>(); m.put("Id", s.getId()); m.put("Name", s.getName()); m.put("FormerName", null); m.put("Type", s.getType()); return m;
}
private SchInfoVOHolder findSchool(String serId) {
return schInfoRepository.findBySchSerId(serId).map(s -> new SchInfoVOHolder(s.getSchId())).orElse(null);
}
private static final class SchInfoVOHolder { final Integer id; SchInfoVOHolder(Integer id) { this.id=id; } }
}
@@ -0,0 +1,90 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/OAStu/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class StuInfoController {
@Autowired private SchStudentRepository studentRepository;
@Autowired private SchInfoRepository schoolRepository;
@Autowired private SchStudentHistoryRepository historyRepository;
@GetMapping("GetAllStulist")
public ResponseEntity<List<Map<String,Object>>> GetAllStulist() { return ResponseEntity.ok(students(studentRepository.findAll(), null)); }
@GetMapping("GetEleAllStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleAllStulist() { return ResponseEntity.ok(studentRepository.findAll().stream().map(s -> OaCompatSupport.electiveStudent(s, schoolSer(s.getSchId()), String.valueOf(s.getClassId()))).collect(Collectors.toList())); }
@GetMapping("GetSchStulist")
public ResponseEntity<List<Map<String,Object>>> GetSchStulist(@RequestParam(required=false) String schserid, @RequestParam(required=false) String schgroupid) {
return ResponseEntity.ok(filter(schserid, schgroupid, null, null));
}
@GetMapping("GetEleSchStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchStulist(@RequestParam(required=false) String schserid, @RequestParam(required=false) String schgroupid) {
return ResponseEntity.ok(filter(schserid, schgroupid, null, null).stream().map(m -> m).collect(Collectors.toList()));
}
@GetMapping("GetClaStulist")
public ResponseEntity<List<Map<String,Object>>> GetClaStulist(@RequestParam(required=false) String ClassID, @RequestParam(required=false) String clagroupid) { return ResponseEntity.ok(filter(null, null, ClassID, clagroupid)); }
@GetMapping("GetEleClaStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleClaStulist(@RequestParam(required=false) String ClassID, @RequestParam(required=false) String clagroupid) { return ResponseEntity.ok(filter(null, null, ClassID, clagroupid)); }
@GetMapping("GetClaArrStulist")
public ResponseEntity<List<Map<String,Object>>> GetClaArrStulist(@RequestParam(required=false) String ClassIDs, @RequestParam(required=false) String clagroupids) { return ResponseEntity.ok(filterArrays(ClassIDs, clagroupids)); }
@GetMapping("GetEleClaArrStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleClaArrStulist(@RequestParam(required=false) String ClassIDs, @RequestParam(required=false) String clagroupids) { return ResponseEntity.ok(filterArrays(ClassIDs, clagroupids)); }
@GetMapping("GetStuIdslist")
public ResponseEntity<List<Map<String,Object>>> GetStuIdslist(@RequestParam(required=false) String stuids) {
Set<Integer> ids = new HashSet<>(OaCompatSupport.ints(stuids));
return ResponseEntity.ok(students(studentRepository.findAll().stream().filter(s -> ids.contains(s.getStuId())).collect(Collectors.toList()), null));
}
@GetMapping("GetEleStuIdslist")
public ResponseEntity<List<Map<String,Object>>> GetEleStuIdslist(@RequestParam(required=false) String stuids) { return GetStuIdslist(stuids); }
@GetMapping("GetStuUserFamIDList")
public ResponseEntity<List<String>> GetStuUserFamIDList(@RequestParam(required=false) String stuids) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("GetFamStulist")
public ResponseEntity<List<Map<String,Object>>> GetFamStulist(@RequestParam(required=false) String invitecodes) {
Set<String> codes = new HashSet<>(OaCompatSupport.strings(invitecodes));
return ResponseEntity.ok(students(studentRepository.findAll().stream().filter(s -> codes.contains(s.getInvitationCode())).collect(Collectors.toList()), null));
}
@GetMapping("GetStuFamMem")
public ResponseEntity<List<Map<String,Object>>> GetAllStuFamMem(@RequestParam(required=false) String SchSerID) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("GetSchBySchIds")
public ResponseEntity<List<Map<String,Object>>> GetSchIdsStulist(@RequestParam(required=false) String schserids) {
Set<Integer> ids = new HashSet<>(); for (String id : OaCompatSupport.strings(schserids)) schoolRepository.findBySchSerId(id).ifPresent(s -> ids.add(s.getSchId()));
return ResponseEntity.ok(students(studentRepository.findAll().stream().filter(s -> ids.contains(s.getSchId())).collect(Collectors.toList()), null));
}
@GetMapping("GetEleSchIdsStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchIdsStulist(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); }
@GetMapping("GetEleSchBySchIds")
public ResponseEntity<List<Map<String,Object>>> GetEleSchBySchIds(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); }
@GetMapping("GetStudentsByElectiveId")
public ResponseEntity<List<Map<String,Object>>> GetStudentsByElectiveId(@RequestParam(required=false) Integer electiveIds) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("getHistoryStudentsBySchoolId")
public ResponseEntity<List<Map<String,Object>>> getHistoryStudentsBySchoolId(@RequestParam Integer schoolId, @RequestParam Integer year) {
return ResponseEntity.ok(historyRepository.findAll().stream().filter(h -> Objects.equals(h.getSchId(), schoolId) && Objects.equals(h.getYear(), year)).map(this::history).collect(Collectors.toList()));
}
@GetMapping("getHistoryClass")
public ResponseEntity<List<Map<String,Object>>> getHistoryClass(@RequestParam Integer schoolId, @RequestParam Integer year) { return ResponseEntity.ok(Collections.emptyList()); }
private List<Map<String,Object>> filter(String schserid, String schgroupid, String classId, String classGroupId) {
Integer schId = schserid == null ? null : schoolRepository.findBySchSerId(schserid).map(SchInfo::getSchId).orElse(null);
Integer cls = firstInt(classId != null ? classId : classGroupId);
return students(studentRepository.findAll().stream().filter(s -> (schId == null || Objects.equals(s.getSchId(), schId)) && (cls == null || Objects.equals(s.getClassId(), cls) || Objects.equals(s.getGroupId(), cls))).collect(Collectors.toList()), schserid);
}
private List<Map<String,Object>> filterArrays(String classIds, String groupIds) {
Set<Integer> ids = new HashSet<>(OaCompatSupport.ints(classIds)); ids.addAll(OaCompatSupport.ints(groupIds));
return students(studentRepository.findAll().stream().filter(s -> ids.contains(s.getClassId()) || ids.contains(s.getGroupId())).collect(Collectors.toList()), null);
}
private List<Map<String,Object>> students(List<SchStudent> list, String schserid) { return list.stream().map(s -> OaCompatSupport.student(s, schserid == null ? schoolSer(s.getSchId()) : schserid, String.valueOf(s.getClassId()))).collect(Collectors.toList()); }
private String schoolSer(Integer id) { return id == null ? null : schoolRepository.findBySchId(id).map(SchInfo::getSchSerId).orElse(null); }
private Integer firstInt(String s) { try { return s == null ? null : Integer.valueOf(s); } catch (Exception e) { return null; } }
private Map<String,Object> history(SchStudentHistory h) { Map<String,Object> m = new LinkedHashMap<>(); m.put("stuId", h.getStuId()); m.put("stuName", h.getName()); m.put("classId", h.getClassId()); m.put("className", null); m.put("grade", h.getGradeId()); m.put("name", null); m.put("school_system_id", h.getSchId()); m.put("system_grade", h.getGradeId()); return m; }
}
@@ -0,0 +1,48 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/TeachInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class TeaChesController {
@Autowired private SchClassTeachRepository teachingRepository;
@Autowired private SchInfoRepository schoolRepository;
@GetMapping("GetSchTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetSchTeach(@RequestParam(required=false) String SchID, @RequestParam(required=false) Integer UserTeaSerID) {
Integer schId = SchID == null ? null : schoolRepository.findBySchSerId(SchID).map(SchInfo::getSchId).orElse(null);
return ResponseEntity.ok(teachingRepository.findAll().stream().filter(t -> (schId == null || Objects.equals(t.getSchId(), schId)) && (UserTeaSerID == null || Objects.equals(t.getTeaId(), UserTeaSerID))).map(t -> OaCompatSupport.teaching(t, schoolSer(t.getSchId()))).collect(Collectors.toList()));
}
@GetMapping("GetEleSchTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchTeachlist(@RequestParam(required=false) String SchID, @RequestParam(required=false) Integer UserTeaSerID) { return GetSchTeach(SchID, UserTeaSerID); }
@GetMapping("GetSchArrTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetSchArrTeach(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); }
@GetMapping("GetEleSchArrTeachList")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrTeachList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); }
@GetMapping("GetSchClaTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetClassTeach(@RequestParam(required=false) String ClassID) {
Integer classId = intValue(ClassID);
return ResponseEntity.ok(teachingRepository.findAll().stream().filter(t -> classId != null && Objects.equals(t.getClassId(), classId)).map(t -> OaCompatSupport.teaching(t, schoolSer(t.getSchId()))).collect(Collectors.toList()));
}
@GetMapping("GetEleSchClaTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchClaTeachlist(@RequestParam(required=false) String ClassID) { return GetClassTeach(ClassID); }
@GetMapping("GetElectiveClassByGrade")
public ResponseEntity<List<Map<String,Object>>> GetElectiveClassByGrade(@RequestParam(required=false) Integer schoolId, @RequestParam(required=false) Integer gradeId) { return ResponseEntity.ok(Collections.emptyList()); }
@PostMapping("GetElectiveClassByTeachers")
public ResponseEntity<List<Map<String,Object>>> GetElectiveClassByTeachers(@RequestBody(required=false) String teacherIds) { return ResponseEntity.ok(Collections.emptyList()); }
private ResponseEntity<List<Map<String,Object>>> bySchools(String value) {
Set<Integer> ids = new HashSet<>(); for (String ser : OaCompatSupport.strings(value)) schoolRepository.findBySchSerId(ser).ifPresent(s -> ids.add(s.getSchId()));
return ResponseEntity.ok(teachingRepository.findAll().stream().filter(t -> ids.contains(t.getSchId())).map(t -> OaCompatSupport.teaching(t, schoolSer(t.getSchId()))).collect(Collectors.toList()));
}
private Integer intValue(String s) { try { return s == null ? null : Integer.valueOf(s); } catch (Exception e) { return null; } }
private String schoolSer(Integer id) { return id == null ? null : schoolRepository.findBySchId(id).map(SchInfo::getSchSerId).orElse(null); }
}
@@ -0,0 +1,76 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/VSchClass/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class VClassController {
@Autowired private SchClassRepository classRepository;
@Autowired private SchInfoRepository schoolRepository;
@Autowired private SchClassTeachRepository teachingRepository;
@GetMapping("GetVClassList")
public ResponseEntity<List<Map<String,Object>>> GetVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); }
@GetMapping("GetEleVClassList")
public ResponseEntity<List<Map<String,Object>>> GetEleVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, true); }
@GetMapping("GetSchArrVClassList")
public ResponseEntity<List<Map<String,Object>>> GetSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, false); }
@GetMapping("GetEleSchArrVClassList")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, true); }
@GetMapping("GetFunTimeSchClass")
public ResponseEntity<List<Map<String,Object>>> GetFunTimeSchClass(@RequestParam(required=false) String time, @RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); }
@GetMapping("GetVClassFirst")
public ResponseEntity<Map<String,Object>> GetVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); }
@GetMapping("GetEleVClassFirst")
public ResponseEntity<Map<String,Object>> GetEleVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); }
@GetMapping("GetVClassIdsList")
public ResponseEntity<List<Map<String,Object>>> GetVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); }
@GetMapping("GetEleVClassIdsList")
public ResponseEntity<List<Map<String,Object>>> GetEleVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); }
@GetMapping("GetGradeClassList")
public ResponseEntity<List<Map<String,Object>>> GetGradeClassList(@RequestParam(required=false) String SchSerID, @RequestParam(required=false) Integer Schooling, @RequestParam(required=false) Integer GradeId) {
Integer schId = schoolId(SchSerID); if (schId == null) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> Objects.equals(c.getSchId(), schId) && (GradeId == null || Objects.equals(c.getGradeId(), GradeId)) && (Schooling == null || Objects.equals(c.getGradeId(), Schooling)) && !Boolean.TRUE.equals(c.getGraduate())).map(c -> OaCompatSupport.classInfo(c, SchSerID)).collect(Collectors.toList()));
}
@GetMapping("GetTeachClassArr")
public ResponseEntity<List<String>> GetTeachClassArr(@RequestParam(required=false) Integer UserTeaSerID) {
if (UserTeaSerID == null) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(teachingRepository.findAll().stream().filter(t -> Objects.equals(t.getTeaId(), UserTeaSerID)).map(SchClassTeach::getClassId).filter(Objects::nonNull).map(String::valueOf).distinct().collect(Collectors.toList()));
}
@GetMapping("GetSchArrVClassListAll")
public ResponseEntity<List<Map<String,Object>>> GetSchArrVClassListAll() { return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> !Boolean.TRUE.equals(c.getGraduate())).map(c -> OaCompatSupport.classInfo(c, schoolSer(c.getSchId()))).collect(Collectors.toList())); }
@GetMapping("GetEleSchArrVClassListAll")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrVClassListAll() { return GetSchArrVClassListAll(); }
@PostMapping("GetSchArrVClassListPost")
public ResponseEntity<List<Map<String,Object>>> GetSchArrVClassListPost(@RequestBody(required=false) String body) { return bySchools(body, false); }
@GetMapping("GetElectiveClassById")
public ResponseEntity<Map<String,Object>> GetElectiveClassById(@RequestParam(required=false) Integer electiveId) { return ResponseEntity.ok(null); }
@GetMapping("GetElectiveClassByGrade")
public ResponseEntity<List<Map<String,Object>>> GetElectiveClassByGrade(@RequestParam(required=false) Integer schoolId, @RequestParam(required=false) Integer gradeId) { return ResponseEntity.ok(Collections.emptyList()); }
@PostMapping("GetElectiveClassByTeachers")
public ResponseEntity<List<Map<String,Object>>> GetElectiveClassByTeachers(@RequestBody(required=false) String teacherIds) { return ResponseEntity.ok(Collections.emptyList()); }
private ResponseEntity<List<Map<String,Object>>> bySchool(String ser, boolean elective) {
Integer id = schoolId(ser); if (id == null) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> Objects.equals(c.getSchId(), id) && (elective || !Boolean.TRUE.equals(c.getGraduate()))).map(c -> OaCompatSupport.classInfo(c, ser)).collect(Collectors.toList()));
}
private ResponseEntity<List<Map<String,Object>>> bySchools(String value, boolean elective) {
Set<Integer> ids = new HashSet<>(); for (String ser : OaCompatSupport.strings(value)) { Integer id = schoolId(ser); if (id != null) ids.add(id); }
return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> ids.contains(c.getSchId()) && (elective || !Boolean.TRUE.equals(c.getGraduate()))).map(c -> OaCompatSupport.classInfo(c, schoolSer(c.getSchId()))).collect(Collectors.toList()));
}
private ResponseEntity<List<Map<String,Object>>> byClassIds(String value) { Set<Integer> ids = new HashSet<>(OaCompatSupport.ints(value)); return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> ids.contains(c.getClassId()) || ids.contains(c.getId())).map(c -> OaCompatSupport.classInfo(c, schoolSer(c.getSchId()))).collect(Collectors.toList())); }
private ResponseEntity<Map<String,Object>> one(String value) { Integer id = parse(value); if (id == null) return ResponseEntity.ok(null); return ResponseEntity.ok(classRepository.findAll().stream().filter(c -> Objects.equals(c.getClassId(), id)).findFirst().map(c -> OaCompatSupport.classInfo(c, schoolSer(c.getSchId()))).orElse(null)); }
private Integer schoolId(String ser) { return ser == null ? null : schoolRepository.findBySchSerId(ser).map(SchInfo::getSchId).orElse(null); }
private String schoolSer(Integer id) { return id == null ? null : schoolRepository.findBySchId(id).map(SchInfo::getSchSerId).orElse(null); }
private Integer parse(String s) { try { return s == null ? null : Integer.valueOf(s); } catch (Exception e) { return null; } }
}