java中批量删除|sql解决
mapper层接口:
public int deleteTrainClassByIds(Long[] classIds);
对应的sql语句:
<update id="deleteTrainClassByIds" parameterType="String">
update train_class
<trim prefix="SET" suffixOverrides=",">
is_delete='2'
</trim>
where class_id in
<foreach item="classId" collection="array" open="(" separator="," close=")">
#{classId}
</foreach>
and is_delete='1'
</update>
server层接口:
public int deleteTrainClassByIds(Long[] classIds);
serverImpl实现类:
public int deleteTrainClassByIds(Long[] classIds) {
return trainClassMapper.deleteTrainClassByIds(classIds);
}
controller层代码
public AjaxResult remove(@PathVariable Long[] classIds) {
return toAjax(trainClassService.deleteTrainClassByIds(classIds));
}