You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
6.5 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MySqlX.XDevAPI.Relational;
using Newtonsoft.Json.Linq;
using ZKLT.Hadoop.Interface;
using ZKLT.Hadoop.Model;
namespace ZKLT.Hadoop.API.Controllers
{
/// <summary>
/// 云计算接口
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class HadoopController : ControllerBase
{
public HadoopController(IHadoopService hadoop)
{
_HadoopService = hadoop;
}
private IHadoopService _HadoopService;
[HttpGet("getsource")]
public ActionResult GetSource([FromQuery] string sourceid)
{
try
{
return Ok(_HadoopService.GetSource(sourceid));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("insertsource")]
public ActionResult InsertSource(HDP_Source source)
{
try
{
return Ok(_HadoopService.InsertSource(source));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("updatesource")]
public ActionResult UpdateSource(HDP_Source source)
{
try
{
return Ok(_HadoopService.UpdateSource(source));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpGet("deletesource")]
public ActionResult DeleteSource([FromQuery] string sourceid)
{
try
{
return Ok(_HadoopService.DeleteSource(sourceid));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("querysource")]
public ActionResult QuerySource(HDP_Command command)
{
try
{
return Ok(_HadoopService.QuerySource(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpGet("gettable")]
public ActionResult GetTable([FromQuery] string tableid)
{
try
{
return Ok(_HadoopService.GetTable(tableid));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("inserttable")]
public ActionResult InsertTable(HDP_Table table)
{
try
{
return Ok(_HadoopService.InsertTable(table));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("updatetable")]
public ActionResult UpdateTable(HDP_Table table)
{
try
{
return Ok(_HadoopService.UpdateTable(table));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpGet("deletetable")]
public ActionResult DeleteTable([FromQuery] string tableId) {
try
{
return Ok(_HadoopService.DeleteTable(tableId));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("querytable")]
public ActionResult QueryTable(HDP_Command command) {
try
{
return Ok(_HadoopService.QueryTable(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("insertfile")]
public ActionResult InsertFile(IFormFile file)
{
if(file == null) {
return BadRequest("文件不存在");
}
var _file = new HDP_File();
_file.FileName = file.FileName;
_file.ContentType = file.ContentType;
_file.Data = new byte[file.Length];
file.OpenReadStream().Read(_file.Data, 0, (int)file.Length);
_file.FileSize = (int)file.Length;
return Ok(_file);
}
[HttpPost("insert")]
public ActionResult Insert(HDP_Command command) {
try
{
return Ok(_HadoopService.Insert(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("update")]
public ActionResult Update(HDP_Command command)
{
try
{
return Ok(_HadoopService.Update(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("delete")]
public ActionResult Delete(HDP_Command command)
{
try
{
return Ok(_HadoopService.Delete(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("querysingle")]
public ActionResult QuerySingle(HDP_Command command)
{
try
{
return Ok(_HadoopService.QuerySingle<dynamic>(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("query")]
public ActionResult Query(HDP_Command command)
{
try
{
return Ok(_HadoopService.Query<dynamic>(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("page")]
public ActionResult Page(HDP_Command command) {
try
{
return Ok(_HadoopService.Page<dynamic>(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
[HttpPost("patch")]
public ActionResult PatchCommand(HDP_Command[] command) {
try
{
return Ok(_HadoopService.PatchCommand(command));
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
}
}