@@ -3,6 +3,7 @@ package com.yunhai.bschclassmanage.controller.oapi.oa;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
|
import com.yunhai.bschclassmanage.Repository.SchTeacherGroupRepository;
|
||||||
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
|
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
|
||||||
import com.yunhai.bschclassmanage.config.Config;
|
import com.yunhai.bschclassmanage.config.Config;
|
||||||
import com.yunhai.bschclassmanage.entity.SchTeacher;
|
import com.yunhai.bschclassmanage.entity.SchTeacher;
|
||||||
@@ -21,7 +22,10 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -37,6 +41,9 @@ public class TeainfoController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SchTeacherRepository schTeacherRepository;
|
private SchTeacherRepository schTeacherRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SchTeacherGroupRepository schTeacherGroupRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISchInfoService schInfoService;
|
private ISchInfoService schInfoService;
|
||||||
|
|
||||||
@@ -50,7 +57,11 @@ public class TeainfoController {
|
|||||||
|
|
||||||
// 2. 鐩存帴浣跨敤 uid 鏌ヨ
|
// 2. 鐩存帴浣跨敤 uid 鏌ヨ
|
||||||
return schTeacherRepository.findByTeaId(uid) // 鍋囪 findByTeaId 杩斿洖 Optional<SchTeacher>
|
return schTeacherRepository.findByTeaId(uid) // 鍋囪 findByTeaId 杩斿洖 Optional<SchTeacher>
|
||||||
.map(this::convertToTeaInfoVO) // 灏?SchTeacher 杞负 TeaInfoVO
|
.map(teacher -> {
|
||||||
|
fillGroupList(Collections.singletonList(teacher), null);
|
||||||
|
return teacher;
|
||||||
|
})
|
||||||
|
.map(this::convertToTeaInfoVO)
|
||||||
.map(ResponseEntity::ok)
|
.map(ResponseEntity::ok)
|
||||||
.orElse(ResponseEntity.notFound().build());
|
.orElse(ResponseEntity.notFound().build());
|
||||||
}
|
}
|
||||||
@@ -94,6 +105,30 @@ public class TeainfoController {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量回填教师的分组列表(groupList 为 @Transient 字段,查询后需要单独填充)。
|
||||||
|
* schId 不为空时只查该校的组关系,保证取到的 GroupID/SchSerID 属于当前学校。
|
||||||
|
*/
|
||||||
|
private void fillGroupList(List<SchTeacher> teachers, Integer schId) {
|
||||||
|
if (teachers == null || teachers.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Integer> teaIds = teachers.stream()
|
||||||
|
.map(SchTeacher::getTeaId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (teaIds.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SchTeacherGroup> relations = (schId != null)
|
||||||
|
? schTeacherGroupRepository.findByTeaIdInAndSchId(teaIds, schId)
|
||||||
|
: schTeacherGroupRepository.findByTeaIdIn(teaIds);
|
||||||
|
Map<Integer, List<SchTeacherGroup>> groupMap = relations.stream()
|
||||||
|
.filter(g -> g.getTeaId() != null)
|
||||||
|
.collect(Collectors.groupingBy(SchTeacherGroup::getTeaId));
|
||||||
|
teachers.forEach(t -> t.setGroupList(groupMap.getOrDefault(t.getTeaId(), Collections.emptyList())));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("GetArrTeainfo")
|
@PostMapping("GetArrTeainfo")
|
||||||
@Operation(summary = "根据教师id数组 获取教师列表")
|
@Operation(summary = "根据教师id数组 获取教师列表")
|
||||||
public ResponseEntity<List<TeaInfoVO>> getArrTeainfo(@RequestBody String userIds) {
|
public ResponseEntity<List<TeaInfoVO>> getArrTeainfo(@RequestBody String userIds) {
|
||||||
@@ -105,8 +140,10 @@ public class TeainfoController {
|
|||||||
List<Integer> uids= Arrays.asList(OtherUtil.convertToArray(userIds));
|
List<Integer> uids= Arrays.asList(OtherUtil.convertToArray(userIds));
|
||||||
|
|
||||||
List<SchTeacher> teachers = schTeacherRepository.findByTeaIdIn(uids);
|
List<SchTeacher> teachers = schTeacherRepository.findByTeaIdIn(uids);
|
||||||
|
fillGroupList(teachers, null);
|
||||||
List<TeaInfoVO> voList = teachers.stream()
|
List<TeaInfoVO> voList = teachers.stream()
|
||||||
.map(this::convertToTeaInfoVO)
|
.map(this::convertToTeaInfoVO)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
|
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
|
||||||
@@ -141,9 +178,11 @@ public class TeainfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(resolvedSchId);
|
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(resolvedSchId);
|
||||||
|
fillGroupList(teachers, resolvedSchId);
|
||||||
|
|
||||||
List<TeaInfoVO> voList = teachers.stream()
|
List<TeaInfoVO> voList = teachers.stream()
|
||||||
.map(this::convertToTeaInfoVO)
|
.map(this::convertToTeaInfoVO)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
|
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
|
||||||
|
|||||||
@@ -1,30 +1,54 @@
|
|||||||
package com.yunhai.bschclassmanage.model.oa;
|
package com.yunhai.bschclassmanage.model.oa;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TeaInfoVO {
|
public class TeaInfoVO {
|
||||||
|
@JsonProperty("SchSerID")
|
||||||
private String SchSerID;
|
private String SchSerID;
|
||||||
|
@JsonProperty("Teapolitical")
|
||||||
private String Teapolitical;
|
private String Teapolitical;
|
||||||
|
@JsonProperty("TeaWorkStart")
|
||||||
private String TeaWorkStart;
|
private String TeaWorkStart;
|
||||||
|
@JsonProperty("Account")
|
||||||
private String Account;
|
private String Account;
|
||||||
|
@JsonProperty("SchSerIDs")
|
||||||
private String SchSerIDs;
|
private String SchSerIDs;
|
||||||
|
@JsonProperty("role")
|
||||||
private Integer role;
|
private Integer role;
|
||||||
|
@JsonProperty("JiaoYuJu")
|
||||||
private String JiaoYuJu;
|
private String JiaoYuJu;
|
||||||
|
@JsonProperty("TeaSex")
|
||||||
private String TeaSex;
|
private String TeaSex;
|
||||||
|
@JsonProperty("IsLeadingMiddle")
|
||||||
private Integer IsLeadingMiddle;
|
private Integer IsLeadingMiddle;
|
||||||
|
@JsonProperty("TeaOriginPlace")
|
||||||
private String TeaOriginPlace;
|
private String TeaOriginPlace;
|
||||||
|
@JsonProperty("Photo")
|
||||||
private String Photo;
|
private String Photo;
|
||||||
|
@JsonProperty("TeaIDCard")
|
||||||
private String TeaIDCard;
|
private String TeaIDCard;
|
||||||
|
@JsonProperty("Name")
|
||||||
private String Name;
|
private String Name;
|
||||||
|
@JsonProperty("GroupID")
|
||||||
private Integer GroupID;
|
private Integer GroupID;
|
||||||
|
@JsonProperty("SchName")
|
||||||
private String SchName;
|
private String SchName;
|
||||||
|
@JsonProperty("TeaTeachStart")
|
||||||
private String TeaTeachStart;
|
private String TeaTeachStart;
|
||||||
|
@JsonProperty("TeaSerID")
|
||||||
private String TeaSerID;
|
private String TeaSerID;
|
||||||
|
@JsonProperty("UserID")
|
||||||
private Integer UserID;
|
private Integer UserID;
|
||||||
|
@JsonProperty("TeaNation")
|
||||||
private String TeaNation;
|
private String TeaNation;
|
||||||
|
@JsonProperty("Tel")
|
||||||
private String Tel;
|
private String Tel;
|
||||||
|
@JsonProperty("TeaWorkType")
|
||||||
private String TeaWorkType;
|
private String TeaWorkType;
|
||||||
|
@JsonProperty("TeaNo")
|
||||||
private Integer TeaNo;
|
private Integer TeaNo;
|
||||||
|
@JsonProperty("TeaBirth")
|
||||||
private String TeaBirth;
|
private String TeaBirth;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user