格式化代码.
This commit is contained in:
parent
d0de7f2842
commit
52e289148a
@ -15,14 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.baomidou.mybatisplus.core.toolkit;
|
package com.baomidou.mybatisplus.core.toolkit;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL 表名解析
|
* SQL 表名解析
|
||||||
* <p>
|
* <p>
|
||||||
* https://github.com/mnadeem/sql-table-name-parser
|
* <a href="https://github.com/mnadeem/sql-table-name-parser">...</a>
|
||||||
* <p>
|
* <p>
|
||||||
* Ultra light, Ultra fast parser to extract table name out SQLs, supports oracle dialect SQLs as well.
|
* Ultra light, Ultra fast parser to extract table name out SQLs, supports oracle dialect SQLs as well.
|
||||||
* USE: new TableNameParser(sql).tables()
|
* USE: new TableNameParser(sql).tables()
|
||||||
@ -123,7 +129,7 @@ public final class TableNameParser {
|
|||||||
* @param sql SQL
|
* @param sql SQL
|
||||||
* @return 语句
|
* @return 语句
|
||||||
*/
|
*/
|
||||||
protected List<SqlToken> fetchAllTokens(String sql) {
|
private List<SqlToken> fetchAllTokens(String sql) {
|
||||||
List<SqlToken> tokens = new ArrayList<>();
|
List<SqlToken> tokens = new ArrayList<>();
|
||||||
Matcher matcher = NON_SQL_TOKEN_PATTERN.matcher(sql);
|
Matcher matcher = NON_SQL_TOKEN_PATTERN.matcher(sql);
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
@ -35,9 +35,12 @@ import java.util.function.Consumer;
|
|||||||
* @since 2021-07-23
|
* @since 2021-07-23
|
||||||
*/
|
*/
|
||||||
public class DdlScript {
|
public class DdlScript {
|
||||||
private DataSource dataSource;
|
|
||||||
private IDdlGenerator ddlGenerator;
|
private final DataSource dataSource;
|
||||||
private boolean autoCommit;
|
|
||||||
|
private final IDdlGenerator ddlGenerator;
|
||||||
|
|
||||||
|
private final boolean autoCommit;
|
||||||
|
|
||||||
public DdlScript(DataSource dataSource) {
|
public DdlScript(DataSource dataSource) {
|
||||||
this(dataSource, null);
|
this(dataSource, null);
|
||||||
|
@ -28,6 +28,7 @@ import java.util.function.Consumer;
|
|||||||
* @since 2021-09-23
|
* @since 2021-09-23
|
||||||
*/
|
*/
|
||||||
public class SimpleDdl implements IDdl {
|
public class SimpleDdl implements IDdl {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
@ -40,4 +41,5 @@ public class SimpleDdl implements IDdl {
|
|||||||
public List<String> getSqlFiles() {
|
public List<String> getSqlFiles() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
|
|||||||
|
|
||||||
private final ConversionService conversionService = DefaultConversionService.getSharedInstance();
|
private final ConversionService conversionService = DefaultConversionService.getSharedInstance();
|
||||||
|
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
protected final Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected M baseMapper;
|
protected M baseMapper;
|
||||||
@ -71,14 +71,14 @@ public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
|
|||||||
return baseMapper;
|
return baseMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class<T> entityClass = currentModelClass();
|
protected final Class<T> entityClass = currentModelClass();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<T> getEntityClass() {
|
public Class<T> getEntityClass() {
|
||||||
return entityClass;
|
return entityClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class<M> mapperClass = currentMapperClass();
|
protected final Class<M> mapperClass = currentMapperClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断数据库操作是否成功
|
* 判断数据库操作是否成功
|
||||||
|
@ -53,14 +53,14 @@ public class InjectionConfig {
|
|||||||
* 自定义模板文件,key为文件名称,value为模板路径(已弃用,换成了customFiles,3.5.4版本会删除此方法)
|
* 自定义模板文件,key为文件名称,value为模板路径(已弃用,换成了customFiles,3.5.4版本会删除此方法)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private Map<String, String> customFile = new HashMap<>();
|
private final Map<String, String> customFile = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义模板文件列表
|
* 自定义模板文件列表
|
||||||
*
|
*
|
||||||
* @since 3.5.3
|
* @since 3.5.3
|
||||||
*/
|
*/
|
||||||
private List<CustomFile> customFiles = new ArrayList<>();
|
private final List<CustomFile> customFiles = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否覆盖已有文件(默认 false)(已弃用,已放到自定义文件类CustomFile中,3.5.4版本会删除此方法)
|
* 是否覆盖已有文件(默认 false)(已弃用,已放到自定义文件类CustomFile中,3.5.4版本会删除此方法)
|
||||||
@ -73,7 +73,6 @@ public class InjectionConfig {
|
|||||||
/**
|
/**
|
||||||
* 输出文件前
|
* 输出文件前
|
||||||
*/
|
*/
|
||||||
@NotNull
|
|
||||||
public void beforeOutputFile(TableInfo tableInfo, Map<String, Object> objectMap) {
|
public void beforeOutputFile(TableInfo tableInfo, Map<String, Object> objectMap) {
|
||||||
if (!customMap.isEmpty()) {
|
if (!customMap.isEmpty()) {
|
||||||
objectMap.putAll(customMap);
|
objectMap.putAll(customMap);
|
||||||
@ -195,4 +194,5 @@ public class InjectionConfig {
|
|||||||
return this.injectionConfig;
|
return this.injectionConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public abstract class BaseKeyWordsHandler implements IKeyWordsHandler {
|
public abstract class BaseKeyWordsHandler implements IKeyWordsHandler {
|
||||||
|
|
||||||
public Set<String> keyWords;
|
public final Set<String> keyWords;
|
||||||
|
|
||||||
public BaseKeyWordsHandler(@NotNull List<String> keyWords) {
|
public BaseKeyWordsHandler(@NotNull List<String> keyWords) {
|
||||||
this.keyWords = new HashSet<>(keyWords);
|
this.keyWords = new HashSet<>(keyWords);
|
||||||
@ -47,4 +47,5 @@ public abstract class BaseKeyWordsHandler implements IKeyWordsHandler {
|
|||||||
public boolean isKeyWords(@NotNull String columnName) {
|
public boolean isKeyWords(@NotNull String columnName) {
|
||||||
return getKeyWords().contains(columnName.toUpperCase(Locale.ENGLISH));
|
return getKeyWords().contains(columnName.toUpperCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DdlApplicationRunner implements ApplicationRunner {
|
public class DdlApplicationRunner implements ApplicationRunner {
|
||||||
private List<IDdl> ddlList;
|
|
||||||
|
private final List<IDdl> ddlList;
|
||||||
|
|
||||||
public DdlApplicationRunner(List<IDdl> ddlList) {
|
public DdlApplicationRunner(List<IDdl> ddlList) {
|
||||||
this.ddlList = ddlList;
|
this.ddlList = ddlList;
|
||||||
@ -51,4 +52,5 @@ public class DdlApplicationRunner implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
log.debug(" ... DDL end create ... ");
|
log.debug(" ... DDL end create ... ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user