|
@@ -28,7 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
/**
|
|
|
* 志愿者排班日期Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2025-04-07
|
|
|
*/
|
|
@@ -43,7 +43,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 查询志愿者排班日期
|
|
|
- *
|
|
|
+ *
|
|
|
* @param volunteerWorkDateId 志愿者排班日期主键
|
|
|
* @return 志愿者排班日期
|
|
|
*/
|
|
@@ -55,7 +55,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 查询志愿者排班日期列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param volunteerWorkDate 志愿者排班日期
|
|
|
* @return 志愿者排班日期
|
|
|
*/
|
|
@@ -67,7 +67,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 新增志愿者排班日期
|
|
|
- *
|
|
|
+ *
|
|
|
* @param volunteerWorkDate 志愿者排班日期
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -79,7 +79,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 修改志愿者排班日期
|
|
|
- *
|
|
|
+ *
|
|
|
* @param list 志愿者排班日期集合
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -95,6 +95,23 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
if (CollectionUtil.isEmpty(infos)){
|
|
|
return AjaxResult.error("您还未注册为志愿者,请先注册");
|
|
|
}
|
|
|
+ //首先判断如果传过来的日期都没有,那么
|
|
|
+ if (list.isEmpty()){
|
|
|
+ //获取已预约的日期
|
|
|
+ List<VolunteerWorkDate> reservationList = this.list(new LambdaQueryWrapper<VolunteerWorkDate>()
|
|
|
+ .eq(VolunteerWorkDate::getVolunteerId, userId)
|
|
|
+ .eq(VolunteerWorkDate::getHasReservation, 1));
|
|
|
+ List<LocalDate> reservations = reservationList.stream().map(VolunteerWorkDate::getWorkDate).collect(Collectors.toList());
|
|
|
+ List<LocalDate> dates = list.stream().map(VolunteerWorkDate::getWorkDate).collect(Collectors.toList());
|
|
|
+ for (LocalDate date : reservations) {
|
|
|
+ if (!dates.contains(date)){
|
|
|
+ //把reservation转换为月日
|
|
|
+ return AjaxResult.error(date.format( DateTimeFormatter.ofPattern("M月d日"))+"已被预约,无法取消,请联系客户取消预约");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.remove(new LambdaQueryWrapper<VolunteerWorkDate>().eq(VolunteerWorkDate::getVolunteerId, userId));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
//判断是否排了今天之前的日期
|
|
|
LocalDate workDate = list.get(0).getWorkDate();
|
|
|
if (workDate.isBefore(LocalDate.now())){
|
|
@@ -129,7 +146,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 批量删除志愿者排班日期
|
|
|
- *
|
|
|
+ *
|
|
|
* @param volunteerWorkDateIds 需要删除的志愿者排班日期主键
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -141,7 +158,7 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
|
|
|
/**
|
|
|
* 删除志愿者排班日期信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param volunteerWorkDateId 志愿者排班日期主键
|
|
|
* @return 结果
|
|
|
*/
|