Skip to content

Commit

Permalink
feat: 支持mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
jinlong-T committed Oct 25, 2021
1 parent b260660 commit 54ef74f
Show file tree
Hide file tree
Showing 9 changed files with 1,047 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum DatasourceTypes {
sqlServer("sqlServer", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
de_doris("de_doris", "de_doris", "com.mysql.jdbc.Driver", "`", "`", "", ""),
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
mongo("mongo", "mongodb", "com.mongodb.jdbc.MongoDriver", "`", "`", "'", "'"),
mongo("mongo", "mongodb", "com.mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
ck("ch", "ch", "ru.yandex.clickhouse.ClickHouseDriver", "`", "`", "'", "'"),
es("es", "es", "", "\"", "\"", "\"", "\"");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
import io.dataease.i18n.Translator;
import io.dataease.provider.QueryProvider;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.IOException;
Expand All @@ -29,9 +26,6 @@ public class JdbcProvider extends DatasourceProvider {
public ExtendedJdbcClassLoader extendedJdbcClassLoader;
static private String FILE_PATH = "/opt/dataease/drivers";

// @Resource
// private WallFilter wallFilter;

@PostConstruct
public void init() throws Exception{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public static QueryProvider getQueryProvider(String type) {
return context.getBean("esQuery", QueryProvider.class);
case ck:
return context.getBean("ckQuery", QueryProvider.class);
case mongo:
return context.getBean("mongoQuery", QueryProvider.class);
default:
return context.getBean("mysqlQuery", QueryProvider.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.dataease.provider.mongodb;

import io.dataease.provider.SQLConstants;

import static io.dataease.datasource.constants.DatasourceTypes.mongo;
import static io.dataease.datasource.constants.DatasourceTypes.oracle;

/**
* @Author gin
* @Date 2021/7/8 7:22 下午
*/
public class MongoConstants extends SQLConstants {
public static final String KEYWORD_TABLE = "%s";

public static final String KEYWORD_FIX = "%s." + mongo.getKeywordPrefix() + "%s" + mongo.getKeywordSuffix();

public static final String ALIAS_FIX = mongo.getAliasPrefix() + "%s" + oracle.getAliasSuffix();

public static final String toInt32 = "toInt32(%s)";

public static final String toDateTime = "toDateTime(%s)";

public static final String toInt64 = "toInt64(%s)";

public static final String toFloat64 = "toFloat64(%s)";

public static final String formatDateTime = "formatDateTime(%s,'%s')";

public static final String toDecimal = "toDecimal64(%s,2)";

public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%M:%S";

public static final String WHERE_VALUE_NULL = "(NULL,'')";

public static final String WHERE_VALUE_VALUE = "'%s'";

public static final String AGG_COUNT = "COUNT(*)";

public static final String AGG_FIELD = "%s(%s)";

public static final String WHERE_BETWEEN = "'%s' AND '%s'";

public static final String BRACKETS = "(%s)";
}
Loading

0 comments on commit 54ef74f

Please sign in to comment.