| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.tool.node.TreeNode; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.patrol.dto.PatrolGroupDTO; |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean removePatrolGroupByIds(List<String> asList) { |
| | | if (asList == null || asList.isEmpty()) { |
| | | return false; |
| | | } |
| | | // 将IPatrolGroupItemService实例化提到循环外部以避免重复实例化 |
| | | IPatrolGroupItemService bean = SpringUtils.getBean(IPatrolGroupItemService.class); |
| | | boolean allSuccess = true; // 记录是否有任何操作失败 |
| | | for (String id : asList) { |
| | | try { |
| | | PatrolGroup patrolGroup = baseMapper.selectById(id); |
| | | if (patrolGroup != null) { |
| | | patrolGroup.setIsDeleted(1); |
| | | int update = baseMapper.updateById(patrolGroup); |
| | | if (update > 0) { |
| | | allSuccess = bean.update(Wrappers.<PatrolGroupItem>lambdaUpdate() |
| | | .set(PatrolGroupItem::getIsDeleted, 1) |
| | | .eq(PatrolGroupItem::getGroupId, id)); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // 记录或处理异常,例如日志记录 |
| | | // log.error("Failed to remove patrol group by id: " + id, e); |
| | | allSuccess = false; |
| | | } |
| | | } |
| | | return allSuccess; |
| | | } |
| | | |
| | | } |