|
|
@@ -14,6 +14,7 @@ import org.dromara.business.mapper.ItemsMapper;
|
|
|
import org.dromara.business.service.IItemsService;
|
|
|
import org.dromara.business.utils.RedisKeys;
|
|
|
import org.dromara.business.utils.RedisUtil;
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -295,7 +296,18 @@ public class ItemsServiceImpl implements IItemsService {
|
|
|
if(isValid){
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
- return baseMapper.deleteByItemsById(ids) > 0;
|
|
|
+
|
|
|
+ try {
|
|
|
+ int deletedRows = baseMapper.deleteByItemsById(ids);
|
|
|
+ return deletedRows > 0;
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 捕获数据库约束异常
|
|
|
+ if (e.getMessage().contains("constraint") || e.getMessage().contains("foreign key")) {
|
|
|
+ throw new ServiceException("存在关联数据,无法删除该道具!");
|
|
|
+ }
|
|
|
+ log.error("删除道具失败", e);
|
|
|
+ throw new ServiceException("删除失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|