|
@@ -2,6 +2,9 @@ package beilv.venue.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import beilv.common.exception.ServiceException;
|
|
|
+import beilv.session.mapper.BeilvSessionMapper;
|
|
|
+import beilv.site.mapper.BeilvSiteMapper;
|
|
|
import beilv.venue.domain.BeilvVenue;
|
|
|
import beilv.venue.mapper.BeilvVenueMapper;
|
|
|
import beilv.venue.service.IBeilvVenueService;
|
|
@@ -22,6 +25,12 @@ public class BeilvVenueServiceImpl implements IBeilvVenueService
|
|
|
@Autowired
|
|
|
private BeilvVenueMapper beilvVenueMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BeilvSiteMapper beilvSiteMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BeilvSessionMapper beilvSessionMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询场馆信息
|
|
|
*
|
|
@@ -79,8 +88,31 @@ public class BeilvVenueServiceImpl implements IBeilvVenueService
|
|
|
@Override
|
|
|
public int deleteBeilvVenueByIds(String ids)
|
|
|
{
|
|
|
+ Long[] venueIds = Convert.toLongArray(ids);
|
|
|
+
|
|
|
+ // 检查场馆是否绑定了球场或时段
|
|
|
+ for (Long venueId : venueIds) {
|
|
|
+ BeilvVenue beilvVenue = selectBeilvVenueById(venueId);
|
|
|
+ if (countSessionByVenueId(venueId) > 0 || countSiteByVenueId(venueId) > 0)
|
|
|
+ {
|
|
|
+ throw new ServiceException(String.format("%1$s已分配,不能删除", beilvVenue.getVenueName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
return beilvVenueMapper.deleteBeilvVenueByIds(Convert.toStrArray(ids));
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public int countSessionByVenueId(Long venueId)
|
|
|
+ {
|
|
|
+ return beilvSessionMapper.countSessionByVenueId(venueId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查场馆是否绑定了球场
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int countSiteByVenueId(Long venueId) {
|
|
|
+ return beilvSiteMapper.countSiteByVenueId(venueId);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 删除场馆信息信息
|