1、重构代码将数据处理全部交给 repository 来操作
2、升级支持免 Db启动提供服务
This commit is contained in:
@@ -13,8 +13,13 @@ import net.tccn.qtask.TaskKit;
|
||||
import net.tccn.user.User;
|
||||
import org.junit.Test;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.source.CacheMemorySource;
|
||||
import org.redkale.util.TypeToken;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -243,18 +248,70 @@ public class RunTest<T> {
|
||||
|
||||
List<MetaService> metaServices = MetaService.dao.find();
|
||||
|
||||
MetaKit metaKit = new MetaKit();
|
||||
|
||||
JsonConvert convert = JsonConvert.root();
|
||||
System.out.println(convert.convertTo(metaServices));
|
||||
try {
|
||||
File file = new File("tmp/metaKit.json");
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
MetaService metaService = new MetaService();
|
||||
|
||||
|
||||
/*try {
|
||||
FileKit.strToFile(gson.toJson(metaServices), file);
|
||||
FileKit.strToFile(convert.convertTo(metaKit), file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readJson() {
|
||||
File file = new File("tmp/MetaService.json");
|
||||
try {
|
||||
Type type = new TypeToken<List<MetaService>>() {
|
||||
}.getType();
|
||||
|
||||
|
||||
List<MetaService> list = convert.convertFrom(type, new FileInputStream(file));
|
||||
|
||||
System.out.println(list);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Class clazz = MetaService.class;
|
||||
|
||||
//File file = new File(String.format("tmp/%s.json", clazz.getSimpleName()));
|
||||
|
||||
/*
|
||||
写入数据到 文件
|
||||
MetaKit.cacheSave(MetaTable.class);
|
||||
MetaKit.cacheSave(MetaLink.class);
|
||||
MetaKit.cacheSave(MetaService.class);
|
||||
MetaKit.cacheSave(DbAccount.class);
|
||||
MetaKit.cacheSave(SysPlat.class);*/
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void cacheMemorySourceTest() {
|
||||
CacheMemorySource source = new CacheMemorySource();
|
||||
//MetaKit.dcate = "db";
|
||||
//MetaKit.init();
|
||||
|
||||
|
||||
List<MetaTable> list = MetaKit.getMetaTables();
|
||||
|
||||
list.forEach(x -> {
|
||||
source.set(x.getKey(), x.getClass(), x);
|
||||
});
|
||||
|
||||
MetaTable metaTable = (MetaTable) source.get(list.get(0).getKey(), MetaTable.class);
|
||||
|
||||
metaTable.setAlias("xxxxx");
|
||||
|
||||
metaTable = (MetaTable) source.get(list.get(0).getKey(), MetaTable.class);
|
||||
|
||||
System.out.println(metaTable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user