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.
61 lines
1.7 KiB
61 lines
1.7 KiB
7 months ago
|
package Tools.MaxKb;
|
||
|
|
||
|
import Tools.MaxKb.Util.MaxKbDb;
|
||
|
import com.dsideal.QingLong.Util.CommonUtil;
|
||
|
import com.jfinal.kit.PropKit;
|
||
|
import com.jfinal.plugin.activerecord.Db;
|
||
|
import com.jfinal.plugin.activerecord.Record;
|
||
|
import org.joda.time.DateTime;
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
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 applicationName = "黄海的一个应用";
|
||
|
record = getApplication(applicationName);
|
||
|
//克隆出对象
|
||
|
record = new Record().setColumns(record.getColumns());
|
||
|
//生成一个uuid
|
||
|
record.set("id", UUID.randomUUID());
|
||
|
//名称
|
||
|
record.set("name", "XXX的拷贝应用");
|
||
|
//增加
|
||
|
Db.save("application", "id", record);
|
||
|
System.out.println("增加成功!");
|
||
|
}
|
||
|
}
|