GetMappingqueryCoachByPageByParam public ResultObject queryCoachByPageByParamQueryRequest queryRequest Admin admin String text String drivingProject
<p>@GetMapping("/queryCoachByPageByParam")
public Result<Object> queryCoachByPageByParam(QueryRequest queryRequest, Admin admin,
String text, String drivingProjectType,
String workStatus, HttpServletRequest request) {</p>
<pre><code>//权限验证
String token = (String) request.getAttribute("claims_admin");
if (token == null || "".equals(token)) {
throw new RuntimeException("权限不足!");
}
Map<String, Object> map = new HashMap<>();
//查出当前管理员
Admin admin1 = adminService.queryOneAdminByID(admin.getAdminId());
//1.当前管理员为总管理
if (admin1.getTotalAdminId() != null && admin1.getTotalAdminId() == 0) {
//找到当前总管理名下所有管理员
List<Admin> admins = adminService.queryAdminsByTotalAdminId(admin.getAdminId());
//(1)通过姓名和电话查询-总管理
if (!StringUtils.isEmpty(text)) {
List<Coach> coaches = new ArrayList<>();
for (Admin admin2 : admins) {
coaches.addAll(adminService.queryAllCoachByAdminId(admin2.getAdminId()));
}
List<CoachDto> coachDtoListByText = new ArrayList<>();
List<Coach> coachList = new ArrayList<>();
for (Coach coach : coaches) {
if (coach.getRealName() != null) {
if (coach.getRealName().contains(text) || coach.getCoachPhone().contains(text)) {
coachList.add(coach);
}
}
}
if (!CollectionUtils.isEmpty(coachList)) {
List<Long> coachIds = coachList.stream()
.map(Coach::getCoachId)
.collect(Collectors.toList());
Map<Long, Coach> coachMap = coaches.stream().collect(Collectors.toMap(Coach::getCoachId, Function.identity()));
// 查询当前教练课程
Map<Long, List<CourseDto>> courseDtoMap = courseInfoService.queryCourseByCoachIds(coachIds, RcqtUtils.getDay());
coachDtoListByText = coachIds.stream()
.map(coachId -> {
Coach coach = coachMap.get(coachId);
if (coach != null) {
CoachDto coachDto = new CoachDto();
BeanUtils.copyProperties(coach, coachDto);
// 判断教练是否在工作中
List<CourseDto> courseDtoList = courseDtoMap.get(coachId);
boolean isWorking
</code></pre>
原文地址: https://www.cveoy.top/t/topic/iAOw 著作权归作者所有。请勿转载和采集!