using FastEndpoints; using FrameworkBLL.User; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.User { public class GetUserSettingDetail : BaseEndpoint> { private readonly IUserBLL _UserBLL; public GetUserSettingDetail(IUserBLL IUserBLL) { _UserBLL = IUserBLL; } public override void Configure() { Get("/User/GetUserSettingDetail"); AllowAnonymous(); } public record GetUserSettingDetailParameters( [property: FromHeader] string Login, [property: QueryParam] int UserId ); protected override string? GetCacheKey(GetUserSettingDetailParameters Parameters, LoginDTO LoginDTO) { try { // ObjectId must differ from GetUser's cache key (both use EntityConstant.OBJECTUSER // for the same UserId/LoginDTO) — otherwise the two endpoints collide on the same // Dapr statestore key and one serves back the other's cached response shape. return KeyGenerator.KeyGeneration(new { Parameters.UserId, Scope = "SETTINGDETAIL" }, EntityConstant.OBJECTUSER, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetUserSettingDetailParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _UserBLL.GetUserSettingDetail(req.UserId, 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); } } } }