对数据保存做一个判定,如果模型设置id,则不复盖模型原有的id
This commit is contained in:
parent
9fedc25f3f
commit
886ea29c6d
@ -29,9 +29,12 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
this.setFieldValByName("deleteFlag", false, metaObject);
|
||||
}
|
||||
if (metaObject.hasGetter("id")) {
|
||||
//如果已经配置id,则不再写入
|
||||
if (metaObject.getValue("id") == null) {
|
||||
this.setFieldValByName("id", String.valueOf(SnowFlake.getId()), metaObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
|
@ -1,15 +1,10 @@
|
||||
package cn.lili.base.mybatisplus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
||||
import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@ -21,12 +16,16 @@ public class MybatisPlusConfig {
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
|
||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
// 攻击 SQL 阻断解析器、加入解析链
|
||||
sqlParserList.add(new BlockAttackSqlParser());
|
||||
paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
return paginationInterceptor;
|
||||
return new PaginationInterceptor();
|
||||
|
||||
//阻断解析器,测试环境使用
|
||||
// PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
//
|
||||
// List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
// // 攻击 SQL 阻断解析器、加入解析链
|
||||
// sqlParserList.add(new BlockAttackSqlParser());
|
||||
// paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
// return paginationInterceptor;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user