All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.diboot.core.methods.DeleteBatchByIdsInRecycleBin Maven / Gradle / Ivy

There is a newer version: 3.4.2
Show newest version
package com.diboot.core.methods;

import com.baomidou.mybatisplus.core.enums.SqlMethod;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.defaults.RawSqlSource;

public class DeleteBatchByIdsInRecycleBin extends AbstractMethod {
    public DeleteBatchByIdsInRecycleBin() {
        this(RecycleBinSqlMethod.DELETE_BATCH_BY_IDS.getMethod());
    }

    public DeleteBatchByIdsInRecycleBin(String name) {
        super(name);
    }

    @Override
    public MappedStatement injectMappedStatement(Class mapperClass, Class modelClass, TableInfo tableInfo) {
        String sql;
        SqlSource sqlSource;
        RecycleBinSqlMethod sqlMethod = RecycleBinSqlMethod.DELETE_BATCH_BY_IDS;
        sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(), SqlScriptUtils.convertForeach(SqlScriptUtils.convertChoose("@org.apache.ibatis.type.SimpleTypeRegistry@isSimpleType(item.getClass())", "#{item}", "#{item." + tableInfo.getKeyProperty() + "}"), "coll", (String)null, "item", ","), " AND NOT (" + tableInfo.getLogicDeleteSql(true, true) + ")");
        sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, Object.class);
        return this.addDeleteMappedStatement(mapperClass, this.methodName, sqlSource);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy