|
|
|
@ -103,9 +103,9 @@ public class MaxKbModel {
|
|
|
|
|
* @param zskName 数据集名称
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Record getZsk(String zskName) {
|
|
|
|
|
public List<Record> getZsk(String zskName) {
|
|
|
|
|
String sql = "select * from dataset where name=?";
|
|
|
|
|
return Db.use(DbConst.MAXKB).findFirst(sql, zskName);
|
|
|
|
|
return Db.use(DbConst.MAXKB).find(sql, zskName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -115,13 +115,13 @@ public class MaxKbModel {
|
|
|
|
|
*/
|
|
|
|
|
public String addZsk(String sourceZskName, String targetZskName) {
|
|
|
|
|
//获取数据集
|
|
|
|
|
Record record = getZsk(sourceZskName);
|
|
|
|
|
if (record == null) {
|
|
|
|
|
List<Record> records = getZsk(sourceZskName);
|
|
|
|
|
if (records == null) {
|
|
|
|
|
System.out.println(sourceZskName + "数据集不存在!");
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
//克隆出对象
|
|
|
|
|
record = new Record().setColumns(record.getColumns());
|
|
|
|
|
Record record = new Record().setColumns(records.getFirst().getColumns());
|
|
|
|
|
//生成一个uuid
|
|
|
|
|
record.set("id", UUID.randomUUID());
|
|
|
|
|
//名称
|
|
|
|
@ -224,13 +224,30 @@ public class MaxKbModel {
|
|
|
|
|
return Db.findFirst(sql, person_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存应用与知识库之间的关系
|
|
|
|
|
*
|
|
|
|
|
* @param applicationId 应用程序ID
|
|
|
|
|
* @param zskId 知识库ID
|
|
|
|
|
*/
|
|
|
|
|
public void saveApplicationZskId(String applicationId, String zskId) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("create_time", LocalDateTime.now());
|
|
|
|
|
record.set("update_time", LocalDateTime.now());
|
|
|
|
|
record.set("id", UUID.randomUUID());
|
|
|
|
|
record.set("application_id", UUID.fromString(applicationId));
|
|
|
|
|
record.set("dataset_id", UUID.fromString(zskId));
|
|
|
|
|
Db.use(DbConst.MAXKB).save("application_dataset_mapping", "id", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除人员应用绑定
|
|
|
|
|
*
|
|
|
|
|
* @param person_id 人员ID
|
|
|
|
|
*/
|
|
|
|
|
public void delPersonApplication(String person_id){
|
|
|
|
|
String sql="delete from t_ai_person_application where person_id=?";
|
|
|
|
|
Db.update(sql,person_id);
|
|
|
|
|
public void delPersonApplication(String person_id) {
|
|
|
|
|
String sql = "delete from t_ai_person_application where person_id=?";
|
|
|
|
|
Db.update(sql, person_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -245,4 +262,61 @@ public class MaxKbModel {
|
|
|
|
|
record.set("application_id", applicationId);
|
|
|
|
|
Db.save("t_ai_person_application", "person_id", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过名称删除应用程序
|
|
|
|
|
*
|
|
|
|
|
* @param applicationName 应用程序名称
|
|
|
|
|
*/
|
|
|
|
|
public void delApplication(String applicationName) {
|
|
|
|
|
String sql = "select * from application where name=?";
|
|
|
|
|
List<Record> list = Db.use(DbConst.MAXKB).find(sql, applicationName);
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
String application_id = record.getStr("id");
|
|
|
|
|
//删除应用与知识库的关联
|
|
|
|
|
sql = "delete from application_dataset_mapping where application_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(application_id));
|
|
|
|
|
|
|
|
|
|
sql = "delete from application_access_token where application_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(application_id));
|
|
|
|
|
|
|
|
|
|
sql = "select * from application_chat where application_id=?";
|
|
|
|
|
List<Record> list1 = Db.use(DbConst.MAXKB).find(sql, UUID.fromString(application_id));
|
|
|
|
|
for (Record record1 : list1) {
|
|
|
|
|
String chat_id = record1.getStr("id");
|
|
|
|
|
sql = "delete from application_chat_record where chat_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(chat_id));
|
|
|
|
|
}
|
|
|
|
|
sql = "delete from application_chat where application_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(application_id));
|
|
|
|
|
|
|
|
|
|
sql = "delete from application_api_key where application_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(application_id));
|
|
|
|
|
//删除应用
|
|
|
|
|
sql = "delete from application where id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(application_id));
|
|
|
|
|
}
|
|
|
|
|
sql = "delete from dataset where name=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, applicationName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 按名称删除知识库
|
|
|
|
|
*
|
|
|
|
|
* @param zskName 知识库名称
|
|
|
|
|
*/
|
|
|
|
|
public void delZsk(String zskName) {
|
|
|
|
|
List<Record> records = getZsk(zskName);
|
|
|
|
|
for (Record record : records) {
|
|
|
|
|
String zskId = record.getStr("id");
|
|
|
|
|
String sql = "delete from problem_paragraph_mapping where dataset_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(zskId));
|
|
|
|
|
sql = "delete from paragraph where dataset_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(zskId));
|
|
|
|
|
sql = "delete from document where dataset_id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(zskId));
|
|
|
|
|
sql = "delete from dataset where id=?";
|
|
|
|
|
Db.use(DbConst.MAXKB).update(sql, UUID.fromString(zskId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|