/// <inheritdoc /> public WebResult StringResult(Base64RawData <string> data) { if (string.IsNullOrWhiteSpace(data.RawData)) { return(new WebResult { Code = 2, Data = "参数错误" }); } switch (data.Type) { case Base64CodeType.Encode: return(new WebResult { Code = 1, Data = ToBase64(Encoding.UTF8, data.RawData) }); case Base64CodeType.Decode: return(new WebResult { Code = 1, Data = FromBase64(Encoding.UTF8, data.RawData) }); } return(new WebResult()); }
public object Post([FromBody] Base64RawData <string> data) { try { return(_base64.StringResult(data)); } catch (Exception e) { _logger.LogError(e, $"错误类型:{data.Type.ToString()}"); throw; } }
public object Post([FromForm] string type, [FromForm] string raw) { var data = new Base64RawData <string> { Type = Enum.Parse <Base64CodeType>(type, true), RawData = raw }; try { return(_base64.StringResult(data)); } catch (Exception e) { _logger.LogError(e, $"错误类型:{data.Type.ToString()}"); throw; } }
public object Get() { HttpRequest request = Request; var data = new Base64RawData <string> { Type = Enum.Parse <Base64CodeType>(request.Query["type"], true), RawData = request.Query["raw"] }; try { return(_base64.StringResult(data)); } catch (Exception e) { _logger.LogError(e, $"错误类型:{data.Type.ToString()}"); throw; } }