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.

90 lines
2.5 KiB
C#

namespace Admin.NET.Plugin.HwPortal;
[AllowAnonymous]
[Route("portal/hwWebDocument")]
public class HwWebDocumentController : HwPortalControllerBase
{
private readonly HwWebDocumentService _service;
public HwWebDocumentController(HwWebDocumentService service)
{
_service = service;
}
[HttpGet("list")]
public async Task<HwPortalTableDataInfo<HwWebDocument>> List([FromQuery] HwWebDocument input)
{
List<HwWebDocument> list = await _service.SelectHwWebDocumentList(input);
foreach (HwWebDocument doc in list)
{
bool hasSecret = doc.HasSecret;
doc.SecretKey = null;
if (hasSecret)
{
doc.DocumentAddress = null;
}
}
return GetDataTable(list);
}
[HttpPost("export")]
[Idempotent]
public async Task<IActionResult> Export([FromQuery] HwWebDocument input)
{
return ExportExcel(await _service.SelectHwWebDocumentList(input), "资料文件数据");
}
[HttpGet("{documentId}")]
public async Task<HwPortalAjaxResult> GetInfo(string documentId)
{
HwWebDocument doc = await _service.SelectHwWebDocumentByDocumentId(documentId);
if (doc != null)
{
bool hasSecret = doc.HasSecret;
doc.SecretKey = null;
if (hasSecret)
{
doc.DocumentAddress = null;
}
}
return Success(doc);
}
[HttpPost]
[Idempotent]
public async Task<HwPortalAjaxResult> Add([FromBody] HwWebDocument input)
{
return ToAjax(await _service.InsertHwWebDocument(input));
}
[HttpPut]
[Idempotent]
public async Task<HwPortalAjaxResult> Edit([FromBody] HwWebDocument input)
{
return ToAjax(await _service.UpdateHwWebDocument(input));
}
[HttpDelete("{documentIds}")]
[Idempotent]
public async Task<HwPortalAjaxResult> Remove(string documentIds)
{
return ToAjax(await _service.DeleteHwWebDocumentByDocumentIds(documentIds.Split(',', StringSplitOptions.RemoveEmptyEntries)));
}
[HttpPost("getSecureDocumentAddress")]
[Idempotent]
public async Task<HwPortalAjaxResult> GetSecureDocumentAddress([FromBody] SecureDocumentRequest request)
{
try
{
return Success(await _service.VerifyAndGetDocumentAddress(request.DocumentId, request.ProvidedKey));
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
}