springdoc

This commit is contained in:
2026-08-31 11:37:21 +08:00
parent c27dde7a52
commit bf5277ef7c
13 changed files with 214 additions and 61 deletions
+1 -1
View File
@@ -183,7 +183,7 @@
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- SpringDoc OpenAPI UI (compatible with Spring Boot 2.7) -->
<!-- SpringDoc OpenAPI UI:为 Spring Boot 2.7 提供 OpenAPI 文档和 Swagger UI -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
@@ -1,10 +1,17 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.SchInfoRepository;
import com.yunhai.bschclassmanage.Repository.SchTeacherGroupRepository;
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchInfo;
import com.yunhai.bschclassmanage.entity.SchTeacher;
import com.yunhai.bschclassmanage.entity.SchTeacherGroup;
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;
@@ -16,27 +23,52 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/** Compatibility endpoints used by BestSchool.IBaseClass.BLL.DbClass consumers. */
@Tag(name = "DbClass", description = "基础班级数据接口")
@RestController
@RequestMapping(Config.OAPI + "/DbClass/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class DbClassController {
@Autowired private ISchTeacherService schTeacherService;
@Autowired private ISchInfoService schInfoService;
@Autowired private SchTeacherGroupRepository schTeacherGroupRepository;
@Autowired private SchTeacherRepository schTeacherRepository;
@Autowired private SchInfoRepository schInfoRepository;
@GetMapping("GetSchteaList")
public ResponseEntity<List<Map<String, Object>>> getSchteaList(@RequestParam("Group") Integer group) {
@Operation(summary = "获取学校教师列表", description = "根据学校 ID 查询学校下的全部教师信息;教师属于多个组时,每个组返回一条记录")
public ResponseEntity<List<Map<String, Object>>> getSchteaList(
@Parameter(description = "学校 ID", required = true, example = "950")
@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());
String schSerId = school == null ? schInfoRepository.findBySchId(group).map(SchInfo::getSchSerId).orElse(null) : school.getSchSerId();
List<SchTeacherGroup> memberships = schTeacherGroupRepository.findBySchIdAndTransferStatus(group, 0);
if (memberships == null || memberships.isEmpty()) return ResponseEntity.ok(Collections.emptyList());
List<Map<String, Object>> result = teachers.stream().map(teacher -> {
Map<Integer, List<Integer>> teacherGroupIds = memberships.stream()
.filter(m -> m.getTeaId() != null && m.getGroupId() != null)
.collect(Collectors.groupingBy(SchTeacherGroup::getTeaId, LinkedHashMap::new,
Collectors.mapping(SchTeacherGroup::getGroupId, Collectors.toList())));
// Keep one output row per school-group membership, including duplicate teachers.
List<Map<String, Object>> result = memberships.stream()
.map(SchTeacherGroup::getTeaId)
.filter(java.util.Objects::nonNull)
.map(schTeacherRepository::findByTeaId)
.filter(Optional::isPresent)
.map(Optional::get)
.map(teacher -> teacherRow(teacher, schSerId, teacherGroupIds.getOrDefault(teacher.getTeaId(), Collections.emptyList())))
.collect(Collectors.toList());
return ResponseEntity.ok(result);
}
private Map<String, Object> teacherRow(SchTeacher teacher, String schSerId, List<Integer> groupIds) {
Map<String, Object> row = new LinkedHashMap<>();
row.put("SchSerID", schSerId);
row.put("TeaTel", teacher.getTel());
@@ -44,8 +76,7 @@ public class DbClassController {
row.put("UserTeaSerID", teacher.getTeaId());
row.put("TeaIDCard", teacher.getIdCard());
row.put("TeaNo", teacher.getSort());
row.put("GroupIds", groupIds);
return row;
}).collect(Collectors.toList());
return ResponseEntity.ok(result);
}
}
@@ -1,19 +1,25 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.config.Config;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@Tag(name = "FamilyCompat", description = "FamilyCompat related APIs")
@RestController
@RequestMapping(Config.OAPI+"/Common/FamCom/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class FamilyCompatController {
@PostMapping("GetStuUserFamIDList")
@Operation(summary = "getStuUserFamIdList")
public ResponseEntity<List<String>> getStuUserFamIdList(@RequestBody(required=false) String stuIds) {
return ResponseEntity.ok(Collections.emptyList());
}
@PostMapping("GetAllStuFamMem")
@Operation(summary = "getAllStuFamMem")
public ResponseEntity<List<Map<String,Object>>> getAllStuFamMem(@RequestBody(required=false) String stuIds) {
return ResponseEntity.ok(Collections.emptyList());
}
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "SchGroup", description = "SchGroup related APIs")
@RestController
@RequestMapping(Config.OAPI+"/SchGroup/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.SchInfoRepository;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchInfo;
@@ -12,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "SchInfo", description = "SchInfo related APIs")
@RestController
@RequestMapping(Config.OAPI+"/SchInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -20,24 +24,29 @@ public class SchInfoController {
@Autowired private SchInfoRepository schInfoRepository;
@GetMapping("GetSchlist")
@Operation(summary = "获取学校列表", description = "根据多个学校 ID 查询学校")
public ResponseEntity<List<SchInfoVO>> GetSchlist(@RequestParam(required = false) String SchIDArr) {
return ResponseEntity.ok(schInfoService.getSchVOList(SchIDArr));
}
@GetMapping("AllList")
@Operation(summary = "获取全部学校列表", description = "查询全部学校")
public ResponseEntity<List<SchInfoVO>> AllList() { return ResponseEntity.ok(schInfoService.getSchVOList(null)); }
@GetMapping("GetSchFirst")
@Operation(summary = "获取单个学校校", description = "根据单个学校 ID 查询学校")
public ResponseEntity<SchInfoVO> GetSchFirst(@RequestParam(required = false) String SchID) {
return ResponseEntity.ok(SchID == null ? null : schInfoService.GetSchFirst(SchID));
}
@GetMapping("GetUserSchFirst")
@Operation(summary = "获取学校", description = "根据用户中心 ID 查询学校")
public ResponseEntity<SchInfoVO> GetUserSchFirst(@RequestParam(required = false) Integer UserSchID) {
return ResponseEntity.ok(UserSchID == null ? null : schInfoService.GetSchFirst(UserSchID));
}
@GetMapping("GetUserSchlist")
@Operation(summary = "获取学校列表", description = "根据用户中心多个 ID 查询学校")
public ResponseEntity<List<SchInfoVO>> GetUserSchlist(@RequestParam(required = false) String UserSchIds) {
if (UserSchIds == null || UserSchIds.trim().isEmpty()) return ResponseEntity.ok(Collections.emptyList());
Set<Integer> ids = parseInts(UserSchIds);
@@ -47,6 +56,7 @@ public class SchInfoController {
}
@GetMapping("GetSchoolByGroupId")
@Operation(summary = "获取学校列表", description = "根据用户中心组 ID 查询学校")
public ResponseEntity<List<SchInfoVO>> GetSchoolByGroupId(@RequestParam(required = false) Integer groupId) {
if (groupId == null || groupId == 0) return ResponseEntity.ok(Collections.emptyList());
return ResponseEntity.ok(schInfoRepository.findAll().stream()
@@ -54,6 +64,7 @@ public class SchInfoController {
}
@GetMapping("GetSchoolBySchoolenId")
@Operation(summary = "获取学校学制", description = "根据用户中心组 ID 查询学校学制")
public ResponseEntity<List<Map<String, Object>>> GetSchoolBySchoolenId(@RequestParam(required = false) Integer groupId) {
return ResponseEntity.ok(Collections.emptyList());
}
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
@@ -10,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "SchSub", description = "SchSub related APIs")
@RestController
@RequestMapping(Config.OAPI+"/SubInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -19,6 +23,7 @@ public class SchSubController {
@Autowired private SchClassTeachRepository teachRepository;
@GetMapping("GetSchSublist")
@Operation(summary = "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);
@@ -27,6 +32,7 @@ public class SchSubController {
}
@GetMapping("GetSchIdsSublist")
@Operation(summary = "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);
@@ -36,6 +42,7 @@ public class SchSubController {
}
@GetMapping("GetSchTeaSublist")
@Operation(summary = "GetSchTeaSublist")
public ResponseEntity<List<String>> GetSchTeaSublist(@RequestParam(required=false) String UserTeaSerID) {
if (UserTeaSerID == null) return ResponseEntity.ok(Collections.emptyList());
try {
@@ -45,6 +52,7 @@ public class SchSubController {
}
@GetMapping("GetSchTeachSublist")
@Operation(summary = "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);
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
@@ -10,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "Schooling", description = "Schooling related APIs")
@RestController
@RequestMapping(Config.OAPI+"/Schoolen/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -25,6 +29,7 @@ public class SchoolingController {
@Autowired private SchDicSubjectRepository subjectRepository;
@GetMapping("GetSchLenLevellist")
@Operation(summary = "获取学校学制列表", description = "根据用 SchSerID 查询学校学制")
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);
@@ -33,12 +38,14 @@ public class SchoolingController {
}
@GetMapping("GetLevelIdlist")
@Operation(summary = "获取学校学制列表", description = "根据用 Schooling 查询学校学制")
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")
@Operation(summary = "获取学校学制列表", description = "根据用 年级id 查询学校学制")
public ResponseEntity<Map<String,Object>> GetSchLenLevelFirst(@RequestParam(required=false) String GradeId) {
if (GradeId == null) return ResponseEntity.ok(null);
try {
@@ -48,6 +55,7 @@ public class SchoolingController {
}
@GetMapping("GetSchLenlist")
@Operation(summary = "获取学校学制长度", description = "根据用 SchSerID 查询学校学制长度")
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);
@@ -57,6 +65,7 @@ public class SchoolingController {
}
@GetMapping("GetAllClassSubject")
@Operation(summary = "获取全部", description = "根据用 SchSerID 查询学校学制长度")
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());
}
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "StuInfo", description = "StuInfo related APIs")
@RestController
@RequestMapping(Config.OAPI+"/OAStu/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -18,60 +22,79 @@ public class StuInfoController {
@Autowired private SchStudentHistoryRepository historyRepository;
@GetMapping("GetAllStulist")
@Operation(summary = "GetAllStulist")
public ResponseEntity<List<Map<String,Object>>> GetAllStulist() { return ResponseEntity.ok(students(studentRepository.findAll(), null)); }
@GetMapping("GetEleAllStulist")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "GetEleStuIdslist")
public ResponseEntity<List<Map<String,Object>>> GetEleStuIdslist(@RequestParam(required=false) String stuids) { return GetStuIdslist(stuids); }
@GetMapping("GetStuUserFamIDList")
@Operation(summary = "GetStuUserFamIDList")
public ResponseEntity<List<String>> GetStuUserFamIDList(@RequestParam(required=false) String stuids) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("GetFamStulist")
@Operation(summary = "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")
@Operation(summary = "GetAllStuFamMem")
public ResponseEntity<List<Map<String,Object>>> GetAllStuFamMem(@RequestParam(required=false) String SchSerID) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("GetSchBySchIds")
@Operation(summary = "GetSchIdsStulist")
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")
@Operation(summary = "GetEleSchIdsStulist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchIdsStulist(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); }
@GetMapping("GetEleSchBySchIds")
@Operation(summary = "GetEleSchBySchIds")
public ResponseEntity<List<Map<String,Object>>> GetEleSchBySchIds(@RequestParam(required=false) String schserids) { return GetSchIdsStulist(schserids); }
@GetMapping("GetStudentsByElectiveId")
@Operation(summary = "GetStudentsByElectiveId")
public ResponseEntity<List<Map<String,Object>>> GetStudentsByElectiveId(@RequestParam(required=false) Integer electiveIds) { return ResponseEntity.ok(Collections.emptyList()); }
@GetMapping("getHistoryStudentsBySchoolId")
@Operation(summary = "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")
@Operation(summary = "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) {
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "TeaChes", description = "TeaChes related APIs")
@RestController
@RequestMapping(Config.OAPI+"/TeachInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -17,26 +21,34 @@ public class TeaChesController {
@Autowired private SchInfoRepository schoolRepository;
@GetMapping("GetSchTeachlist")
@Operation(summary = "GetSchTeach")
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")
@Operation(summary = "GetEleSchTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchTeachlist(@RequestParam(required=false) String SchID, @RequestParam(required=false) Integer UserTeaSerID) { return GetSchTeach(SchID, UserTeaSerID); }
@GetMapping("GetSchArrTeachlist")
@Operation(summary = "GetSchArrTeach")
public ResponseEntity<List<Map<String,Object>>> GetSchArrTeach(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); }
@GetMapping("GetEleSchArrTeachList")
@Operation(summary = "GetEleSchArrTeachList")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrTeachList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr); }
@GetMapping("GetSchClaTeachlist")
@Operation(summary = "GetClassTeach")
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")
@Operation(summary = "GetEleSchClaTeachlist")
public ResponseEntity<List<Map<String,Object>>> GetEleSchClaTeachlist(@RequestParam(required=false) String ClassID) { return GetClassTeach(ClassID); }
@GetMapping("GetElectiveClassByGrade")
@Operation(summary = "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")
@Operation(summary = "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) {
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchTeacher;
@@ -22,6 +25,7 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Tag(name = "Teainfo", description = "Teainfo related APIs")
@RestController
@RequestMapping(Config.OAPI+"/OATea/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -37,15 +41,16 @@ public class TeainfoController {
private ISchInfoService schInfoService;
@GetMapping("GetTeainfo")
@Operation(summary = "getTeainfo")
public ResponseEntity<TeaInfoVO> getTeainfo(@RequestParam Integer uid) {
// 1. 参数校验
// 1. 鍙傛暟鏍¢獙
if (uid == null) {
return ResponseEntity.badRequest().build();
}
// 2. 直接使用 uid 查询
return schTeacherRepository.findByTeaId(uid) // 假设 findByTeaId 返回 Optional<SchTeacher>
.map(this::convertToTeaInfoVO) // 将 SchTeacher 转为 TeaInfoVO
// 2. 鐩存帴浣跨敤 uid 鏌ヨ
return schTeacherRepository.findByTeaId(uid) // 鍋囪 findByTeaId 杩斿洖 Optional<SchTeacher>
.map(this::convertToTeaInfoVO) // 灏?SchTeacher 杞负 TeaInfoVO
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
@@ -56,7 +61,7 @@ public class TeainfoController {
}
TeaInfoVO vo = new TeaInfoVO();
// 直接映射
// 鐩存帴鏄犲皠
vo.setAccount(teacher.getAccount());
vo.setName(teacher.getName());
vo.setTeaIDCard(teacher.getIdCard());
@@ -69,7 +74,7 @@ public class TeainfoController {
vo.setTeaSex(sex);
}
// TeaSerID 使用 teaId(转为字符串)或 id
// TeaSerID 浣跨敤 teaId锛堣浆涓哄瓧绗︿覆锛夋垨 id
if (teacher.getTeaId() != null) {
vo.setTeaSerID(teacher.getTeaId().toString());
} else {
@@ -80,7 +85,7 @@ public class TeainfoController {
if(groupList==null||groupList.isEmpty())
return null;
// 其他字段默认 null(或根据业务设置默认值)
// 鍏朵粬瀛楁榛樿 null锛堟垨鏍规嵁涓氬姟璁剧疆榛樿鍊硷級
SchInfoVO schInfoVO= schInfoService.GetSchFirst(groupList.stream().findFirst().get().getSchId());
vo.setSchSerID(schInfoVO==null?null:schInfoVO.getSchSerId());
@@ -90,8 +95,9 @@ public class TeainfoController {
}
@PostMapping("GetArrTeainfo")
@Operation(summary = "根据教师id数组 获取教师列表")
public ResponseEntity<List<TeaInfoVO>> getArrTeainfo(@RequestBody String userIds) {
// 1. 参数校验
// 1. 鍙傛暟鏍¢獙
if (userIds == null) {
return ResponseEntity.badRequest().build();
}
@@ -106,21 +112,35 @@ public class TeainfoController {
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
}
/**
* 解析学校ID:支持直接传 schId,或传 SchSerID 反查 schId,二者至少提供一个。
*
* @param schId 学校内部ID(优先使用)
* @param schSerID 学校外部序列号
* @return 学校内部ID,参数非法或查不到时返回 null
*/
private Integer resolveSchId(Integer schId, String schSerID) {
if (schId != null) {
return schId;
}
if (schSerID == null || schSerID.trim().isEmpty()) {
return null;
}
SchInfoVO schInfoVO = schInfoService.GetSchFirst(schSerID);
return schInfoVO == null ? null : schInfoVO.getUserSchSerId();
}
@GetMapping("GetSchTeainfo")
public ResponseEntity<List<TeaInfoVO>> getSchTeainfo(@RequestParam String SchSerID) {
// 1. 参数校验
if (SchSerID == null) {
@Operation(summary = "根据学校ID 获取教师列表(SchSerID 与 schId 二选一)")
public ResponseEntity<List<TeaInfoVO>> getSchTeainfo(@RequestParam(value = "SchSerID", required = false) String SchSerID,
@RequestParam(value = "schId", required = false) Integer schId) {
// 1. 参数校验:SchSerID 与 schId 至少传一个
Integer resolvedSchId = resolveSchId(schId, SchSerID);
if (resolvedSchId == null) {
return ResponseEntity.badRequest().build();
}
SchInfoVO schInfoVO= schInfoService.GetSchFirst(SchSerID);
if(schInfoVO==null)
{
return ResponseEntity.badRequest().build();
}
Integer schId=schInfoVO.getUserSchSerId();
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(schId);
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(resolvedSchId);
List<TeaInfoVO> voList = teachers.stream()
.map(this::convertToTeaInfoVO)
@@ -130,8 +150,10 @@ public class TeainfoController {
}
@GetMapping("GetSchTeaList")
public ResponseEntity<List<TeaInfoVO>> getSchTeaList(@RequestParam String SchSerID) {
return getSchTeainfo(SchSerID);
@Operation(summary = "getSchTeaList(SchSerID 与 schId 二选一)")
public ResponseEntity<List<TeaInfoVO>> getSchTeaList(@RequestParam(value = "SchSerID", required = false) String SchSerID,
@RequestParam(value = "schId", required = false) Integer schId) {
return getSchTeainfo(SchSerID, schId);
}
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.SchStudentRepository;
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
import com.yunhai.bschclassmanage.config.Config;
@@ -23,6 +26,7 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Tag(name = "UserInfo", description = "UserInfo related APIs")
@RestController
@RequestMapping(Config.OAPI + "/UserInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -44,8 +48,9 @@ public class UserInfoController {
private ISchInfoService schInfoService;
@GetMapping("GetUserList")
@Operation(summary = "getUserList")
public ResponseEntity<List<UserInfoVO>> getUserList(@RequestParam String SchSerID) {
// 1. 参数校验
// 1. 鍙傛暟鏍¢獙
if (SchSerID == null || SchSerID.trim().isEmpty()) {
return ResponseEntity.badRequest().build();
}
@@ -56,16 +61,16 @@ public class UserInfoController {
}
Integer schId = schInfoVO.getUserSchSerId();
// 2. 获取教师和学生列表(判空)
// 2. 鑾峰彇鏁欏笀鍜屽鐢熷垪琛紙鍒ょ┖锛?
List<SchTeacher> teachers = schTeacherService.getSchTeacherCacheList(schId);
List<SchStudent> students = schStudentService.getSchGradeClassStudentCacheList(schId, null, null, null);
// 3. 转换为 UserInfoVO
// 3. 杞崲涓?UserInfoVO
List<UserInfoVO> voList = new ArrayList<>();
if (teachers != null) {
voList.addAll(teachers.stream()
.map(this::convertToUserInfoVO)
.filter(vo -> vo != null) // 过滤转换失败的
.filter(vo -> vo != null) // 杩囨护杞崲澶辫触鐨?
.collect(Collectors.toList()));
}
if (students != null) {
@@ -75,51 +80,51 @@ public class UserInfoController {
.collect(Collectors.toList()));
}
// 4. 返回结果
// 4. 杩斿洖缁撴灉
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
}
// ===== 转换教师 =====
// ===== 杞崲鏁欏笀 =====
private UserInfoVO convertToUserInfoVO(SchTeacher teacher) {
if (teacher == null) {
return null;
}
UserInfoVO vo = new UserInfoVO();
// 基础字段
// 鍩虹瀛楁
vo.setUids(teacher.getAccount());
vo.setName(teacher.getName());
vo.setIDCard(teacher.getIdCard());
vo.setTel(teacher.getTel());
vo.setNo(teacher.getSort());
vo.setSex(teacher.getGender());
vo.setUserID(teacher.getTeaId()); // 教师用户ID
vo.setUsertype(1); // 假设教师类型为1
vo.setUserID(teacher.getTeaId()); // 鏁欏笀鐢ㄦ埛ID
vo.setUsertype(1); // 鍋囪鏁欏笀绫诲瀷涓?
// 获取学校ID和组ID
// 鑾峰彇瀛︽牎ID鍜岀粍ID
List<SchTeacherGroup> groupList = teacher.getGroupList();
if (groupList != null && !groupList.isEmpty()) {
SchTeacherGroup firstGroup = groupList.get(0);
vo.setGroupID(firstGroup.getGroupId());
// 通过组获取学校信息
// 閫氳繃缁勮幏鍙栧鏍′俊鎭?
SchInfoVO schInfo = schInfoService.GetSchFirst(firstGroup.getSchId());
// 若没有直接按组查学校的方法,可改为通过组的schId查
// 鑻ユ病鏈夌洿鎺ユ寜缁勬煡瀛︽牎鐨勬柟娉曪紝鍙敼涓洪€氳繃缁勭殑schId鏌?
if (schInfo != null) {
vo.setSchSerID(schInfo.getSchSerId());
}
} else {
// 无分组,可能是管理员或特殊用户,可设置默认或 null
// 鏃犲垎缁勶紝鍙兘鏄鐞嗗憳鎴栫壒娈婄敤鎴凤紝鍙缃粯璁ゆ垨 null
vo.setGroupID(null);
vo.setSchSerID(null);
}
// 其他字段(如 Photo, SerID 等)如果 SchTeacher 没有,可置 null 或从别处获取
vo.setPhoto(null); // 可根据 teacher 的某字段补充
// 鍏朵粬瀛楁锛堝 Photo, SerID 绛夛級濡傛灉 SchTeacher 娌℃湁锛屽彲缃?null 鎴栦粠鍒鑾峰彇
vo.setPhoto(null); // 鍙牴鎹?teacher 鐨勬煇瀛楁琛ュ厖
vo.setSerID(null);
return vo;
}
// ===== 转换学生 =====
// ===== 杞崲瀛︾敓 =====
private UserInfoVO convertToUserInfoVO(SchStudent student) {
if (student == null) {
return null;
@@ -129,16 +134,16 @@ public class UserInfoController {
vo.setUids(student.getAccount());
vo.setName(student.getName());
vo.setIDCard(student.getIdCard());
vo.setTel(null); // 学生表可能无电话,如有则补充
vo.setNo(null); // 学生表没有 No 字段,可置 null 或从 stuClassNo 转换
vo.setTel(null); // 瀛︾敓琛ㄥ彲鑳芥棤鐢佃瘽锛屽鏈夊垯琛ュ厖
vo.setNo(null); // 瀛︾敓琛ㄦ病鏈?No 瀛楁锛屽彲缃?null 鎴栦粠 stuClassNo 杞崲
vo.setSex(student.getGender());
vo.setUserID(student.getStuId()); // 学生用户ID
vo.setUsertype(UserRole.STU_USER.getValue()); // 假设学生类型为2
vo.setUserID(student.getStuId()); // 瀛︾敓鐢ㄦ埛ID
vo.setUsertype(UserRole.STU_USER.getValue()); // 鍋囪瀛︾敓绫诲瀷涓?
vo.setGroupID(student.getGroupId());
SchInfoVO schInfo = schInfoService.GetSchFirst(student.getSchId());
// 若没有直接按组查学校的方法,可改为通过组的schId查
// 鑻ユ病鏈夌洿鎺ユ寜缁勬煡瀛︽牎鐨勬柟娉曪紝鍙敼涓洪€氳繃缁勭殑schId鏌?
if (schInfo != null) {
vo.setSchSerID(schInfo.getSchSerId());
}
@@ -149,6 +154,7 @@ public class UserInfoController {
}
@GetMapping("getUserIdList")
@Operation(summary = "getUserIdList")
public ResponseEntity<List<UserInfoVO>> getUserIdList(@RequestParam Integer userid) {
if (userid == null) {
return ResponseEntity.badRequest().build();
@@ -1,5 +1,8 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunhai.bschclassmanage.Repository.*;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.*;
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Tag(name = "VClass", description = "VClass related APIs")
@RestController
@RequestMapping(Config.OAPI+"/VSchClass/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
@@ -18,44 +22,61 @@ public class VClassController {
@Autowired private SchClassTeachRepository teachingRepository;
@GetMapping("GetVClassList")
@Operation(summary = "GetVClassList")
public ResponseEntity<List<Map<String,Object>>> GetVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); }
@GetMapping("GetEleVClassList")
@Operation(summary = "GetEleVClassList")
public ResponseEntity<List<Map<String,Object>>> GetEleVClassList(@RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, true); }
@GetMapping("GetSchArrVClassList")
@Operation(summary = "GetSchArrVClassList")
public ResponseEntity<List<Map<String,Object>>> GetSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, false); }
@GetMapping("GetEleSchArrVClassList")
@Operation(summary = "GetEleSchArrVClassList")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrVClassList(@RequestParam(required=false) String SchIDArr) { return bySchools(SchIDArr, true); }
@GetMapping("GetFunTimeSchClass")
@Operation(summary = "GetFunTimeSchClass")
public ResponseEntity<List<Map<String,Object>>> GetFunTimeSchClass(@RequestParam(required=false) String time, @RequestParam(required=false) String SchSerID) { return bySchool(SchSerID, false); }
@GetMapping("GetVClassFirst")
@Operation(summary = "GetVClassFirst")
public ResponseEntity<Map<String,Object>> GetVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); }
@GetMapping("GetEleVClassFirst")
@Operation(summary = "GetEleVClassFirst")
public ResponseEntity<Map<String,Object>> GetEleVClassFirst(@RequestParam(required=false) String ClassID) { return one(ClassID); }
@GetMapping("GetVClassIdsList")
@Operation(summary = "GetVClassIdsList")
public ResponseEntity<List<Map<String,Object>>> GetVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); }
@GetMapping("GetEleVClassIdsList")
@Operation(summary = "GetEleVClassIdsList")
public ResponseEntity<List<Map<String,Object>>> GetEleVClassIdsList(@RequestParam(required=false) String ClassIds) { return byClassIds(ClassIds); }
@GetMapping("GetGradeClassList")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "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")
@Operation(summary = "GetEleSchArrVClassListAll")
public ResponseEntity<List<Map<String,Object>>> GetEleSchArrVClassListAll() { return GetSchArrVClassListAll(); }
@PostMapping("GetSchArrVClassListPost")
@Operation(summary = "GetSchArrVClassListPost")
public ResponseEntity<List<Map<String,Object>>> GetSchArrVClassListPost(@RequestBody(required=false) String body) { return bySchools(body, false); }
@GetMapping("GetElectiveClassById")
@Operation(summary = "GetElectiveClassById")
public ResponseEntity<Map<String,Object>> GetElectiveClassById(@RequestParam(required=false) Integer electiveId) { return ResponseEntity.ok(null); }
@GetMapping("GetElectiveClassByGrade")
@Operation(summary = "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")
@Operation(summary = "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) {
+1 -1
View File
@@ -95,4 +95,4 @@ springdoc:
path: /swagger-ui.html
operations-sorter: method
tags-sorter: alpha
packages-to-scan: com.yunhai.bschclassmanage.controller
packages-to-scan: com.yunhai.bschclassmanage.controller # 扫描 Controller 包