public Integer deleteByIds(List<Integer> ids) { } 用这个方法写个逻辑删除,用mybatis-plus,这是VO类 @Data @ApiModel(value = "飞行任务管理-后端列表页vo") public class BisTaskVO extends PageReqVO implements Serializable { @ApiModelProperty(value = "id") private Integer id; @ApiModelProperty(value = "逻辑删除 1是 0否") private Integer isDel; @TableField(exist = false) private List<Integer> ids; } 再用DataResult写个调用方法,不要写mapper和sql
时间: 2024-01-07 21:06:00 浏览: 28
好的,可以参考以下代码:
```java
@Service
public class BisTaskService {
@Autowired
private BisTaskMapper bisTaskMapper;
/**
* 批量逻辑删除
*/
public DataResult<Object> deleteByIds(List<Integer> ids) {
DataResult<Object> result = new DataResult<>();
if (CollectionUtils.isEmpty(ids)) {
result.setResultCode(ResultCode.PARAM_ERROR);
result.setResultMessage("ids不能为空");
return result;
}
int count = bisTaskMapper.deleteByIds(ids);
result.setData(count);
return result;
}
}
@Mapper
public interface BisTaskMapper extends BaseMapper<BisTask> {
/**
* 批量逻辑删除
*/
int deleteByIds(List<Integer> ids);
}
```
其中,BisTaskMapper 继承自 Mybatis-Plus 的 BaseMapper,无需写 SQL 语句,直接调用 Mapper 的 deleteByIds 方法即可实现批量逻辑删除。BisTaskService 中的 deleteByIds 方法中,先判断 ids 是否为空,然后调用 Mapper 的 deleteByIds 方法,最后将删除的数量封装到 DataResult 中返回。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)