Controller
/**
* 批量删除
* @param list
* @return
*/
@PostMapping("/removeBatchById")
public Result removeBatchById( @RequestBody List<Long> list){
userinfoService.removeBatchById(list);
return Result.OK("批量删除成功",list);
}
Service
/**
* 根据编号数组批量删除用户信息
* @param idList
*/
public void removeBatchById(List<Long> idList){
userinfoMapper.deleteBatchById(idList);
}
Dao
/**
* 批量删除方法
* @param idList
*/
void deleteBatchById(List<Long> idList);
Mapper.xml
<!--批量删除的写法 -->
<delete id="deleteBatchById" >
delete from tb_userinfo ur where id in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
备注:collection=“list” 表示参数是动态数组类型