|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.dromara.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
@ -111,6 +112,15 @@ public class BaseMaterialTypeServiceImpl implements IBaseMaterialTypeService {
|
|
|
|
|
*/
|
|
|
|
|
private void validEntityBeforeSave(BaseMaterialType entity){
|
|
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
|
if (StringUtils.isNotBlank(entity.getMatrialTypeCode())) {
|
|
|
|
|
BaseMaterialTypeBo query = new BaseMaterialTypeBo();
|
|
|
|
|
query.setMatrialTypeCode(entity.getMatrialTypeCode());
|
|
|
|
|
MPJLambdaWrapper<BaseMaterialType> lqw = buildQueryWrapper(query);
|
|
|
|
|
BaseMaterialType baseMaterialType = baseMapper.selectOne(lqw);
|
|
|
|
|
if (baseMaterialType != null && !baseMaterialType.getMatrialTypeId().equals(entity.getMatrialTypeId())) {
|
|
|
|
|
throw new ServiceException("编码已存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -124,6 +134,14 @@ public class BaseMaterialTypeServiceImpl implements IBaseMaterialTypeService {
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if(isValid){
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
for (Long id : ids) {
|
|
|
|
|
//TODO 校验是否需要删除
|
|
|
|
|
BaseMaterialType query = new BaseMaterialType();
|
|
|
|
|
query.setParentId(id);
|
|
|
|
|
if (baseMapper.selectCount(Wrappers.lambdaQuery(query)) > 0) {
|
|
|
|
|
throw new ServiceException("存在子节点,不允许删除");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
}
|
|
|
|
|