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> List([FromQuery] HwWebDocument input) { List 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 Export([FromQuery] HwWebDocument input) { return ExportExcel(await _service.SelectHwWebDocumentList(input), "资料文件数据"); } [HttpGet("{documentId}")] public async Task 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 Add([FromBody] HwWebDocument input) { return ToAjax(await _service.InsertHwWebDocument(input)); } [HttpPut] [Idempotent] public async Task Edit([FromBody] HwWebDocument input) { return ToAjax(await _service.UpdateHwWebDocument(input)); } [HttpDelete("{documentIds}")] [Idempotent] public async Task Remove(string documentIds) { return ToAjax(await _service.DeleteHwWebDocumentByDocumentIds(documentIds.Split(',', StringSplitOptions.RemoveEmptyEntries))); } [HttpPost("getSecureDocumentAddress")] [Idempotent] public async Task GetSecureDocumentAddress([FromBody] SecureDocumentRequest request) { try { return Success(await _service.VerifyAndGetDocumentAddress(request.DocumentId, request.ProvidedKey)); } catch (Exception ex) { return Error(ex.Message); } } }