mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
style: code format.
This commit is contained in:
parent
8b621fbdc9
commit
f03ad784c9
@ -24,4 +24,5 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.FIELD})
|
@Target({ElementType.FIELD})
|
||||||
public @interface EnumValue {
|
public @interface EnumValue {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ public class Generator {
|
|||||||
|
|
||||||
buildPrimaryKey(table);
|
buildPrimaryKey(table);
|
||||||
|
|
||||||
dialect.buildTableColumns(schemaName,table, globalConfig, dbMeta, conn);
|
dialect.buildTableColumns(schemaName, table, globalConfig, dbMeta, conn);
|
||||||
|
|
||||||
tables.add(table);
|
tables.add(table);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,18 +70,18 @@ public interface IDialect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResultSet forRemarks(String schema, Table table, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
|
protected ResultSet forRemarks(String schema, Table table, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
|
||||||
if (conn instanceof OracleConnection){
|
if (conn instanceof OracleConnection) {
|
||||||
((OracleConnection) conn).setRemarksReporting(true);
|
((OracleConnection) conn).setRemarksReporting(true);
|
||||||
return dbMeta.getColumns(conn.getCatalog(), StringUtil.isNotBlank(schema) ? schema : dbMeta.getUserName(), table.getName(), null);
|
return dbMeta.getColumns(conn.getCatalog(), StringUtil.isNotBlank(schema) ? schema : dbMeta.getUserName(), table.getName(), null);
|
||||||
}else if ("com.zaxxer.hikari.pool.HikariProxyConnection".equals(conn.getClass().getName())){
|
} else if ("com.zaxxer.hikari.pool.HikariProxyConnection".equals(conn.getClass().getName())) {
|
||||||
return forRemarks(schema,table,dbMeta,getOriginalConn(HikariProxyConnection.class,"delegate",conn));
|
return forRemarks(schema, table, dbMeta, getOriginalConn(HikariProxyConnection.class, "delegate", conn));
|
||||||
}else if ("com.alibaba.druid.pool.DruidPooledConnection".equals(conn.getClass().getName())){
|
} else if ("com.alibaba.druid.pool.DruidPooledConnection".equals(conn.getClass().getName())) {
|
||||||
return forRemarks(schema,table,dbMeta,getOriginalConn(DruidPooledConnection.class,"conn",conn));
|
return forRemarks(schema, table, dbMeta, getOriginalConn(DruidPooledConnection.class, "conn", conn));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection getOriginalConn(Class<?> clazz,String attr,Connection conn){
|
private Connection getOriginalConn(Class<?> clazz, String attr, Connection conn) {
|
||||||
Field delegate = ClassUtil.getFirstField(clazz, field -> field.getName().equals(attr));
|
Field delegate = ClassUtil.getFirstField(clazz, field -> field.getName().equals(attr));
|
||||||
try {
|
try {
|
||||||
delegate.setAccessible(true);
|
delegate.setAccessible(true);
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTableColumns(String schemaName, Table table, GlobalConfig globalConfig, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
|
public void buildTableColumns(String schemaName, Table table, GlobalConfig globalConfig, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
|
||||||
Map<String, String> columnRemarks = buildColumnRemarks(schemaName,table, dbMeta, conn);
|
Map<String, String> columnRemarks = buildColumnRemarks(schemaName, table, dbMeta, conn);
|
||||||
|
|
||||||
String sql = forBuildColumnsSql(table.getSchema(), table.getName());
|
String sql = forBuildColumnsSql(table.getSchema(), table.getName());
|
||||||
try (Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery(sql)) {
|
try (Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery(sql)) {
|
||||||
@ -58,7 +58,7 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
|
|
||||||
private Map<String, String> buildColumnRemarks(String schemaName, Table table, DatabaseMetaData dbMeta, Connection conn) {
|
private Map<String, String> buildColumnRemarks(String schemaName, Table table, DatabaseMetaData dbMeta, Connection conn) {
|
||||||
Map<String, String> columnRemarks = new HashMap<>();
|
Map<String, String> columnRemarks = new HashMap<>();
|
||||||
try (ResultSet colRs = forRemarks(schemaName,table, dbMeta, conn)) {
|
try (ResultSet colRs = forRemarks(schemaName, table, dbMeta, conn)) {
|
||||||
while (colRs.next()) {
|
while (colRs.next()) {
|
||||||
columnRemarks.put(colRs.getString("COLUMN_NAME"), colRs.getString("REMARKS"));
|
columnRemarks.put(colRs.getString("COLUMN_NAME"), colRs.getString("REMARKS"));
|
||||||
}
|
}
|
||||||
@ -99,7 +99,4 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class TableDefGenerator implements IGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public void generate(Table table, GlobalConfig globalConfig) {
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
if (!globalConfig.isTableDefGenerateEnable()){
|
if (!globalConfig.isTableDefGenerateEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.mybatisflex.codegen.test;
|
package com.mybatisflex.codegen.test;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class BaseEntity {
|
public class BaseEntity {
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
public Date getCreateTime() {
|
public Date getCreateTime() {
|
||||||
@ -12,4 +29,5 @@ public class BaseEntity {
|
|||||||
public void setCreateTime(Date createTime) {
|
public void setCreateTime(Date createTime) {
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,7 +148,7 @@ public class GeneratorTest {
|
|||||||
generator.generate();
|
generator.generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testCodeGen3() {
|
public void testCodeGen3() {
|
||||||
//配置数据源
|
//配置数据源
|
||||||
HikariDataSource dataSource = new HikariDataSource();
|
HikariDataSource dataSource = new HikariDataSource();
|
||||||
|
|||||||
@ -1,6 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.mybatisflex.codegen.test;
|
package com.mybatisflex.codegen.test;
|
||||||
|
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
||||||
public interface MyBaseMapper<T> extends BaseMapper<T> {
|
public interface MyBaseMapper<T> extends BaseMapper<T> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.mybatisflex.codegen.test;
|
package com.mybatisflex.codegen.test;
|
||||||
|
|
||||||
import com.mybatisflex.annotation.UpdateListener;
|
import com.mybatisflex.annotation.UpdateListener;
|
||||||
|
|
||||||
public class MyUpdateListener implements UpdateListener {
|
public class MyUpdateListener implements UpdateListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(Object entity) {
|
public void onUpdate(Object entity) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,9 @@
|
|||||||
package com.mybatisflex.codegen.test;
|
package com.mybatisflex.codegen.test;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
|
||||||
import com.mybatisflex.codegen.Generator;
|
import com.mybatisflex.codegen.Generator;
|
||||||
import com.mybatisflex.codegen.config.GlobalConfig;
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
import com.mybatisflex.codegen.dialect.IDialect;
|
import com.mybatisflex.codegen.dialect.IDialect;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -29,7 +27,7 @@ import java.sql.Statement;
|
|||||||
|
|
||||||
public class SqliteGeneratorTest {
|
public class SqliteGeneratorTest {
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testGenerator3() {
|
public void testGenerator3() {
|
||||||
|
|
||||||
//配置数据源
|
//配置数据源
|
||||||
@ -85,4 +83,5 @@ public class SqliteGeneratorTest {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,8 @@ package com.mybatisflex.core;
|
|||||||
*/
|
*/
|
||||||
public class FlexConsts {
|
public class FlexConsts {
|
||||||
|
|
||||||
private FlexConsts() {}
|
private FlexConsts() {
|
||||||
|
}
|
||||||
|
|
||||||
public static final String NAME = "MyBatis-Flex";
|
public static final String NAME = "MyBatis-Flex";
|
||||||
public static final String VERSION = "1.4.9";
|
public static final String VERSION = "1.4.9";
|
||||||
@ -57,4 +58,5 @@ public class FlexConsts {
|
|||||||
* 当 entity 使用逻辑删除时,1 为 entity 的删除状态
|
* 当 entity 使用逻辑删除时,1 为 entity 的删除状态
|
||||||
*/
|
*/
|
||||||
public static final int LOGIC_DELETE_DELETED = 1;
|
public static final int LOGIC_DELETE_DELETED = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -23,7 +23,10 @@ import com.mybatisflex.core.dialect.DbType;
|
|||||||
import org.apache.ibatis.session.Configuration;
|
import org.apache.ibatis.session.Configuration;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -317,6 +320,7 @@ public class FlexGlobalConfig {
|
|||||||
* 对应的是 注解 {@link com.mybatisflex.annotation.Id} 的配置
|
* 对应的是 注解 {@link com.mybatisflex.annotation.Id} 的配置
|
||||||
*/
|
*/
|
||||||
public static class KeyConfig {
|
public static class KeyConfig {
|
||||||
|
|
||||||
private KeyType keyType;
|
private KeyType keyType;
|
||||||
private String value;
|
private String value;
|
||||||
private boolean before = true;
|
private boolean before = true;
|
||||||
@ -344,6 +348,7 @@ public class FlexGlobalConfig {
|
|||||||
public void setBefore(boolean before) {
|
public void setBefore(boolean before) {
|
||||||
this.before = before;
|
this.before = before;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -399,4 +404,5 @@ public class FlexGlobalConfig {
|
|||||||
|
|
||||||
globalConfigs.put(id, config);
|
globalConfigs.put(id, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -241,4 +241,5 @@ public class MybatisFlexBootstrap {
|
|||||||
this.logImpl = logImpl;
|
this.logImpl = logImpl;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,7 +151,9 @@ public class AuditManager {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface AuditRunnable<T> {
|
public interface AuditRunnable<T> {
|
||||||
|
|
||||||
T execute() throws SQLException;
|
T execute() throws SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,10 @@ import java.lang.reflect.Proxy;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL 审计详细消息。
|
* SQL 审计详细消息。
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@ -39,6 +39,9 @@ public class ConsoleMessageCollector implements MessageCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface SqlDebugPrinter {
|
public interface SqlDebugPrinter {
|
||||||
|
|
||||||
void print(String sql, Long tookTimeMillis);
|
void print(String sql, Long tookTimeMillis);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -19,5 +19,7 @@ package com.mybatisflex.core.audit;
|
|||||||
* 审计消息收集器
|
* 审计消息收集器
|
||||||
*/
|
*/
|
||||||
public interface MessageCollector {
|
public interface MessageCollector {
|
||||||
|
|
||||||
void collect(AuditMessage message);
|
void collect(AuditMessage message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@ -81,4 +81,5 @@ public class ScheduledMessageCollector implements MessageCollector, Runnable {
|
|||||||
run(); //clear the messages
|
run(); //clear the messages
|
||||||
scheduler.shutdown();
|
scheduler.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -41,7 +41,9 @@ public class HttpMessageReporter implements MessageReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface JSONFormatter {
|
public interface JSONFormatter {
|
||||||
|
|
||||||
String toJSONString(Object object);
|
String toJSONString(Object object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,8 @@ import java.util.Map.Entry;
|
|||||||
*/
|
*/
|
||||||
public class HttpUtil {
|
public class HttpUtil {
|
||||||
|
|
||||||
private HttpUtil() {}
|
private HttpUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final String POST = "POST";
|
private static final String POST = "POST";
|
||||||
|
|
||||||
@ -74,16 +75,19 @@ public class HttpUtil {
|
|||||||
* https 域名校验
|
* https 域名校验
|
||||||
*/
|
*/
|
||||||
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
|
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https 证书管理
|
* https 证书管理
|
||||||
*/
|
*/
|
||||||
private static class TrustAnyTrustManager implements X509TrustManager {
|
private static class TrustAnyTrustManager implements X509TrustManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
return null;
|
return null;
|
||||||
@ -96,6 +100,7 @@ public class HttpUtil {
|
|||||||
@Override
|
@Override
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -58,7 +58,6 @@ public abstract class AbstractDataSource implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||||
@ -75,7 +74,6 @@ public abstract class AbstractDataSource implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logger getParentLogger() {
|
public Logger getParentLogger() {
|
||||||
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
|
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -138,4 +138,5 @@ public class DataSourceBuilder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,8 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public class DataSourceKey {
|
public class DataSourceKey {
|
||||||
|
|
||||||
private DataSourceKey() {}
|
private DataSourceKey() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final ThreadLocal<String> keyThreadLocal = new ThreadLocal<>();
|
private static final ThreadLocal<String> keyThreadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -188,6 +188,7 @@ public class FlexDataSource extends AbstractDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ConnectionHandler implements InvocationHandler {
|
private static class ConnectionHandler implements InvocationHandler {
|
||||||
|
|
||||||
private static final String[] proxyMethods = new String[]{"commit", "rollback", "close", "setAutoCommit"};
|
private static final String[] proxyMethods = new String[]{"commit", "rollback", "close", "setAutoCommit"};
|
||||||
private final Connection original;
|
private final Connection original;
|
||||||
private final String xid;
|
private final String xid;
|
||||||
@ -219,6 +220,7 @@ public class FlexDataSource extends AbstractDataSource {
|
|||||||
private boolean isTransactional() {
|
private boolean isTransactional() {
|
||||||
return Objects.equals(xid, TransactionContext.getXID());
|
return Objects.equals(xid, TransactionContext.getXID());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,7 @@ public class DbTypeUtil {
|
|||||||
return DbType.TDENGINE;
|
return DbType.TDENGINE;
|
||||||
} else if (jdbcUrl.contains(":informix")) {
|
} else if (jdbcUrl.contains(":informix")) {
|
||||||
return DbType.INFORMIX;
|
return DbType.INFORMIX;
|
||||||
}else if (jdbcUrl.contains(":sinodb")) {
|
} else if (jdbcUrl.contains(":sinodb")) {
|
||||||
return DbType.SINODB;
|
return DbType.SINODB;
|
||||||
} else if (jdbcUrl.contains(":uxdb:")) {
|
} else if (jdbcUrl.contains(":uxdb:")) {
|
||||||
return DbType.UXDB;
|
return DbType.UXDB;
|
||||||
@ -180,4 +180,5 @@ public class DbTypeUtil {
|
|||||||
}
|
}
|
||||||
return Pattern.compile(regex).matcher(jdbcUrl).find();
|
return Pattern.compile(regex).matcher(jdbcUrl).find();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class DialectFactory {
|
public class DialectFactory {
|
||||||
|
|
||||||
private DialectFactory() {}
|
private DialectFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库类型和方言的映射关系,可以通过其读取指定的方言,亦可能通过其扩展其他方言
|
* 数据库类型和方言的映射关系,可以通过其读取指定的方言,亦可能通过其扩展其他方言
|
||||||
@ -146,4 +147,5 @@ public class DialectFactory {
|
|||||||
return new CommonsDialectImpl();
|
return new CommonsDialectImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.core.dialect;
|
package com.mybatisflex.core.dialect;
|
||||||
|
|
||||||
import com.mybatisflex.core.query.*;
|
import com.mybatisflex.core.query.CPI;
|
||||||
|
import com.mybatisflex.core.query.QueryOrderBy;
|
||||||
|
import com.mybatisflex.core.query.QueryTable;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.util.CollectionUtil;
|
import com.mybatisflex.core.util.CollectionUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -178,4 +178,5 @@ public class OracleDialect extends CommonsDialectImpl {
|
|||||||
|
|
||||||
return sql.append(INSERT_ALL_END).toString();
|
return sql.append(INSERT_ALL_END).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -97,4 +97,5 @@ public final class FlexExceptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -39,4 +39,5 @@ public class FieldQuery implements Serializable {
|
|||||||
public void setQueryWrapper(QueryWrapper queryWrapper) {
|
public void setQueryWrapper(QueryWrapper queryWrapper) {
|
||||||
this.queryWrapper = queryWrapper;
|
this.queryWrapper = queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -29,16 +29,16 @@ public class FieldQueryBuilder<T> implements Serializable {
|
|||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldQueryBuilder<T> field(String field){
|
public FieldQueryBuilder<T> field(String field) {
|
||||||
fieldQuery.setField(field);
|
fieldQuery.setField(field);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldQueryBuilder<T> field(LambdaGetter<T> fn){
|
public FieldQueryBuilder<T> field(LambdaGetter<T> fn) {
|
||||||
return field(LambdaUtil.getFieldName(fn));
|
return field(LambdaUtil.getFieldName(fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldQueryBuilder<T> queryWrapper(QueryBuilder<T> fun){
|
public FieldQueryBuilder<T> queryWrapper(QueryBuilder<T> fun) {
|
||||||
fieldQuery.setQueryWrapper(fun.build(entity));
|
fieldQuery.setQueryWrapper(fun.build(entity));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -46,4 +46,5 @@ public class FieldQueryBuilder<T> implements Serializable {
|
|||||||
public FieldQuery build() {
|
public FieldQuery build() {
|
||||||
return fieldQuery;
|
return fieldQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -18,5 +18,7 @@ package com.mybatisflex.core.field;
|
|||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
|
||||||
public interface QueryBuilder<T> {
|
public interface QueryBuilder<T> {
|
||||||
|
|
||||||
QueryWrapper build(T entity);
|
QueryWrapper build(T entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -52,4 +52,5 @@ public abstract class BaseJsonTypeHandler<T> extends BaseTypeHandler<T> {
|
|||||||
protected abstract T parseJson(String json);
|
protected abstract T parseJson(String json);
|
||||||
|
|
||||||
protected abstract String toJson(T object);
|
protected abstract String toJson(T object);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -60,4 +60,5 @@ public class CompositeEnumTypeHandler<E extends Enum<E>> implements TypeHandler<
|
|||||||
public E getResult(CallableStatement cs, int columnIndex) throws SQLException {
|
public E getResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||||
return delegate.getResult(cs, columnIndex);
|
return delegate.getResult(cs, columnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -39,4 +39,5 @@ public class Fastjson2TypeHandler extends BaseJsonTypeHandler<Object> {
|
|||||||
, JSONWriter.Feature.WriteNullStringAsEmpty
|
, JSONWriter.Feature.WriteNullStringAsEmpty
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -36,4 +36,5 @@ public class FastjsonTypeHandler extends BaseJsonTypeHandler<Object> {
|
|||||||
return JSON.toJSONString(object, SerializerFeature.WriteMapNullValue,
|
return JSON.toJSONString(object, SerializerFeature.WriteMapNullValue,
|
||||||
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty);
|
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -47,4 +47,5 @@ public class GsonTypeHandler extends BaseJsonTypeHandler<Object> {
|
|||||||
public static void setGson(Gson gson) {
|
public static void setGson(Gson gson) {
|
||||||
GsonTypeHandler.gson = gson;
|
GsonTypeHandler.gson = gson;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -58,4 +58,5 @@ public class JacksonTypeHandler extends BaseJsonTypeHandler<Object> {
|
|||||||
public static void setObjectMapper(ObjectMapper objectMapper) {
|
public static void setObjectMapper(ObjectMapper objectMapper) {
|
||||||
JacksonTypeHandler.objectMapper = objectMapper;
|
JacksonTypeHandler.objectMapper = objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -73,10 +73,10 @@ public class CustomKeyGenerator implements KeyGenerator {
|
|||||||
MetaObject metaParam = configuration.newMetaObject(parameter);
|
MetaObject metaParam = configuration.newMetaObject(parameter);
|
||||||
Object generateId = keyGenerator.generate(entity, idInfo.getColumn());
|
Object generateId = keyGenerator.generate(entity, idInfo.getColumn());
|
||||||
try {
|
try {
|
||||||
MetaObject metaObjectForProperty= metaParam.metaObjectForProperty(FlexConsts.ENTITY);
|
MetaObject metaObjectForProperty = metaParam.metaObjectForProperty(FlexConsts.ENTITY);
|
||||||
Invoker setInvoker = tableInfo.getReflector().getSetInvoker(idInfo.getProperty());
|
Invoker setInvoker = tableInfo.getReflector().getSetInvoker(idInfo.getProperty());
|
||||||
Object id = ConvertUtil.convert(generateId, setInvoker.getType());
|
Object id = ConvertUtil.convert(generateId, setInvoker.getType());
|
||||||
this.setValue(metaObjectForProperty,this.idInfo.getProperty(),id);
|
this.setValue(metaObjectForProperty, this.idInfo.getProperty(), id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
@ -95,4 +95,5 @@ public class CustomKeyGenerator implements KeyGenerator {
|
|||||||
metaParam.setValue(property, value);
|
metaParam.setValue(property, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -30,4 +30,5 @@ public interface IMultiKeyGenerator {
|
|||||||
* @return 列名数组
|
* @return 列名数组
|
||||||
*/
|
*/
|
||||||
String[] getKeyColumnNames();
|
String[] getKeyColumnNames();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class KeyGeneratorFactory {
|
public class KeyGeneratorFactory {
|
||||||
|
|
||||||
private KeyGeneratorFactory() {}
|
private KeyGeneratorFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, IKeyGenerator> KEY_GENERATOR_MAP = new HashMap<>();
|
private static final Map<String, IKeyGenerator> KEY_GENERATOR_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,8 @@ package com.mybatisflex.core.keygen;
|
|||||||
|
|
||||||
public class KeyGenerators {
|
public class KeyGenerators {
|
||||||
|
|
||||||
private KeyGenerators() {}
|
private KeyGenerators() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uuid 主键生成器
|
* uuid 主键生成器
|
||||||
@ -36,4 +37,5 @@ public class KeyGenerators {
|
|||||||
* {@link com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator}
|
* {@link com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator}
|
||||||
*/
|
*/
|
||||||
public static final String snowFlakeId = "snowFlakeId";
|
public static final String snowFlakeId = "snowFlakeId";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -54,4 +54,5 @@ public class MultiEntityKeyGenerator implements KeyGenerator {
|
|||||||
// 多条数据批量插入的场景下,不支持后设置主键
|
// 多条数据批量插入的场景下,不支持后设置主键
|
||||||
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
|
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -55,4 +55,5 @@ public class MultiRowKeyGenerator implements KeyGenerator {
|
|||||||
// 多条数据批量插入的场景下,不支持后设置主键
|
// 多条数据批量插入的场景下,不支持后设置主键
|
||||||
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
|
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MybatisKeyGeneratorUtil {
|
public class MybatisKeyGeneratorUtil {
|
||||||
|
|
||||||
private MybatisKeyGeneratorUtil() {}
|
private MybatisKeyGeneratorUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
public static KeyGenerator createTableKeyGenerator(TableInfo tableInfo, MappedStatement ms) {
|
public static KeyGenerator createTableKeyGenerator(TableInfo tableInfo, MappedStatement ms) {
|
||||||
List<IdInfo> primaryKeyList = tableInfo.getPrimaryKeyList();
|
List<IdInfo> primaryKeyList = tableInfo.getPrimaryKeyList();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -68,4 +68,5 @@ public class RowCustomKeyGenerator implements KeyGenerator {
|
|||||||
public void processAfter(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
|
public void processAfter(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -219,6 +219,7 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class KeyAssigner {
|
private class KeyAssigner {
|
||||||
|
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
private final ResultSetMetaData rsmd;
|
private final ResultSetMetaData rsmd;
|
||||||
private final TypeHandlerRegistry typeHandlerRegistry;
|
private final TypeHandlerRegistry typeHandlerRegistry;
|
||||||
@ -266,5 +267,7 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
|
|||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import java.util.Map;
|
|||||||
* 为 row 的主键生成器
|
* 为 row 的主键生成器
|
||||||
*/
|
*/
|
||||||
public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
||||||
|
|
||||||
private static final KeyGenerator[] NO_KEY_GENERATORS = new KeyGenerator[0];
|
private static final KeyGenerator[] NO_KEY_GENERATORS = new KeyGenerator[0];
|
||||||
|
|
||||||
private final MappedStatement ms;
|
private final MappedStatement ms;
|
||||||
@ -153,4 +154,5 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
|||||||
public String[] getKeyColumnNames() {
|
public String[] getKeyColumnNames() {
|
||||||
return autoKeyGeneratorNames.toArray(new String[0]);
|
return autoKeyGeneratorNames.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -25,4 +25,5 @@ public class UUIDKeyGenerator implements IKeyGenerator {
|
|||||||
public Object generate(Object entity, String keyColumn) {
|
public Object generate(Object entity, String keyColumn) {
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public interface LogicDeleteProcessor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户构建查询正常数据的条件。
|
* 用户构建查询正常数据的条件。
|
||||||
|
*
|
||||||
* @param logicColumn 逻辑删除列
|
* @param logicColumn 逻辑删除列
|
||||||
* @param tableInfo
|
* @param tableInfo
|
||||||
* @param dialect 数据库方言
|
* @param dialect 数据库方言
|
||||||
@ -34,6 +35,7 @@ public interface LogicDeleteProcessor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户与构建删除数据时的内容。
|
* 用户与构建删除数据时的内容。
|
||||||
|
*
|
||||||
* @param logicColumn 逻辑删除列
|
* @param logicColumn 逻辑删除列
|
||||||
* @param tableInfo
|
* @param tableInfo
|
||||||
* @param dialect 数据库方言
|
* @param dialect 数据库方言
|
||||||
|
|||||||
@ -24,7 +24,8 @@ import java.util.function.Supplier;
|
|||||||
*/
|
*/
|
||||||
public class MaskManager {
|
public class MaskManager {
|
||||||
|
|
||||||
private MaskManager() {}
|
private MaskManager() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脱敏处理器,type : processor
|
* 脱敏处理器,type : processor
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -21,4 +21,5 @@ package com.mybatisflex.core.mask;
|
|||||||
public interface MaskProcessor {
|
public interface MaskProcessor {
|
||||||
|
|
||||||
Object mask(Object data);
|
Object mask(Object data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -33,25 +33,26 @@ public class MaskTypeHandler extends BaseTypeHandler<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
|
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
|
||||||
ps.setString(i,parameter.toString());
|
ps.setString(i, parameter.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||||
String data = rs.getString(columnName);
|
String data = rs.getString(columnName);
|
||||||
return MaskManager.mask(maskType,data);
|
return MaskManager.mask(maskType, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||||
String data = rs.getString(columnIndex);
|
String data = rs.getString(columnIndex);
|
||||||
return MaskManager.mask(maskType,data);
|
return MaskManager.mask(maskType, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||||
String data = cs.getString(columnIndex);
|
String data = cs.getString(columnIndex);
|
||||||
return MaskManager.mask(maskType,data);
|
return MaskManager.mask(maskType, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,8 @@ package com.mybatisflex.core.mask;
|
|||||||
*/
|
*/
|
||||||
public class Masks {
|
public class Masks {
|
||||||
|
|
||||||
private Masks() {}
|
private Masks() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号脱敏
|
* 手机号脱敏
|
||||||
@ -183,8 +184,8 @@ public class Masks {
|
|||||||
* 密码 脱敏
|
* 密码 脱敏
|
||||||
*/
|
*/
|
||||||
static MaskProcessor PASSWORD_PROCESSOR = data -> {
|
static MaskProcessor PASSWORD_PROCESSOR = data -> {
|
||||||
if (data instanceof String ) {
|
if (data instanceof String) {
|
||||||
return mask((String) data, 0, 0, ((String) data).length()) ;
|
return mask((String) data, 0, 0, ((String) data).length());
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -341,4 +341,5 @@ public class FlexConfiguration extends Configuration {
|
|||||||
, new MapperInvocationHandler(mapper, this));
|
, new MapperInvocationHandler(mapper, this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,5 +87,7 @@ public class FlexResultSetHandler extends DefaultResultSetHandler {
|
|||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return originalCursor.iterator();
|
return originalCursor.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
@ -17,19 +17,20 @@ package com.mybatisflex.core.mybatis;
|
|||||||
|
|
||||||
public class MappedStatementTypes {
|
public class MappedStatementTypes {
|
||||||
|
|
||||||
private MappedStatementTypes() {}
|
private MappedStatementTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
private static ThreadLocal<Class<?>> currentTypeTL = new ThreadLocal<>();
|
private static ThreadLocal<Class<?>> currentTypeTL = new ThreadLocal<>();
|
||||||
|
|
||||||
public static void setCurrentType(Class<?> type){
|
public static void setCurrentType(Class<?> type) {
|
||||||
currentTypeTL.set(type);
|
currentTypeTL.set(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getCurrentType(){
|
public static Class<?> getCurrentType() {
|
||||||
return currentTypeTL.get();
|
return currentTypeTL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(){
|
public static void clear() {
|
||||||
currentTypeTL.remove();
|
currentTypeTL.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -90,4 +90,5 @@ public class SqlArgsParameterHandler extends DefaultParameterHandler {
|
|||||||
ps.setTimestamp(index, new java.sql.Timestamp(value.getTime()));
|
ps.setTimestamp(index, new java.sql.Timestamp(value.getTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -37,4 +37,5 @@ public class TypeHandlerObject implements Serializable {
|
|||||||
public void setParameter(PreparedStatement ps, int i) throws SQLException {
|
public void setParameter(PreparedStatement ps, int i) throws SQLException {
|
||||||
typeHandler.setParameter(ps, i, value, jdbcType);
|
typeHandler.setParameter(ps, i, value, jdbcType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -23,10 +23,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface CacheKeyBuilder {
|
public interface CacheKeyBuilder {
|
||||||
|
|
||||||
default CacheKey buildCacheKey(CacheKey cacheKey, Object parameterObject){
|
default CacheKey buildCacheKey(CacheKey cacheKey, Object parameterObject) {
|
||||||
if (parameterObject instanceof Map && ((Map) parameterObject).containsKey(FlexConsts.SQL_ARGS)){
|
if (parameterObject instanceof Map && ((Map) parameterObject).containsKey(FlexConsts.SQL_ARGS)) {
|
||||||
cacheKey.update(Arrays.toString((Object[]) ((Map<?, ?>) parameterObject).get(FlexConsts.SQL_ARGS)));
|
cacheKey.update(Arrays.toString((Object[]) ((Map<?, ?>) parameterObject).get(FlexConsts.SQL_ARGS)));
|
||||||
}
|
}
|
||||||
return cacheKey;
|
return cacheKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -143,4 +143,5 @@ public class FlexBatchExecutor extends BatchExecutor implements CacheKeyBuilder
|
|||||||
batchResultList.clear();
|
batchResultList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -31,6 +31,7 @@ public class FlexReuseExecutor extends ReuseExecutor implements CacheKeyBuilder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
|
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
|
||||||
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql),parameterObject);
|
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql), parameterObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -31,6 +31,7 @@ public class FlexSimpleExecutor extends SimpleExecutor implements CacheKeyBuilde
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
|
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
|
||||||
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql),parameterObject);
|
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql), parameterObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,6 @@ public class Page<T> implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前页的数据。
|
* 获取当前页的数据。
|
||||||
*
|
*
|
||||||
@ -277,4 +276,5 @@ public class Page<T> implements Serializable {
|
|||||||
", records=" + records +
|
", records=" + records +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,5 +147,7 @@ public class ArithmeticQueryColumn extends QueryColumn {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,8 +127,8 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
|
|||||||
joinTables.add(queryTable);
|
joinTables.add(queryTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addEndFragment(String fragment){
|
protected void addEndFragment(String fragment) {
|
||||||
if (endFragments == null){
|
if (endFragments == null) {
|
||||||
endFragments = new ArrayList<>();
|
endFragments = new ArrayList<>();
|
||||||
}
|
}
|
||||||
endFragments.add(fragment);
|
endFragments.add(fragment);
|
||||||
@ -251,14 +251,14 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putContext(String key, Object value){
|
protected void putContext(String key, Object value) {
|
||||||
if (context == null){
|
if (context == null) {
|
||||||
context = new HashMap<>();
|
context = new HashMap<>();
|
||||||
}
|
}
|
||||||
context.put(key,value);
|
context.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <R> R getContext(String key){
|
protected <R> R getContext(String key) {
|
||||||
return context == null ? null : (R) context.get(key);
|
return context == null ? null : (R) context.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,11 +278,11 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
|
|||||||
clone.orderBys = CollectionUtil.cloneArrayList(this.orderBys);
|
clone.orderBys = CollectionUtil.cloneArrayList(this.orderBys);
|
||||||
clone.unions = CollectionUtil.cloneArrayList(this.unions);
|
clone.unions = CollectionUtil.cloneArrayList(this.unions);
|
||||||
// copy List if necessary ...
|
// copy List if necessary ...
|
||||||
if (this.endFragments != null){
|
if (this.endFragments != null) {
|
||||||
clone.endFragments = CollectionUtil.newArrayList(this.endFragments);
|
clone.endFragments = CollectionUtil.newArrayList(this.endFragments);
|
||||||
}
|
}
|
||||||
// copy Map if necessary ...
|
// copy Map if necessary ...
|
||||||
if (this.context != null){
|
if (this.context != null) {
|
||||||
clone.context = CollectionUtil.newHashMap(this.context);
|
clone.context = CollectionUtil.newHashMap(this.context);
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
@ -290,4 +290,5 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -123,4 +123,5 @@ public class Brackets extends QueryCondition {
|
|||||||
clone.childCondition = ObjectUtil.clone(this.childCondition);
|
clone.childCondition = ObjectUtil.clone(this.childCondition);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,6 @@ public class CPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static With getWith(QueryWrapper queryWrapper) {
|
public static With getWith(QueryWrapper queryWrapper) {
|
||||||
return queryWrapper.with;
|
return queryWrapper.with;
|
||||||
}
|
}
|
||||||
@ -235,4 +234,5 @@ public class CPI {
|
|||||||
public static boolean isSameTable(QueryTable queryTable, QueryTable otherTable) {
|
public static boolean isSameTable(QueryTable queryTable, QueryTable otherTable) {
|
||||||
return queryTable.isSameTable(otherTable);
|
return queryTable.isSameTable(otherTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,6 +91,7 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
|
|||||||
|
|
||||||
|
|
||||||
public static class When implements CloneSupport<When> {
|
public static class When implements CloneSupport<When> {
|
||||||
|
|
||||||
private QueryCondition whenCondition;
|
private QueryCondition whenCondition;
|
||||||
private Object thenValue;
|
private Object thenValue;
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
@ -148,6 +150,9 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
|
|||||||
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
|
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,6 +91,7 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
|
|||||||
|
|
||||||
|
|
||||||
public static class When implements CloneSupport<When> {
|
public static class When implements CloneSupport<When> {
|
||||||
|
|
||||||
private Object searchValue;
|
private Object searchValue;
|
||||||
private Object thenValue;
|
private Object thenValue;
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,6 +155,9 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
|
|||||||
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
|
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,4 +61,5 @@ public class DistinctQueryColumn extends QueryColumn {
|
|||||||
clone.queryColumns = CollectionUtil.cloneArrayList(this.queryColumns);
|
clone.queryColumns = CollectionUtil.cloneArrayList(this.queryColumns);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,6 @@ public class FunctionQueryColumn extends QueryColumn implements HasParamsColumn
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FunctionQueryColumn{" +
|
return "FunctionQueryColumn{" +
|
||||||
|
|||||||
@ -1,6 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.mybatisflex.core.query;
|
package com.mybatisflex.core.query;
|
||||||
|
|
||||||
public interface HasParamsColumn {
|
public interface HasParamsColumn {
|
||||||
|
|
||||||
Object[] getParamValues();
|
Object[] getParamValues();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,4 +100,5 @@ public class Join implements CloneSupport<Join> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -52,5 +52,6 @@ public class Joiner<M> {
|
|||||||
join.on(newWrapper.whereQueryCondition);
|
join.on(newWrapper.whereQueryCondition);
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,4 +82,5 @@ public class OperatorQueryCondition extends QueryCondition {
|
|||||||
clone.childCondition = ObjectUtil.clone(this.childCondition);
|
clone.childCondition = ObjectUtil.clone(this.childCondition);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import java.util.List;
|
|||||||
* 示例2:and not EXISTS (select ... from ... where ....)
|
* 示例2:and not EXISTS (select ... from ... where ....)
|
||||||
*/
|
*/
|
||||||
public class OperatorSelectCondition extends QueryCondition {
|
public class OperatorSelectCondition extends QueryCondition {
|
||||||
|
|
||||||
//操作符,例如 exist, not exist
|
//操作符,例如 exist, not exist
|
||||||
private final String operator;
|
private final String operator;
|
||||||
private QueryWrapper queryWrapper;
|
private QueryWrapper queryWrapper;
|
||||||
@ -82,4 +83,5 @@ public class OperatorSelectCondition extends QueryCondition {
|
|||||||
clone.queryWrapper = ObjectUtil.clone(this.queryWrapper);
|
clone.queryWrapper = ObjectUtil.clone(this.queryWrapper);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -589,4 +589,5 @@ public class QueryColumn implements CloneSupport<QueryColumn> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -302,4 +302,5 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,4 +84,5 @@ public class QueryOrderBy implements CloneSupport<QueryOrderBy> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,4 +126,5 @@ public class QueryTable implements CloneSupport<QueryTable> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -731,4 +731,5 @@ public class QueryWrapper extends BaseQueryWrapper<QueryWrapper> {
|
|||||||
public QueryWrapper clone() {
|
public QueryWrapper clone() {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,4 +68,5 @@ public class RawFragment extends QueryCondition {
|
|||||||
public String getContent() {
|
public String getContent() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,4 +60,5 @@ public class SelectQueryColumn extends QueryColumn implements HasParamsColumn {
|
|||||||
public Object[] getParamValues() {
|
public Object[] getParamValues() {
|
||||||
return queryWrapper.getValueArray();
|
return queryWrapper.getValueArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,4 +62,5 @@ public class SelectQueryTable extends QueryTable {
|
|||||||
clone.queryWrapper = this.queryWrapper.clone();
|
clone.queryWrapper = this.queryWrapper.clone();
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -19,7 +19,7 @@ public enum SqlConnector {
|
|||||||
|
|
||||||
|
|
||||||
AND(" AND "),
|
AND(" AND "),
|
||||||
// AND_NOT(" AND NOT "),
|
// AND_NOT(" AND NOT "),
|
||||||
// AND_EXISTS(" AND EXISTS "),
|
// AND_EXISTS(" AND EXISTS "),
|
||||||
// AND_NOT_EXISTS(" AND NOT EXISTS "),
|
// AND_NOT_EXISTS(" AND NOT EXISTS "),
|
||||||
OR(" OR "),
|
OR(" OR "),
|
||||||
|
|||||||
@ -93,4 +93,5 @@ public class StringFunctionQueryColumn extends QueryColumn {
|
|||||||
clone.params = CollectionUtil.newArrayList(this.params);
|
clone.params = CollectionUtil.newArrayList(this.params);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,4 +53,5 @@ public class StringQueryColumn extends QueryColumn {
|
|||||||
public StringQueryColumn clone() {
|
public StringQueryColumn clone() {
|
||||||
return (StringQueryColumn) super.clone();
|
return (StringQueryColumn) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,4 +42,5 @@ public class StringQueryOrderBy extends QueryOrderBy {
|
|||||||
public StringQueryOrderBy clone() {
|
public StringQueryOrderBy clone() {
|
||||||
return (StringQueryOrderBy) super.clone();
|
return (StringQueryOrderBy) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,4 +77,5 @@ public class UnionWrapper implements CloneSupport<UnionWrapper> {
|
|||||||
throw FlexExceptions.wrap(e);
|
throw FlexExceptions.wrap(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,9 @@ package com.mybatisflex.core.query;
|
|||||||
|
|
||||||
import com.mybatisflex.core.util.CollectionUtil;
|
import com.mybatisflex.core.util.CollectionUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WithBuilder {
|
public class WithBuilder {
|
||||||
|
|
||||||
|
|||||||
@ -22,4 +22,5 @@ public interface WithDetail extends CloneSupport<WithDetail> {
|
|||||||
String toSql(IDialect dialect);
|
String toSql(IDialect dialect);
|
||||||
|
|
||||||
Object[] getParamValues();
|
Object[] getParamValues();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class WithItem implements CloneSupport<WithItem> {
|
|||||||
|
|
||||||
public String toSql(IDialect dialect) {
|
public String toSql(IDialect dialect) {
|
||||||
StringBuilder sql = new StringBuilder(name);
|
StringBuilder sql = new StringBuilder(name);
|
||||||
if (CollectionUtil.isNotEmpty(params)){
|
if (CollectionUtil.isNotEmpty(params)) {
|
||||||
sql.append(BRACKET_LEFT).append(StringUtil.join(DELIMITER, params)).append(BRACKET_RIGHT);
|
sql.append(BRACKET_LEFT).append(StringUtil.join(DELIMITER, params)).append(BRACKET_RIGHT);
|
||||||
}
|
}
|
||||||
sql.append(AS).append(BRACKET_LEFT);
|
sql.append(AS).append(BRACKET_LEFT);
|
||||||
|
|||||||
@ -33,7 +33,8 @@ import java.util.List;
|
|||||||
|
|
||||||
class WrapperUtil {
|
class WrapperUtil {
|
||||||
|
|
||||||
private WrapperUtil() {}
|
private WrapperUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
static List<QueryWrapper> getChildQueryWrapper(QueryCondition condition) {
|
static List<QueryWrapper> getChildQueryWrapper(QueryCondition condition) {
|
||||||
List<QueryWrapper> list = null;
|
List<QueryWrapper> list = null;
|
||||||
@ -154,7 +155,8 @@ class WrapperUtil {
|
|||||||
return StringUtil.isBlank(alias) ? SqlConsts.EMPTY : getAsKeyWord(dialect) + dialect.wrap(alias);
|
return StringUtil.isBlank(alias) ? SqlConsts.EMPTY : getAsKeyWord(dialect) + dialect.wrap(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAsKeyWord(IDialect dialect){
|
private static String getAsKeyWord(IDialect dialect) {
|
||||||
return dialect instanceof OracleDialect ? SqlConsts.BLANK : SqlConsts.AS;
|
return dialect instanceof OracleDialect ? SqlConsts.BLANK : SqlConsts.AS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ abstract class AbstractRelation<SelfEntity> {
|
|||||||
String dataSource, Class<SelfEntity> entityClass, Field relationField,
|
String dataSource, Class<SelfEntity> entityClass, Field relationField,
|
||||||
String extraCondition
|
String extraCondition
|
||||||
) {
|
) {
|
||||||
this.name = entityClass.getSimpleName()+"."+relationField.getName();
|
this.name = entityClass.getSimpleName() + "." + relationField.getName();
|
||||||
this.simpleName = relationField.getName();
|
this.simpleName = relationField.getName();
|
||||||
this.selfEntityClass = entityClass;
|
this.selfEntityClass = entityClass;
|
||||||
this.relationField = relationField;
|
this.relationField = relationField;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user