98 lines
3.5 KiB
C#
98 lines
3.5 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Text;
|
|
using System.Web;
|
|
using YLErp.Modules.ApiModule.ExportModule;
|
|
|
|
namespace YLWebAPI.ApiModule.ManagerApi
|
|
{
|
|
/// <summary>
|
|
/// 交易合约文档
|
|
/// </summary>
|
|
[ManagerAuth]
|
|
public class TradeContractDocController : BaseApiController
|
|
{
|
|
/// <summary>
|
|
/// 交易确认书批量导出API
|
|
/// </summary>
|
|
[HttpPost, Route("api/v1/otc/trade_contract/OpenDocBatchExport")]
|
|
public HttpResponseMessage OtcTradeContractOpenDocExport([FromBody] OtcTradeContractOpenDocExportRequest model)
|
|
{
|
|
if (model is null)
|
|
{
|
|
return new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
|
{
|
|
Content = new StringContent("参数不能为空", System.Text.Encoding.UTF8, "text/plain")
|
|
};
|
|
}
|
|
|
|
try
|
|
{
|
|
var zipBuffer = new OtcTradeContractDocExportService(CurUser).GetZipFileOfOpenDocs(model, out _);
|
|
|
|
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
Content = new ByteArrayContent(zipBuffer)
|
|
};
|
|
|
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
|
{
|
|
FileName =HttpUtility.UrlEncode("交易确认书批量导出.zip",Encoding.UTF8)
|
|
};
|
|
|
|
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
|
|
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
|
{
|
|
Content = new StringContent(ex.ToString(), System.Text.Encoding.UTF8, "text/plain")
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 了结确认书批量导出API
|
|
/// </summary>
|
|
[HttpPost, Route("api/v1/otc/trade_contract/CloseDocBatchExport")]
|
|
public HttpResponseMessage OtcTradeContractCloseDocExport([FromBody] OtcTradeContractCloseDocExportRequest model)
|
|
{
|
|
if (model is null)
|
|
{
|
|
return new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
|
{
|
|
Content = new StringContent("参数不能为空", System.Text.Encoding.UTF8, "text/plain")
|
|
};
|
|
}
|
|
|
|
try
|
|
{
|
|
var zipBuffer = new OtcTradeContractDocExportService(CurUser).GetZipFileOfCloseDocs(model, out _);
|
|
|
|
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
Content = new ByteArrayContent(zipBuffer)
|
|
};
|
|
|
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
|
{
|
|
FileName = HttpUtility.UrlEncode("了结确认书批量导出.zip", Encoding.UTF8)
|
|
};
|
|
|
|
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
|
|
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
|
{
|
|
Content = new StringContent(ex.ToString(), System.Text.Encoding.UTF8, "text/plain")
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|