|
@@ -15,8 +15,10 @@ import com.leromro.common.core.domain.AjaxResult;
|
|
|
import com.leromro.common.core.domain.R;
|
|
|
import com.leromro.common.exception.ServiceException;
|
|
|
import com.leromro.common.utils.SecurityUtils;
|
|
|
+import com.leromro.core.domain.VolunteerInfo;
|
|
|
import com.leromro.core.mapper.VolunteerWorkDateMapper;
|
|
|
import com.leromro.common.utils.DateUtils;
|
|
|
+import com.leromro.core.service.IVolunteerInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.leromro.core.mapper.VolunteerWorkDateMapper;
|
|
@@ -36,6 +38,9 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
@Autowired
|
|
|
private VolunteerWorkDateMapper volunteerWorkDateMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IVolunteerInfoService volunteerInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询志愿者排班日期
|
|
|
*
|
|
@@ -84,10 +89,22 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
{
|
|
|
// 获取当前用户信息
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
- // 查询出所有已经预约的日期
|
|
|
+ //判断当前用户是否已经注册了志愿者
|
|
|
+ List<VolunteerInfo> infos = volunteerInfoService.list(new LambdaQueryWrapper<VolunteerInfo>()
|
|
|
+ .eq(VolunteerInfo::getUserId, userId));
|
|
|
+ if (CollectionUtil.isEmpty(infos)){
|
|
|
+ return AjaxResult.error("您还未注册为志愿者,请先注册");
|
|
|
+ }
|
|
|
+ //判断是否排了今天之前的日期
|
|
|
+ LocalDate workDate = list.get(0).getWorkDate();
|
|
|
+ if (workDate.isBefore(LocalDate.now())){
|
|
|
+ return AjaxResult.error("排班日期不能设置为今天以前");
|
|
|
+ }
|
|
|
+ // 查询出所有已经预约的日期,今天和今天以后的
|
|
|
List<VolunteerWorkDate> reservationList = this.list(new LambdaQueryWrapper<VolunteerWorkDate>()
|
|
|
.eq(VolunteerWorkDate::getVolunteerId, userId)
|
|
|
- .eq(VolunteerWorkDate::getHasReservation, 1));
|
|
|
+ .eq(VolunteerWorkDate::getHasReservation, 1)
|
|
|
+ .ge(VolunteerWorkDate::getWorkDate, LocalDate.now()));
|
|
|
// 如果存在则判断已经预约的日期是否被删除,如果被删除则提示不能修改
|
|
|
if (CollectionUtil.isNotEmpty(reservationList)){
|
|
|
List<LocalDate> dates = list.stream().map(VolunteerWorkDate::getWorkDate).collect(Collectors.toList());
|
|
@@ -137,7 +154,8 @@ public class VolunteerWorkDateServiceImpl extends ServiceImpl<VolunteerWorkDateM
|
|
|
// 获取当前用户信息
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
List<VolunteerWorkDate> list = this.list(new LambdaQueryWrapper<VolunteerWorkDate>()
|
|
|
- .eq(VolunteerWorkDate::getVolunteerId, userId));
|
|
|
+ .eq(VolunteerWorkDate::getVolunteerId, userId)
|
|
|
+ .ge(VolunteerWorkDate::getWorkDate, LocalDate.now()));
|
|
|
return R.ok(list);
|
|
|
}
|
|
|
}
|