| | |
| | | db.close();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public ModelAndView addLLMFactory(SMTAIServerRequest tranReq) throws Exception {
|
| | | // 解析请求参数
|
| | | String factoryId = tranReq.convParamToString("factory_id", true);
|
| | | String factoryTitle = tranReq.convParamToString("factory_title",true);
|
| | | String factoryArgs = tranReq.convParamToString("factory_args",true);
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try {
|
| | |
|
| | | String selectSql = "SELECT * FROM ai_llm_factory WHERE factory_id = ?";
|
| | | Object[] params1 = {factoryId};
|
| | | if (db.querySQL(selectSql, params1).getRowCount()>0) {
|
| | | return tranReq.returnJsonState(false, "模型id已存在", null);
|
| | | }
|
| | | // 构建 SQL 语句
|
| | | String sql = "INSERT INTO ai_llm_factory (factory_id, factory_title, factory_args) VALUES (?, ?, ?)";
|
| | | Object[] params2 = {factoryId, factoryTitle, factoryArgs};
|
| | | // 执行插入操作
|
| | | db.executeSQL(sql, params2);
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | public ModelAndView addLLMConnect(SMTAIServerRequest tranReq) throws Exception {
|
| | | // 解析请求参数
|
| | | String connectId = tranReq.convParamToString("connect_id", true);
|
| | | String factoryId = tranReq.convParamToString("factory_id", true);
|
| | | String connectTitle = tranReq.convParamToString("connect_title", true);
|
| | | String className = tranReq.convParamToString("class_name", true);
|
| | | String connectArgs = tranReq.convParamToString("connect_args", true);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 首先检查模型id是否存在
|
| | | String selectFactorySql = "SELECT * FROM ai_llm_factory WHERE factory_id = ?";
|
| | | Object[] factoryParams = {factoryId};
|
| | | if (db.querySQL(selectFactorySql, factoryParams).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "模型id不存在", null);
|
| | | }
|
| | |
|
| | | // 检查连接id是否已存在
|
| | | String selectConnectSql = "SELECT * FROM ai_llm_connect WHERE connect_id = ?";
|
| | | Object[] connectParams = {connectId};
|
| | | if (db.querySQL(selectConnectSql, connectParams).getRowCount() > 0) {
|
| | | return tranReq.returnJsonState(false, "连接id已存在", null);
|
| | | }
|
| | |
|
| | | // 构建 SQL 语句
|
| | | String insertSql = "INSERT INTO ai_llm_connect (connect_id, factory_id, connect_title, class_name, connect_args) VALUES (?, ?, ?, ?, ?)";
|
| | | Object[] insertParams = {connectId, factoryId, connectTitle, className, connectArgs};
|
| | |
|
| | | // 执行插入操作
|
| | | db.executeSQL(insertSql, insertParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | public ModelAndView updateLLMFactory(SMTAIServerRequest tranReq) throws Exception {
|
| | | // 解析请求参数
|
| | | String factoryId = tranReq.convParamToString("factory_id", true);
|
| | | String factoryTitle = tranReq.convParamToString("factory_title", true);
|
| | | String factoryArgs = tranReq.convParamToString("factory_args", true);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查工厂 ID 是否存在
|
| | | String selectSql = "SELECT * FROM ai_llm_factory WHERE factory_id = ?";
|
| | | Object[] params = {factoryId};
|
| | | if (db.querySQL(selectSql, params).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "模型id不存在", null);
|
| | | }
|
| | |
|
| | | // 构建 SQL 语句
|
| | | String updateSql = "UPDATE ai_llm_factory SET factory_title = ?, factory_args = ? WHERE factory_id = ?";
|
| | | Object[] updateParams = {factoryTitle, factoryArgs, factoryId};
|
| | |
|
| | | // 执行更新操作
|
| | | db.executeSQL(updateSql, updateParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | public ModelAndView updateLLMConnect(SMTAIServerRequest tranReq) throws Exception {
|
| | | // 解析请求参数
|
| | | String connectId = tranReq.convParamToString("connect_id", true);
|
| | | String factoryId = tranReq.convParamToString("factory_id", true);
|
| | | String connectTitle = tranReq.convParamToString("connect_title", true);
|
| | | String className = tranReq.convParamToString("class_name", true);
|
| | | String connectArgs = tranReq.convParamToString("connect_args", true);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查连接 ID 是否存在
|
| | | String selectConnectSql = "SELECT * FROM ai_llm_connect WHERE connect_id = ?";
|
| | | Object[] connectParams = {connectId};
|
| | | if (db.querySQL(selectConnectSql, connectParams).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "连接id不存在", null);
|
| | | }
|
| | |
|
| | | // 检查模型 ID 是否存在
|
| | | String selectFactorySql = "SELECT * FROM ai_llm_factory WHERE factory_id = ?";
|
| | | Object[] factoryParams = {factoryId};
|
| | | if (db.querySQL(selectFactorySql, factoryParams).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "模型id不存在", null);
|
| | | }
|
| | |
|
| | | // 构建 SQL 语句
|
| | | String updateSql = "UPDATE ai_llm_connect SET factory_id = ?, connect_title = ?, class_name = ?, connect_args = ? WHERE connect_id = ?";
|
| | | Object[] updateParams = {factoryId, connectTitle, className, connectArgs, connectId};
|
| | |
|
| | | // 执行更新操作
|
| | | db.executeSQL(updateSql, updateParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public ModelAndView clearSystemCache(SMTAIServerRequest tranReq) throws Exception
|
| | | {
|
| | | SMTApp.getThis().clearEhCacheManager();
|
| | |
| | | }
|
| | | return tranReq.returnJson(jsonWr);
|
| | | }
|
| | | public ModelAndView addQuestionReplace(SMTAIServerRequest tranReq) throws Exception {
|
| | | String loginUserId = tranReq.getLoginUserId();
|
| | | // 解析请求参数
|
| | | String replaceId = tranReq.convParamToString("replace_id", true);
|
| | | String questionText = tranReq.convParamToString("question_text", true);
|
| | | String replaceText = tranReq.convParamToString("replace_text", true);
|
| | | int replaceOrder = tranReq.convParamToInteger("replace_order", true);
|
| | | String replaceState = tranReq.convParamToString("replace_state", true);
|
| | | String groupType = tranReq.convParamToString("group_type", true);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查替换ID是否已存在
|
| | | String selectSql = "SELECT * FROM ai_question_replace WHERE replace_id = ?";
|
| | | Object[] selectParams = {replaceId};
|
| | | if (db.querySQL(selectSql, selectParams).getRowCount() > 0) {
|
| | | return tranReq.returnJsonState(false, "替换ID已存在", null);
|
| | | }
|
| | |
|
| | | // 构建 SQL 语句
|
| | | String insertSql = "INSERT INTO ai_question_replace (replace_id, question_text, replace_text, replace_order, replace_state, create_user, create_time, group_type) " +
|
| | | "VALUES (?, ?, ?, ?, ?, ?, NOW(), ?)";
|
| | | Object[] insertParams = {
|
| | | replaceId, questionText, replaceText, replaceOrder, replaceState, loginUserId, groupType
|
| | | };
|
| | |
|
| | | // 执行插入操作
|
| | | db.executeSQL(insertSql, insertParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | public ModelAndView updateQuestionReplace(SMTAIServerRequest tranReq) throws Exception {
|
| | | // 解析请求参数
|
| | | String replaceId = tranReq.convParamToString("replace_id", true);
|
| | | String questionText = tranReq.convParamToString("question_text", false);
|
| | | String replaceText = tranReq.convParamToString("replace_text", false);
|
| | | int replaceOrder = tranReq.convParamToInteger("replace_order", false);
|
| | | String replaceState = tranReq.convParamToString("replace_state", false);
|
| | | String groupType = tranReq.convParamToString("group_type", false);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查替换ID是否存在
|
| | | String selectSql = "SELECT * FROM ai_question_replace WHERE replace_id = ?";
|
| | | Object[] selectParams = {replaceId};
|
| | | if (db.querySQL(selectSql, selectParams).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "替换ID不存在", null);
|
| | | }
|
| | |
|
| | | // 构建 SQL 语句
|
| | | String updateSql = "UPDATE ai_question_replace SET question_text = ?, replace_text = ?, replace_order = ?, replace_state = ?, group_type = ? " +
|
| | | "WHERE replace_id = ?";
|
| | | Object[] updateParams = {questionText, replaceText, replaceOrder, replaceState, groupType, replaceId};
|
| | |
|
| | | // 执行更新操作
|
| | | db.executeSQL(updateSql, updateParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|