| | |
| | | {
|
| | | db.close();
|
| | | }
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | public ModelAndView addRoleInfo(SMTAIServerRequest tranReq) throws Exception {
|
| | | String roleId = tranReq.convParamToString("role_id", true);
|
| | | String roleTitle = tranReq.convParamToString("role_title", true);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查角色ID是否已存在
|
| | | String selectSql = "SELECT * FROM ai_sys.sys_role_info WHERE role_id = ?";
|
| | | Object[] selectParams = {roleId};
|
| | | if (db.querySQL(selectSql, selectParams).getRowCount() > 0) {
|
| | | return tranReq.returnJsonState(false, "角色ID已存在", null);
|
| | | }
|
| | |
|
| | | // 插入新角色
|
| | | String insertSql = "INSERT INTO ai_sys.sys_role_info (role_id, role_title) VALUES (?, ?)";
|
| | | Object[] insertParams = {roleId, roleTitle};
|
| | |
|
| | | db.executeSQL(insertSql, insertParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | } |
| | | }
|
| | |
|
| | | public ModelAndView updateRoleInfo(SMTAIServerRequest tranReq) throws Exception {
|
| | | String roleId = tranReq.convParamToString("role_id", true);
|
| | | String roleTitle = tranReq.convParamToString("role_title", false);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | |
|
| | | try {
|
| | | // 检查角色ID是否存在
|
| | | String selectSql = "SELECT * FROM ai_sys.sys_role_info WHERE role_id = ?";
|
| | | Object[] selectParams = {roleId};
|
| | | if (db.querySQL(selectSql, selectParams).getRowCount() == 0) {
|
| | | return tranReq.returnJsonState(false, "角色ID不存在", null);
|
| | | }
|
| | |
|
| | | // 更新角色信息
|
| | | String updateSql = "UPDATE ai_sys.sys_role_info SET role_title = ? WHERE role_id = ?";
|
| | | Object[] updateParams = {roleTitle, roleId};
|
| | |
|
| | | db.executeSQL(updateSql, updateParams);
|
| | |
|
| | | // 返回 JSON 结果
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | return tranReq.returnJson(jsonWr);
|
| | | } finally {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public ModelAndView addUserInfo(SMTAIServerRequest tranReq) throws Exception
|
| | | {
|
| | | String userName = tranReq.convParamToString("user_name", true);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public ModelAndView getResourceUsage(SMTAIServerRequest tranReq) throws Exception |
| | | {
|
| | | SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
|
| | | |
| | | SMTAIServerApp.getApp().getDatasourceUsgaeToJson(jsonWr);
|
| | | |
| | | return tranReq.returnJson(jsonWr);
|
| | | }
|
| | |
|
| | | }
|