using System.Collections.Concurrent;
using System.Text.Json;
using YLErp.Helpers;
namespace YLErp.Web.WebAPI.Controllers
{
///
/// 仅供本地开发验证收益互换移动审批调用链的 OA 模拟接口。
///
[ApiController]
[Route("api/mock/tradeApprovalOa")]
public class TradeApprovalOaMockController : ControllerBase
{
private static readonly ConcurrentDictionary Flows = new();
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
[HttpPost("createOaFlow")]
public IActionResult CreateOaFlow([FromBody] JsonElement payload)
{
if (!IsEnabled()) return NotFound();
var requestId = "mock-" + Guid.NewGuid().ToString("N");
Flows[requestId] = new MockOaFlow { RequestId = requestId };
return Json(new { code = 0, data = new { msg = string.Empty, requestid = requestId }, status = "SUCCESS" });
}
[HttpGet("getRequestData")]
public IActionResult GetRequestData([FromQuery] string requestId)
{
if (!IsEnabled()) return NotFound();
if (!Flows.TryGetValue(requestId ?? string.Empty, out var flow))
return Json(new { code = 0, data = Array.Empty