using System; using System.Threading; using System.Threading.Tasks; using FastEndpoints; using FrameworkBLL.SysJobShare; using FrameworkDAL.DTO.SysJobShare; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.SysJobShare { /// /// Create or update a share record (the "Share" button action). /// SysJobShareId == 0 → new share; > 0 → update CanExecute/CanViewResult. /// public class SaveSysJobShare : BaseEndpoint> { private readonly ISysJobShareBLL _SysJobShareBLL; public SaveSysJobShare(ISysJobShareBLL sysJobShareBLL) { _SysJobShareBLL = sysJobShareBLL; } public override void Configure() { Post("/SysJobShare/SaveSysJobShare"); AllowAnonymous(); } public record SaveSysJobShareParameters( [property: FromHeader] string Login, [property: FromBody] SysJobShareDTO SysJobShareDTO ); protected override async Task> ExecuteAsync(SaveSysJobShareParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SysJobShareBLL.SaveSysJobShare(req.SysJobShareDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }