parent
128b9dc21a
commit
973a923bf8
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.mall.mybatis.core;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.mybatis.core.injector.CustomSqlInject;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hccake 2020/8/3
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class MybatisPlusAutoConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义方法扩展注入器
|
||||||
|
* @return ISqlInjector CustomSqlInject
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(ISqlInjector.class)
|
||||||
|
public ISqlInjector sqlInjector(){
|
||||||
|
return new CustomSqlInject();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package cn.iocoder.mall.mybatis.core.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hccake 2020/8/3
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public enum CustomSqlMethodEnum {
|
||||||
|
/**
|
||||||
|
* 批量插入
|
||||||
|
*/
|
||||||
|
INSERT_BATCH("insertByBatch",
|
||||||
|
"批量插入数据",
|
||||||
|
"<script>\n"
|
||||||
|
+ "INSERT INTO %s %s VALUES \n"
|
||||||
|
+ "<foreach collection=\"collection\" item=\"item\" separator=\",\"> %s\n </foreach>\n"
|
||||||
|
+ "</script>");
|
||||||
|
|
||||||
|
private final String method;
|
||||||
|
private final String desc;
|
||||||
|
private final String sql;
|
||||||
|
|
||||||
|
CustomSqlMethodEnum(String method, String desc, String sql) {
|
||||||
|
this.method = method;
|
||||||
|
this.desc = desc;
|
||||||
|
this.sql = sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSql() {
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.mall.mybatis.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper 层基类
|
||||||
|
* @author Hccake 2020/8/3
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public interface CommonMapper<T> extends BaseMapper<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入
|
||||||
|
* @param collection 批量插入数据
|
||||||
|
* @return ignore
|
||||||
|
*/
|
||||||
|
int insertByBatch(@Param("collection") Collection<T> collection);
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
|
cn.iocoder.mall.mybatis.core.MybatisPlusAutoConfiguration
|
||||||
Loading…
Reference in new issue