90 lines
2.5 KiB
C#
90 lines
2.5 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using HRM.BO;
|
|
using HRM.BO.SearchTools;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace HRM.UI.Controllers.SearchTools
|
|
{
|
|
[Route("api/SearchTools")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class SearchToolsController : ControllerBase
|
|
{
|
|
private readonly IDbColumnsService _dbColumnsService;
|
|
private readonly IQueryToolService _queryToolService;
|
|
|
|
public SearchToolsController(IDbColumnsService dbColumnsService, IQueryToolService queryToolService)
|
|
{
|
|
this._dbColumnsService = dbColumnsService;
|
|
this._queryToolService = queryToolService;
|
|
}
|
|
|
|
[HttpGet("getColumnsByTableId/{tableId}")]
|
|
public ActionResult GetColumnsByTableName(int tableId)
|
|
{
|
|
List<DbColumns> items = new List<DbColumns>();
|
|
try
|
|
{
|
|
items = this._dbColumnsService.GetByTableId(tableId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
[HttpGet("getColumns")]
|
|
public ActionResult GetColumns()
|
|
{
|
|
List<DbColumns> items = new List<DbColumns>();
|
|
try
|
|
{
|
|
items = this._dbColumnsService.GetAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpGet("getAllQueryTool")]
|
|
public ActionResult GetAllQueryTool()
|
|
{
|
|
List<QueryTool> items = new List<QueryTool>();
|
|
try
|
|
{
|
|
items = this._queryToolService.GetAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("saveQueryTool")]
|
|
public ActionResult SaveQueryTool(QueryTool item)
|
|
{
|
|
try
|
|
{
|
|
this._queryToolService.SaveQueryTool(item);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
} |