初始化
This commit is contained in:
16
src/main/java/com/yuandian/common/App.java
Normal file
16
src/main/java/com/yuandian/common/App.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.yuandian.common;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
log.info("Hello Yuandian!");
|
||||
}
|
||||
}
|
||||
87
src/main/java/com/yuandian/common/Database.java
Normal file
87
src/main/java/com/yuandian/common/Database.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* description
|
||||
*
|
||||
* @author eson
|
||||
*2022年6月29日-10:16:15
|
||||
*/
|
||||
package com.yuandian.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bson.BsonDocument;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.bson.conversions.Bson;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientURI;
|
||||
import com.mongodb.client.model.IndexOptions;
|
||||
import com.mongodb.client.model.Indexes;
|
||||
|
||||
import lombok.var;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* description
|
||||
*
|
||||
* @author eson
|
||||
*2022年6月29日-10:16:15
|
||||
*/
|
||||
@Slf4j
|
||||
public class Database {
|
||||
|
||||
public class Origin<T> {
|
||||
T client;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Config.UseConfig("yuandian.database", (cnf) -> {
|
||||
Map<String,Object> oriConfig = cnf.get("database", "mongodb", "ori");
|
||||
String uri = (String)oriConfig.get("uri"); // 获取 uri配置
|
||||
|
||||
MongoClient client = new MongoClient(new MongoClientURI(uri));
|
||||
|
||||
var dbInfoList = (ArrayList)oriConfig.get("db_info_list"); // 获取 db_info_list 列表
|
||||
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// var cOriName = "bus_db";
|
||||
|
||||
// var db = client.getDatabase("yd-base");
|
||||
|
||||
// var busDB = db.getCollection(cOriName);
|
||||
// var cur = busDB.listIndexes().iterator();
|
||||
|
||||
|
||||
|
||||
// if(!cur.hasNext()) {
|
||||
|
||||
|
||||
// var bs = new BasicDBObject();
|
||||
// bs.js
|
||||
|
||||
// bs.append("create_at", "1");
|
||||
|
||||
// bs.append("key", mapAsJavaMap(Map(("_id", "hashed"))))
|
||||
|
||||
// busDB.createIndex(keys)
|
||||
|
||||
// db.ex("db.db_bus.createIndex({ create_at: 1 },{expireAfterSeconds: 3600})");
|
||||
// var opt = new IndexOptions().expireAfter((long) 3600, TimeUnit.SECONDS);
|
||||
// cOri.createIndex(Indexes.ascending("create_at"), opt);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// db.createCollection(cOriName);
|
||||
}
|
||||
}
|
||||
7
src/main/resources/application.properties
Normal file
7
src/main/resources/application.properties
Normal file
@@ -0,0 +1,7 @@
|
||||
# 启动端口 具体由项目而定
|
||||
# server.port=3440
|
||||
|
||||
# 测试环境的 nacos 配置地址
|
||||
yuandian.dataflow.config.nacos.server.addr=config.yuandian.local:8848
|
||||
# 测试环境的 nacos 配置地址
|
||||
yuandian.dataflow.config.nacos.server.addr-test=config.yuandian.local:8848
|
||||
44
src/main/resources/db_bus.mongodb
Normal file
44
src/main/resources/db_bus.mongodb
Normal file
@@ -0,0 +1,44 @@
|
||||
// MongoDB Playground
|
||||
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
|
||||
|
||||
const database = 'yd-base';
|
||||
const collection = 'db_bus';
|
||||
|
||||
// The current database to use.
|
||||
use(database);
|
||||
|
||||
// Create a new collection.
|
||||
// db.createCollection(collection);
|
||||
// c = db.getCollection(collation);
|
||||
db.db_bus.createIndex({ create_at: 1 },{expireAfterSeconds: 3600})
|
||||
|
||||
// The prototype form to create a regular collection:
|
||||
/* db.createCollection( <name>,
|
||||
{
|
||||
capped: <boolean>,
|
||||
autoIndexId: <boolean>,
|
||||
size: <number>,
|
||||
max: <number>,
|
||||
storageEngine: <document>,
|
||||
validator: <document>,
|
||||
validationLevel: <string>,
|
||||
validationAction: <string>,
|
||||
indexOptionDefaults: <document>,
|
||||
viewOn: <string>,
|
||||
pipeline: <pipeline>,
|
||||
collation: <document>,
|
||||
writeConcern: <document>
|
||||
}
|
||||
) */
|
||||
|
||||
// The prototype form to create a time-series collection:
|
||||
/* db.createCollection( <name>,
|
||||
{
|
||||
timeseries: {
|
||||
timeField: <string>,
|
||||
metaField: <string>,
|
||||
granularity: <string>
|
||||
},
|
||||
expireAfterSeconds: <number>
|
||||
}
|
||||
) */
|
||||
13
src/main/resources/logback.xml
Normal file
13
src/main/resources/logback.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<configuration>
|
||||
<appender name="CONSOLE"
|
||||
class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
%d{yyyyMMdd HH:mm:ss.SSS} %level %thread\(%file:%line\): %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
||||
17
src/test/java/com/yuandian/common/AppTest.java
Normal file
17
src/test/java/com/yuandian/common/AppTest.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.yuandian.common;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
public class AppTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void testApp() {
|
||||
//TODO: test 参考 http://doc.yuandian.com/pages/viewpage.action?pageId=4391012
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user