获取当前用户的今日日程

This commit is contained in:
HuangXinQuan
2026-02-10 17:25:32 +08:00
parent ca9b145d3e
commit 2a5a157c57
5 changed files with 75 additions and 7 deletions

View File

@@ -9,6 +9,8 @@ public interface IDoctorScheduleAppService {
R<?> getTodayDoctorScheduleList();
R<?> getTodayMySchedule();
R<?> getDoctorScheduleListByDeptId(Long deptId);
R<?> getDoctorScheduleListByDeptIdAndDateRange(Long deptId, String startDate, String endDate);

View File

@@ -113,6 +113,44 @@ public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService {
}
}
@Override
public R<?> getTodayMySchedule() {
try {
// 获取当前登录用户信息
com.core.common.core.domain.model.LoginUser loginUser = com.core.common.utils.SecurityUtils.getLoginUser();
Long doctorId = loginUser.getPractitionerId();
// 如果没有获取到医生ID尝试使用用户ID
if (doctorId == null || doctorId == 0) {
doctorId = loginUser.getUserId();
System.out.println("Using userId as doctorId: " + doctorId);
} else {
System.out.println("Using practitionerId as doctorId: " + doctorId);
}
// 获取今天的日期
LocalDate today = LocalDate.now();
System.out.println("Querying schedule for date: " + today);
// 查询当前医生今天的排班信息从SchedulePool表
LambdaQueryWrapper<SchedulePool> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SchedulePool::getScheduleDate, today) // 根据具体日期查询
.eq(SchedulePool::getDoctorId, doctorId) // 根据医生ID查询
.eq(SchedulePool::getStatus, 1); // 只查询可用的排班
List<SchedulePool> list = schedulePoolService.list(queryWrapper);
System.out.println("Found " + list.size() + " schedules for doctorId: " + doctorId);
// 为了支持多种日程类型,我们可以在这里整合来自不同数据源的信息
// 目前只返回排班信息,但为以后扩展预留空间
return R.ok(list);
} catch (Exception e) {
System.err.println("Error getting today's schedule: " + e.getMessage());
e.printStackTrace();
return R.fail("获取排班信息失败:" + e.getMessage());
}
}
@Override
public R<?> addDoctorSchedule(DoctorSchedule doctorSchedule) {
if (ObjectUtil.isEmpty(doctorSchedule)) {

View File

@@ -89,4 +89,13 @@ public class DoctorScheduleController {
return R.ok(doctorScheduleAppService.getTodayDoctorScheduleList());
}
/*
* 获取当前登录医生今日排班List
*
* */
@GetMapping("/today-my-schedule")
public R<?> getTodayMySchedule() {
return doctorScheduleAppService.getTodayMySchedule();
}
}