新增圖資讀取

This commit is contained in:
dev02 2022-11-09 15:22:18 +08:00
parent cad0b36cc7
commit b0b9500bd3

View File

@ -90,6 +90,7 @@ namespace FrontendWebApi.ApiControllers
return apiResult; return apiResult;
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<List<GraphList>>> GraManList([FromBody] GraphInfo gi) public async Task<ApiResult<List<GraphList>>> GraManList([FromBody] GraphInfo gi)
{ {
@ -133,6 +134,44 @@ namespace FrontendWebApi.ApiControllers
return apiResult; return apiResult;
} }
[HttpPost]
public async Task<ApiResult<GraphList>> GraManRead([FromBody] GraphInfo gi)
{
ApiResult<GraphList> apiResult = new ApiResult<GraphList>();
GraphList graManList = new GraphList();
try
{
var sqlString = @$"SELECT *
FROM graph_manage gm
JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0
JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
WHERE v2.system_value = @sub_system_tag AND gm.deleted = 0 AND gm.code = @code
ORDER BY gm.priority, gm.created_at desc";
var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag, @code = gi.code };
graManList = await backendRepository.GetOneAsync<GraphList>(sqlString, param);
if (graManList == null)
{
apiResult.Code = "0002";
apiResult.Msg = "找不到圖資";
return apiResult;
}
apiResult.Code = "0000";
apiResult.Data = graManList;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> DelOneGraMan([FromBody] GraphInfo gi) public async Task<ApiResult<string>> DelOneGraMan([FromBody] GraphInfo gi)
{ {