添加物理删除相关方法。

develop-QA
Tom Li 3 months ago
parent 626531858d
commit bf94219313
  1. 36
      blade-service/blade-desk/src/main/java/org/springblade/desk/basic/mapper/en/DeleteAbsoluteById.java
  2. 10
      blade-service/blade-desk/src/main/java/org/springblade/desk/basic/mapper/en/EnBaseMapper.java
  3. 17
      blade-service/blade-desk/src/main/java/org/springblade/desk/basic/mapper/en/EnCustomSqlInjector.java
  4. 18
      blade-service/blade-desk/src/main/java/org/springblade/desk/basic/mapper/en/EnMyBatisConfig.java

@ -0,0 +1,36 @@
package org.springblade.desk.basic.mapper.en;
import com.baomidou.mybatisplus.core.enums.SqlMethod;
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;
import java.beans.Introspector;
/**
* deleteAbsoluteById
*/
public class DeleteAbsoluteById extends AbstractMethod {
public DeleteAbsoluteById() {
this(Introspector.decapitalize(DeleteAbsoluteById.class.getSimpleName()));
}
/**
* @param methodName 方法名
* @since 3.5.0
*/
protected DeleteAbsoluteById(String methodName) {
super(methodName);
}
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
SqlMethod sqlMethod = SqlMethod.DELETE_BY_ID;
String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
tableInfo.getKeyProperty());
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
return this.addDeleteMappedStatement(mapperClass, methodName, sqlSource);
}
}

@ -3,11 +3,19 @@ package org.springblade.desk.basic.mapper.en;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serializable;
/**
* Enhance MyBatis Plus BaseMapper.
*
* @param <T>
*/
public interface EnBaseMapper<T extends BaseEntity> extends BaseMapper<T> {
/**
* 根据 ID 物理删除
* @param id
* @return
*/
int deleteAbsoluteById(Serializable id);
}

@ -0,0 +1,17 @@
package org.springblade.desk.basic.mapper.en;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import java.util.List;
public class EnCustomSqlInjector extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
methodList.add(new DeleteAbsoluteById());
return methodList;
}
}

@ -0,0 +1,18 @@
package org.springblade.desk.basic.mapper.en;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class EnMyBatisConfig {
/**
* 注册自定义SQL注入器
*
* @return
*/
@Bean
public EnCustomSqlInjector customSqlInjector() {
return new EnCustomSqlInjector();
}
}
Loading…
Cancel
Save