mybatisplus通用批量修改

准备工作见上一篇批量插入

根据id批量修改

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

/**
 * @author  xiu
 * @date  2022/1/27 11:13
 * @description 根据id批量修改
 */
public class MyUpdateListSelectiveMethod extends AbstractMethod {

    public MyUpdateListSelectiveMethod(String methodName) {
        super(methodName);
    }

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        StringBuilder sql = new StringBuilder();
        sql.append("");
        SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql.toString(), modelClass);
        return this.addUpdateMappedStatement(mapperClass, modelClass, sqlSource);
    }
}

然后就能通过myUpdateListSelective进行批量修改数据了

你可能感兴趣的:(mybatisplus,mybatis,java)