Infrastructure/OpenAuth.WebApi/Controllers/ServiceControllers/DataMaintenance/LayerController.cs

232 lines
6.4 KiB
C#
Raw Normal View History

2025-01-10 10:14:58 +08:00
using Infrastructure;
2025-04-14 10:57:27 +08:00
using Microsoft.AspNetCore.Authorization;
2025-01-10 10:14:58 +08:00
using Microsoft.AspNetCore.Mvc;
2025-04-14 10:57:27 +08:00
using OpenAuth.App;
using OpenAuth.App.Request;
2025-01-10 10:14:58 +08:00
using OpenAuth.App.ServiceApp.LayerManagerApp;
using OpenAuth.App.ServiceApp.LayerManagerApp.Request;
2025-04-17 14:48:05 +08:00
using Org.BouncyCastle.Ocsp;
2025-01-10 10:14:58 +08:00
namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance;
2025-01-10 10:14:58 +08:00
/// <summary>
/// 图层
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class LayerController : ControllerBase
{
private readonly LayerApp _app;
public LayerController(LayerApp layerApp)
{
_app = layerApp;
}
/// <summary>
/// excel 上传
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public async Task<Response<bool>> UploadExcel(LayerReq req)
{
return await _app.UploadExcel(req);
}
/// <summary>
/// shape文件上传
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
2025-04-17 14:48:05 +08:00
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
[RequestSizeLimit(214748364800)]
2025-04-17 14:48:05 +08:00
public async Task<Response<bool>> UploadShape(string zipFilePath, string tableName)
2025-01-10 10:14:58 +08:00
{
2025-04-17 14:48:05 +08:00
return await _app.UploadShape3( zipFilePath, tableName);
2025-01-10 10:14:58 +08:00
}
2025-04-14 10:57:27 +08:00
[HttpGet]
[AllowAnonymous]
public Response<Dictionary<string, object>> TableDataByTableName(string tablename,string type,string keyword,string keyvalue,int page=1,int limit = 10) {
return _app.TableDataByTableName(tablename,type, keyword,keyvalue, page,limit);
}
[HttpGet]
[AllowAnonymous]
2025-04-17 14:48:05 +08:00
public IActionResult TempeleteByTableName(string tablename,int type)
2025-04-14 10:57:27 +08:00
{
var res = new Response();
2025-04-17 14:48:05 +08:00
if (type ==0)
2025-04-14 10:57:27 +08:00
{
2025-04-17 14:48:05 +08:00
var excelRes = _app.TempeleteByTableName(tablename,type,"","");
if (excelRes.Code == 200)
{
return File(excelRes.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"数据导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
}
else
{
res.Code = excelRes.Code;
res.Message = "导出失败";
}
2025-04-14 10:57:27 +08:00
}
2025-04-17 14:48:05 +08:00
if (type==1)
2025-04-14 10:57:27 +08:00
{
2025-04-17 14:48:05 +08:00
try
{
string shpFilePath = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.shp");
string shpFilePathzip = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
_app.TempeleteByTableName(tablename,type, shpFilePath, shpFilePathzip);
byte[] fileBytes = System.IO.File.ReadAllBytes(shpFilePathzip);
return File(fileBytes, "application/octet-stream", $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
}
catch (Exception ex)
{
return StatusCode(500, $"Internal server error: {ex.Message}");
}
2025-04-14 10:57:27 +08:00
}
2025-04-17 14:48:05 +08:00
2025-04-14 10:57:27 +08:00
return Ok(res);
}
2025-04-17 14:48:05 +08:00
2025-04-14 10:57:27 +08:00
[HttpPost]
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
[RequestSizeLimit(214748364800)]
2025-04-17 14:48:05 +08:00
public async Task<Response<bool>> UploadExcelAll(string tableName, IFormFile file)
2025-04-14 10:57:27 +08:00
{
Response<bool> response = new Response<bool>();
try
{
2025-04-17 14:48:05 +08:00
response.Result = await _app.UploadExcel1(tableName, file);
2025-04-26 14:12:14 +08:00
return response;
2025-04-17 14:48:05 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
2025-04-26 14:12:14 +08:00
return response;
2025-04-17 14:48:05 +08:00
}
2025-04-26 14:12:14 +08:00
2025-04-17 14:48:05 +08:00
}
[HttpPost]
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
[RequestSizeLimit(214748364800)]
2025-04-26 14:12:14 +08:00
public async Task<Response<Dictionary<string, object>>> UploadExcelInsert(string tableName, IFormFile file)
2025-04-17 14:48:05 +08:00
{
2025-04-26 14:12:14 +08:00
return await _app.UploadExcel2(tableName, file);
2025-04-14 10:57:27 +08:00
}
[HttpPost]
[AllowAnonymous]
public Response<bool> UpdateTableData(UpdateTableReq req)
{
Response<bool> response = new Response<bool>();
try
{
response.Result = _app.UpdateTableData(req);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
[HttpPost]
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
public Response<bool> AddTableData(UpdateTableReq req)
2025-04-14 10:57:27 +08:00
{
2025-04-30 13:24:35 +08:00
2025-04-14 10:57:27 +08:00
Response<bool> response = new Response<bool>();
try
{
2025-04-30 13:24:35 +08:00
response.Result = _app.AddTableData(req);
2025-04-14 10:57:27 +08:00
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
2025-04-30 13:24:35 +08:00
return response;
}
[HttpPost]
[AllowAnonymous]
[RequestSizeLimit(214748364800)]
public async Task<Response<Dictionary<string, object>>> AddUploadExcel(string tableName, IFormFile file)
{
UploadExcelReq req = new UploadExcelReq { tableName = tableName, file = file };
return await _app.AddUploadExcel(req);
2025-04-14 10:57:27 +08:00
}
2025-04-17 14:48:05 +08:00
[HttpGet]
[AllowAnonymous]
public async Task<Response<bool>> UploadSldStyle(string tablename,string styleName, string filepath)
{
Response<bool> response = new Response<bool>();
try
{
var result = await _app.uploadSldStyle(styleName,tablename, filepath);
return result;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
response.Result = false;
}
return response;
}
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
[RequestSizeLimit(214748364800)]
2025-04-17 14:48:05 +08:00
public async Task<Response<Dictionary<string, object>>> UploadShape1(string zipFilePath, string tableName)
{
return await _app.UploadShape1(zipFilePath,tableName);
}
[HttpPost]
[AllowAnonymous]
2025-04-30 13:24:35 +08:00
public async Task<Response<Dictionary<string, object>>> UploadShape2(string zipFilePath, string tableName)
2025-04-17 14:48:05 +08:00
{
return await _app.UploadShape2(zipFilePath, tableName);
}
[HttpPost]
[AllowAnonymous]
public Response<bool> UpdateTableOriginalData(UpdateTableReq req)
{
Response<bool> response = new Response<bool>();
try
{
response.Result = _app.UpdateTableData1(req);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
2025-01-10 10:14:58 +08:00
}