parent
626531858d
commit
bf94219313
4 changed files with 80 additions and 1 deletions
@ -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); |
||||
} |
||||
} |
||||
@ -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…
Reference in new issue