diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/DbClassController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/DbClassController.java new file mode 100644 index 0000000..6794210 --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/DbClassController.java @@ -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>> 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 teachers = schTeacherService.getSchTeacherList(group); + if (teachers == null || teachers.isEmpty()) return ResponseEntity.ok(Collections.emptyList()); + + List> result = teachers.stream().map(teacher -> { + Map 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); + } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/FamilyCompatController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/FamilyCompatController.java new file mode 100644 index 0000000..f0ea517 --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/FamilyCompatController.java @@ -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> getStuUserFamIdList(@RequestBody(required=false) String stuIds) { + return ResponseEntity.ok(Collections.emptyList()); + } + @PostMapping("GetAllStuFamMem") + public ResponseEntity>> getAllStuFamMem(@RequestBody(required=false) String stuIds) { + return ResponseEntity.ok(Collections.emptyList()); + } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/OaCompatSupport.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/OaCompatSupport.java new file mode 100644 index 0000000..c7ccadd --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/OaCompatSupport.java @@ -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 ints(String value) { + if (value == null || value.trim().isEmpty()) return Collections.emptyList(); + List out = new ArrayList<>(); + for (String token : value.split(",")) try { out.add(Integer.valueOf(token.trim())); } catch (NumberFormatException ignored) { } + return out; + } + static List strings(String value) { + if (value == null || value.trim().isEmpty()) return Collections.emptyList(); + List out = new ArrayList<>(); + for (String token : value.split(",")) if (!token.trim().isEmpty()) out.add(token.trim()); + return out; + } + static Map student(SchStudent s, String schSerId, String classId) { + Map 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 electiveStudent(SchStudent s, String schSerId, String classId) { + Map m = student(s, schSerId, classId); + m.put("StuSex", s.getGender()); m.put("electiveId", 0); m.put("schoolId", s.getSchId()); + return m; + } + static Map classInfo(SchClass c, String schSerId) { + Map 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 teaching(SchClassTeach t, String schSerId) { + Map 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; + } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchSubController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchSubController.java new file mode 100644 index 0000000..3f6908e --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchSubController.java @@ -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>> 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 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>> GetSchIdsSublist(@RequestParam(required=false) String SchIds) { + if (SchIds == null || SchIds.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList()); + List ids = OaCompatSupport.strings(SchIds); + List> 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> 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> GetSchTeachSublist(@RequestParam(required=false) String SchID) { + if (SchID == null) return ResponseEntity.ok(Collections.emptyList()); + Optional 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 subject(SchDicSubject s, String schSerId) { + Map 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; + } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchoolingController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchoolingController.java new file mode 100644 index 0000000..aba934d --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/SchoolingController.java @@ -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>> 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>> 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> 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>> 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 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>> 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 grade(BaseSchsystemGrade g) { + Map 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 schooling(BaseSchsystem s) { + Map 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; } } +} + + + + diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/StuInfoController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/StuInfoController.java new file mode 100644 index 0000000..5bdca7e --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/StuInfoController.java @@ -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>> GetAllStulist() { return ResponseEntity.ok(students(studentRepository.findAll(), null)); } + @GetMapping("GetEleAllStulist") + public ResponseEntity>> 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>> GetSchStulist(@RequestParam(required=false) String schserid, @RequestParam(required=false) String schgroupid) { + return ResponseEntity.ok(filter(schserid, schgroupid, null, null)); + } + @GetMapping("GetEleSchStulist") + public ResponseEntity>> 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>> GetClaStulist(@RequestParam(required=false) String ClassID, @RequestParam(required=false) String clagroupid) { return ResponseEntity.ok(filter(null, null, ClassID, clagroupid)); } + @GetMapping("GetEleClaStulist") + public ResponseEntity>> GetEleClaStulist(@RequestParam(required=false) String ClassID, @RequestParam(required=false) String clagroupid) { return ResponseEntity.ok(filter(null, null, ClassID, clagroupid)); } + + @GetMapping("GetClaArrStulist") + public ResponseEntity>> GetClaArrStulist(@RequestParam(required=false) String ClassIDs, @RequestParam(required=false) String clagroupids) { return ResponseEntity.ok(filterArrays(ClassIDs, clagroupids)); } + @GetMapping("GetEleClaArrStulist") + public ResponseEntity>> GetEleClaArrStulist(@RequestParam(required=false) String ClassIDs, @RequestParam(required=false) String clagroupids) { return ResponseEntity.ok(filterArrays(ClassIDs, clagroupids)); } + + @GetMapping("GetStuIdslist") + public ResponseEntity>> GetStuIdslist(@RequestParam(required=false) String stuids) { + Set 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>> GetEleStuIdslist(@RequestParam(required=false) String stuids) { return GetStuIdslist(stuids); } + @GetMapping("GetStuUserFamIDList") + public ResponseEntity> GetStuUserFamIDList(@RequestParam(required=false) String stuids) { return ResponseEntity.ok(Collections.emptyList()); } + @GetMapping("GetFamStulist") + public ResponseEntity>> GetFamStulist(@RequestParam(required=false) String invitecodes) { + Set 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>> GetAllStuFamMem(@RequestParam(required=false) String SchSerID) { return ResponseEntity.ok(Collections.emptyList()); } + @GetMapping("GetSchBySchIds") + public ResponseEntity>> GetSchIdsStulist(@RequestParam(required=false) String schserids) { + Set 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>> GetEleSchIdsStulist(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); } + @GetMapping("GetEleSchBySchIds") + public ResponseEntity>> GetEleSchBySchIds(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); } + @GetMapping("GetStudentsByElectiveId") + public ResponseEntity>> GetStudentsByElectiveId(@RequestParam(required=false) Integer electiveIds) { return ResponseEntity.ok(Collections.emptyList()); } + @GetMapping("getHistoryStudentsBySchoolId") + public ResponseEntity>> 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>> getHistoryClass(@RequestParam Integer schoolId, @RequestParam Integer year) { return ResponseEntity.ok(Collections.emptyList()); } + + private List> 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> filterArrays(String classIds, String groupIds) { + Set 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> students(List 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 history(SchStudentHistory h) { Map 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; } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/TeaChesController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/TeaChesController.java new file mode 100644 index 0000000..6bb9f79 --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/TeaChesController.java @@ -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>> 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>> GetEleSchTeachlist(@RequestParam(required=false) String SchID, @RequestParam(required=false) Integer UserTeaSerID) { return GetSchTeach(SchID, UserTeaSerID); } + @GetMapping("GetSchArrTeachlist") + public ResponseEntity>> GetSchArrTeach(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); } + @GetMapping("GetEleSchArrTeachList") + public ResponseEntity>> GetEleSchArrTeachList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); } + @GetMapping("GetSchClaTeachlist") + public ResponseEntity>> 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>> GetEleSchClaTeachlist(@RequestParam(required=false) String ClassID) { return GetClassTeach(ClassID); } + @GetMapping("GetElectiveClassByGrade") + public ResponseEntity>> GetElectiveClassByGrade(@RequestParam(required=false) Integer schoolId, @RequestParam(required=false) Integer gradeId) { return ResponseEntity.ok(Collections.emptyList()); } + @PostMapping("GetElectiveClassByTeachers") + public ResponseEntity>> GetElectiveClassByTeachers(@RequestBody(required=false) String teacherIds) { return ResponseEntity.ok(Collections.emptyList()); } + + private ResponseEntity>> bySchools(String value) { + Set 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); } +} diff --git a/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/VClassController.java b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/VClassController.java new file mode 100644 index 0000000..7825468 --- /dev/null +++ b/src/main/java/com/yunhai/bschclassmanage/controller/oapi/oa/VClassController.java @@ -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>> GetVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); } + @GetMapping("GetEleVClassList") + public ResponseEntity>> GetEleVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, true); } + @GetMapping("GetSchArrVClassList") + public ResponseEntity>> GetSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, false); } + @GetMapping("GetEleSchArrVClassList") + public ResponseEntity>> GetEleSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, true); } + @GetMapping("GetFunTimeSchClass") + public ResponseEntity>> GetFunTimeSchClass(@RequestParam(required=false) String time, @RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); } + @GetMapping("GetVClassFirst") + public ResponseEntity> GetVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); } + @GetMapping("GetEleVClassFirst") + public ResponseEntity> GetEleVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); } + @GetMapping("GetVClassIdsList") + public ResponseEntity>> GetVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); } + @GetMapping("GetEleVClassIdsList") + public ResponseEntity>> GetEleVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); } + @GetMapping("GetGradeClassList") + public ResponseEntity>> 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> 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>> 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>> GetEleSchArrVClassListAll() { return GetSchArrVClassListAll(); } + @PostMapping("GetSchArrVClassListPost") + public ResponseEntity>> GetSchArrVClassListPost(@RequestBody(required=false) String body) { return bySchools(body, false); } + @GetMapping("GetElectiveClassById") + public ResponseEntity> GetElectiveClassById(@RequestParam(required=false) Integer electiveId) { return ResponseEntity.ok(null); } + @GetMapping("GetElectiveClassByGrade") + public ResponseEntity>> GetElectiveClassByGrade(@RequestParam(required=false) Integer schoolId, @RequestParam(required=false) Integer gradeId) { return ResponseEntity.ok(Collections.emptyList()); } + @PostMapping("GetElectiveClassByTeachers") + public ResponseEntity>> GetElectiveClassByTeachers(@RequestBody(required=false) String teacherIds) { return ResponseEntity.ok(Collections.emptyList()); } + + private ResponseEntity>> 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>> bySchools(String value, boolean elective) { + Set 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>> byClassIds(String value) { Set 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> 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; } } +} + +