add
This commit is contained in:
@@ -162,6 +162,14 @@ public class AdminController {
|
||||
return ApiResponse.success(scheduleMapper.listByDate(java.time.LocalDate.parse(date)));
|
||||
}
|
||||
|
||||
@GetMapping("/schedules/range")
|
||||
public ApiResponse<List<Schedule>> listSchedulesRange(@RequestParam String start, @RequestParam String end) {
|
||||
return ApiResponse.success(scheduleMapper.listByDateRange(
|
||||
java.time.LocalDate.parse(start),
|
||||
java.time.LocalDate.parse(end)
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/schedules")
|
||||
public ApiResponse<Schedule> createSchedule(@RequestBody ScheduleRequest request) {
|
||||
Schedule schedule = new Schedule();
|
||||
|
||||
@@ -40,6 +40,16 @@ public class NurseController {
|
||||
return ApiResponse.success(scheduleMapper.listByNurseAndDate(nurseId, java.time.LocalDate.parse(date)));
|
||||
}
|
||||
|
||||
@GetMapping("/schedules/range")
|
||||
public ApiResponse<List<Schedule>> listSchedulesRange(@RequestParam String start, @RequestParam String end) {
|
||||
Long nurseId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(scheduleMapper.listByNurseAndDateRange(
|
||||
nurseId,
|
||||
java.time.LocalDate.parse(start),
|
||||
java.time.LocalDate.parse(end)
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/care-records")
|
||||
public ApiResponse<CareRecord> createCare(@RequestBody CareRecordRequest request) {
|
||||
CareRecord record = new CareRecord();
|
||||
|
||||
@@ -14,6 +14,12 @@ public interface ScheduleMapper {
|
||||
@Select("SELECT * FROM schedule WHERE date = #{date} ORDER BY id DESC")
|
||||
List<Schedule> listByDate(LocalDate date);
|
||||
|
||||
@Select("SELECT * FROM schedule WHERE date BETWEEN #{start} AND #{end} ORDER BY date ASC")
|
||||
List<Schedule> listByDateRange(@Param("start") LocalDate start, @Param("end") LocalDate end);
|
||||
|
||||
@Select("SELECT * FROM schedule WHERE nurse_id = #{nurseId} AND date BETWEEN #{start} AND #{end} ORDER BY date ASC")
|
||||
List<Schedule> listByNurseAndDateRange(@Param("nurseId") Long nurseId, @Param("start") LocalDate start, @Param("end") LocalDate end);
|
||||
|
||||
@Insert("INSERT INTO schedule(nurse_id, date, shift, task, created_at, updated_at) VALUES(#{nurseId}, #{date}, #{shift}, #{task}, NOW(), NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Schedule schedule);
|
||||
|
||||
Reference in New Issue
Block a user