You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.5 KiB
115 lines
3.5 KiB
package Tools.MaxKb;
|
|
|
|
import Tools.MaxKb.Util.MaxKbDb;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import java.util.UUID;
|
|
|
|
public class Test {
|
|
|
|
/**
|
|
* 获取模型
|
|
*
|
|
* @param model_name 模型名称
|
|
* @return
|
|
*/
|
|
public static Record getModel(String model_name) {
|
|
String sql = "select * from model where name=?";
|
|
return Db.findFirst(sql, model_name);
|
|
}
|
|
|
|
/**
|
|
* 获取应用
|
|
*
|
|
* @param applicationName 应用名称
|
|
* @return
|
|
*/
|
|
public static Record getApplication(String applicationName) {
|
|
String sql = "select * from application where name=?";
|
|
return Db.findFirst(sql, applicationName);
|
|
}
|
|
|
|
/**
|
|
* 增加应用程序
|
|
*
|
|
* @param sourceApplicationName 源应用名称
|
|
* @param targetApplicationName 目标应用名称
|
|
*/
|
|
public static void addApplication(String sourceApplicationName, String targetApplicationName) {
|
|
//获取应用
|
|
Record record = getApplication(sourceApplicationName);
|
|
if (record == null) {
|
|
System.out.println(sourceApplicationName + "应用不存在!");
|
|
System.exit(0);
|
|
}
|
|
//克隆出对象
|
|
record = new Record().setColumns(record.getColumns());
|
|
//生成一个uuid
|
|
record.set("id", UUID.randomUUID());
|
|
//名称
|
|
record.set("name", targetApplicationName);
|
|
//增加
|
|
Db.save("application", "id", record);
|
|
}
|
|
|
|
/**
|
|
* 获取数据集
|
|
*
|
|
* @param dataset_name 数据集名称
|
|
* @return
|
|
*/
|
|
public static Record getDataSet(String dataset_name) {
|
|
String sql = "select * from dataset where name=?";
|
|
return Db.findFirst(sql, dataset_name);
|
|
}
|
|
|
|
/**
|
|
* 增加数据集
|
|
*
|
|
* @param sourceDatasetName 数据集名称
|
|
*/
|
|
public static void addDataSet(String sourceDatasetName, String targetDatasetName) {
|
|
//获取数据集
|
|
Record record = getDataSet(sourceDatasetName);
|
|
if (record == null) {
|
|
System.out.println(sourceDatasetName + "数据集不存在!");
|
|
System.exit(0);
|
|
}
|
|
//克隆出对象
|
|
record = new Record().setColumns(record.getColumns());
|
|
//生成一个uuid
|
|
record.set("id", UUID.randomUUID());
|
|
//名称
|
|
record.set("name", targetDatasetName);
|
|
record.set("desc", targetDatasetName);
|
|
//增加
|
|
Db.save("dataset", "id", record);
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
//加载配置文件
|
|
PropKit.use("MaxKb.properties");
|
|
//初始化数据库
|
|
MaxKbDb.Init();
|
|
|
|
//获取模型的id
|
|
String model_name = "DeepSeek";
|
|
Record record = getModel(model_name);
|
|
String model_id = record.getStr("id");
|
|
System.out.println(model_id);
|
|
|
|
//增加应用
|
|
String sourceApplicationName = "黄海的一个应用";
|
|
String targetApplicationName = "XXX的拷贝应用";
|
|
addApplication(sourceApplicationName, targetApplicationName);
|
|
System.out.println("增加成功!");
|
|
|
|
//每个人一个应用,每个人一个知识库
|
|
String sourceDataSetName = "长春教育知识库";
|
|
String targetDataSetName = "XXX的拷贝知识库";
|
|
addDataSet(sourceDataSetName, targetDataSetName);
|
|
}
|
|
} |