diff --git a/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs
index ac7f6de..9887493 100644
--- a/FrontendWebApi/ApiControllers/GraphManageController.cs
+++ b/FrontendWebApi/ApiControllers/GraphManageController.cs
@@ -93,6 +93,10 @@ namespace FrontendWebApi.ApiControllers
}
+ ///
+ /// 圖資類別列表
+ ///
+ ///
[HttpPost]
public async Task>> VarList()
{
@@ -120,6 +124,119 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+ ///
+ /// 新增圖資類別
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> SaveVar([FromBody] GraphVar gv)
+ {
+ ApiResult apiResult = new ApiResult();
+
+ try
+ {
+ Dictionary variable = new Dictionary();
+ var system_value = backendRepository.GetOneAsync("select system_value from variable where system_type = @system_type and deleted = 0 order by system_value desc limit 1", new { @system_type = gv.system_type }).Result;
+ variable.Add("@deleted", 0);
+ variable.Add("@system_type", gv.system_type);
+ variable.Add("@system_key", gv.system_key);
+ variable.Add("@system_parent_id", gv.system_parent_id);
+ variable.Add("@system_remark", "圖資管理-" + gv.system_key);
+ variable.Add("@priority", Int32.Parse(system_value) + 1);
+ variable.Add("@system_value", Int32.Parse(system_value) + 1);
+ variable.Add("@created_by", myUser.userinfo_guid);
+ variable.Add("@created_at", DateTime.Now);
+
+ await backendRepository.AddOneByCustomTable(variable, "variable");
+ apiResult.Code = "0000";
+ apiResult.Data = "新增成功";
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ string json = System.Text.Json.JsonSerializer.Serialize(gv);
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
+ ///
+ /// 編輯圖資類別
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> EditVar([FromBody] GraphVar gv)
+ {
+ ApiResult apiResult = new ApiResult();
+ var gm = await backendRepository.GetOneAsync("select * from variable where id = @id and deleted = 0", new { @id = gv.id });
+
+ if (gm != null)
+ {
+ apiResult.Code = "0002";
+ apiResult.Data = "無法找到圖資";
+ return apiResult;
+ }
+
+ try
+ {
+ Dictionary variable = new Dictionary();
+ var system_value = backendRepository.GetOneAsync("select system_value from variable where system_type = @system_type and deleted = 0 order by system_value desc limit 1", new { @system_type = gv.system_type }).Result;
+
+ variable.Add("@system_key", gv.system_key);
+ variable.Add("@updated_by", myUser.userinfo_guid);
+ variable.Add("@updated_at", DateTime.Now);
+
+ await backendRepository.UpdateOneByCustomTable(variable, "variable", "id = " + gv.id);
+ apiResult.Code = "0000";
+ apiResult.Data = "編輯成功";
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ string json = System.Text.Json.JsonSerializer.Serialize(gv);
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
+ ///
+ /// 刪除圖資類別
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> DelOneGraMan([FromBody] GraphVar gv)
+ {
+ ApiResult apiResult = new ApiResult();
+
+ try
+ {
+ var sqlString = @$"UPDATE variable SET deleted = 1, updated_at = @time, updated_by = @user WHERE id = @id";
+
+ var param = new { @id = gv.id, @time = DateTime.Now, @user = myUser.userinfo_guid };
+
+ await backendRepository.ExecuteSql(sqlString, param);
+ apiResult.Code = "0000";
+ apiResult.Data = "刪除成功";
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
[HttpPost]
public async Task>> GraManList([FromBody] GraphInfo gi)
{