批量修改:
1.手动添加批量删除方法
/**
* 批量逻辑删除
*
* @param commentsList
* @return
*/
@Update({
"<script>",
"<foreach collection='commentsList' item='item' index='index' separator=';'>",
"UPDATE t_task_audit SET ",
"delete_flag=1",
"WHERE task_id=#{item.taskId}",
"</foreach>",
"</script>"
})
int updateBatch(@Param("commentsList") List<CommentsObject> commentsList);
2.使用注解@TableLogic,配合yml配置文件使用mybatis-plus自带的删除方法
// 删除标识
@TableLogic
private String deleteFlag;
mybatis-plus:
global-config:
db-config:
logic-delete-value: 1
logic-not-delete-value: 0
调用mybatis-plus删除方法,效果就是逻辑删除
组装idList,批量删除
List<String> idList = new ArrayList<>();
for (CommentsObject comments : commentsList) {
idList.add(comments.getId());
}
//批量逻辑删除审批记录
int count = commentsObjectMapper.deleteBatchIds(idList);
logger.info("批量删除主表" + record.getTaskId() + "相关的表记录" + count + "条");
https://blog.csdn.net/ypp91zr/article/details/112941355