using FastEndpoints; using FMBLL.Asset; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FMSL.EndPoints.Asset { public class GetAsset : BaseEndpoint> { private readonly IAssetBLL _AssetBLL; public GetAsset(IAssetBLL IAssetBLL) { _AssetBLL = IAssetBLL; } public override void Configure() { Get("/Asset/GetAsset"); AllowAnonymous(); } public record GetAssetParameters( [property: FromHeader] string Login, [property: QueryParam] int AssetId ); //protected override string? GetCacheKey(GetAssetParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.AssetId!, EntityConstant.OBJECTASSET, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetAssetParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AssetBLL.GetAsset(req.AssetId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }