using Infrastructure; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using OpenAuth.App; using OpenAuth.App.Request; using OpenAuth.App.ServiceApp.LayerManagerApp; using OpenAuth.App.ServiceApp.LayerManagerApp.Request; namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance; /// /// 图层 /// [Route("api/[controller]/[action]")] [ApiController] public class LayerController : ControllerBase { private readonly LayerApp _app; public LayerController(LayerApp layerApp) { _app = layerApp; } /// /// excel 上传 /// /// /// [HttpPost] public async Task> UploadExcel(LayerReq req) { return await _app.UploadExcel(req); } /// /// shape文件上传 /// /// /// [HttpPost] public async Task> UploadShape(LayerReq req) { return await _app.UploadShape(req); } [HttpGet] [AllowAnonymous] public Response> 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] public IActionResult TempeleteByTableName(string tablename) { var res = new Response(); var excelRes = _app.TempeleteByTableName(tablename); 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 = "导出失败"; } return Ok(res); } [HttpPost] [AllowAnonymous] public async Task> UploadExcelAll([FromBody]UploadExcelReq req) { Response response = new Response(); try { response.Result = await _app.UploadExcel1(req); } catch (Exception ex) { response.Code = 500; response.Message = ex.InnerException?.Message ?? ex.Message; } return response; } [HttpPost] [AllowAnonymous] public Response UpdateTableData(UpdateTableReq req) { Response response = new Response(); try { response.Result = _app.UpdateTableData(req); } catch (Exception ex) { response.Code = 500; response.Message = ex.InnerException?.Message ?? ex.Message; } return response; } [HttpPost] [AllowAnonymous] public async Task> AddUploadExcel([FromBody] UploadExcelReq req) { Response response = new Response(); try { response.Result = await _app.AddUploadExcel(req); } catch (Exception ex) { response.Code = 500; response.Message = ex.InnerException?.Message ?? ex.Message; } return response; } }