|
@@ -5,6 +5,8 @@ import java.util.List;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.huashe.common.exception.ServiceException;
|
|
|
+import com.huashe.park.common.i18n.MessageUtils;
|
|
|
import com.huashe.park.core.mapper.ConsUnitInfoMapper;
|
|
|
import com.huashe.park.core.service.IConsUnitInfoService;
|
|
|
import com.huashe.park.domain.entity.ConsUnitInfo;
|
|
@@ -17,6 +19,7 @@ import com.huashe.park.domain.entity.ConsUnitInfo;
|
|
|
*/
|
|
|
@Service
|
|
|
public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
+
|
|
|
@Autowired
|
|
|
private ConsUnitInfoMapper consUnitInfoMapper;
|
|
|
|
|
@@ -27,7 +30,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
* @return 施工单元
|
|
|
*/
|
|
|
@Override
|
|
|
- public ConsUnitInfo selectConsUnitInfoById(String id) {
|
|
|
+ public ConsUnitInfo selectConsUnitInfoById(Long id) {
|
|
|
return consUnitInfoMapper.selectConsUnitInfoById(id);
|
|
|
}
|
|
|
|
|
@@ -50,6 +53,8 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertConsUnitInfo(ConsUnitInfo consUnitInfo) {
|
|
|
+ ConsUnitInfo parentConsUnit = consUnitInfoMapper.selectConsUnitInfoById(consUnitInfo.getParentId());
|
|
|
+ consUnitInfo.setAncestors(parentConsUnit.getAncestors() + "," + parentConsUnit.getId());
|
|
|
return consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
|
|
|
}
|
|
|
|
|
@@ -61,6 +66,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateConsUnitInfo(ConsUnitInfo consUnitInfo) {
|
|
|
+ if (consUnitInfo.getParentId().equals(consUnitInfo.getId())) {
|
|
|
+ throw new ServiceException(MessageUtils.message("cons.unit.modify.not.self", consUnitInfo.getName()));
|
|
|
+ }
|
|
|
return consUnitInfoMapper.updateConsUnitInfo(consUnitInfo);
|
|
|
}
|
|
|
|
|
@@ -71,10 +79,20 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteConsUnitInfoByIds(String[] ids) {
|
|
|
+ public int deleteConsUnitInfoByIds(Long[] ids) {
|
|
|
return consUnitInfoMapper.deleteConsUnitInfoByIds(ids);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean hasChildById(Long id) {
|
|
|
+ return consUnitInfoMapper.hasChildById(id) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean hasHoleById(Long id) {
|
|
|
+ return consUnitInfoMapper.hasHoleById(id) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除施工单元信息
|
|
|
*
|
|
@@ -82,7 +100,13 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteConsUnitInfoById(String id) {
|
|
|
+ public int deleteConsUnitInfoById(Long id) {
|
|
|
+ if (hasChildById(id)) {
|
|
|
+ throw new ServiceException(MessageUtils.message("cons.unit.delete.no.child"));
|
|
|
+ }
|
|
|
+ if (hasHoleById(id)) {
|
|
|
+ throw new ServiceException(MessageUtils.message("cons.unit.has.no.hole"));
|
|
|
+ }
|
|
|
return consUnitInfoMapper.deleteConsUnitInfoById(id);
|
|
|
}
|
|
|
}
|