using Microsoft.AspNetCore.Mvc; using OpenAuth.App.ServiceApp.TaxManage; using OpenAuth.App; using OpenAuth.App.ServiceApp.CompanyManage; using Infrastructure; using OpenAuth.Repository.Domain; using OpenAuth.App.ServiceApp.CompanyManage.Request; using Microsoft.AspNetCore.Authorization; namespace OpenAuth.WebApi.Controllers.ServiceController { /// /// 企业信息 /// [Route("api/[controller]/[action]")] [ApiController] public class TaxCompanyController : ControllerBase { TaxCompanyApp _comApp; public TaxCompanyController( TaxCompanyApp comApp) { _comApp = comApp; } #region 获取分页数据列表 /// /// 获取分页列表 /// /// /// [HttpGet] [AllowAnonymous] public async Task>>> LoadCompanyPageList([FromQuery]TaxCompanyReq req) { var result = new Response>>(); try { var data = await _comApp.LoadCompanyPageList(req); result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } /// /// 根据id获取单个企业信息 /// /// 企业id /// [HttpGet] [AllowAnonymous] public async Task> GetConpanyInfoById(string id) { var result = new Response(); try { var data = await _comApp.GetConpanyInfoById(id); result.Result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region /// /// 添加企业信息 /// /// /// /// [HttpPost] [AllowAnonymous] public async Task> AddCompany(TaxCompany req) { var result = new Response(); try { var data = await _comApp.AddCompany(req); result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } /// /// 编辑企业信息 /// /// /// /// [HttpPost] [AllowAnonymous] public async Task> UpdateCompany(TaxCompany req) { var result = new Response(); try { var data = await _comApp.UpdateCompany(req); result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } /// /// 删除企业 /// /// 企业id [HttpPost] [AllowAnonymous] public async Task> DeleteCompany(string[] ids) { var result = new Response(); try { var data = await _comApp.DeleteCompany(ids); result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region /// /// 查询乡镇 /// /// [HttpGet] [AllowAnonymous] public async Task>> GetStreetInfo() { var result = new Response>(); try { var data = await _comApp.GetStreetInfo(); result.Result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } /// /// 根据乡镇编码查询村 /// /// [HttpGet] [AllowAnonymous] public async Task>> GetCommunityInfo(string djqdm) { var result = new Response>(); try { var data = await _comApp.GetCommunityInfo(djqdm); result.Result = data; } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region 企业数据导入 /// /// 上传企业数据 /// /// 文件 /// [HttpPost] [AllowAnonymous] public Response ImportCompanyInfo(IFormFileCollection formFiles) { Response response = new Response(); try { response = _comApp.ImportCompanyInfo(formFiles); } catch (Exception ex) { response.Code = 500; response.Message = ex.InnerException?.Message ?? ex.Message; } return response; } #endregion } }