using FastEndpoints;
using FrameworkBLL.Comment;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using GB5Shared.FastEndPoint;
using static GB5Shared.GB5Constant.Constant;
namespace FrameworkSL.Endpoints.Comment
{
///
/// Superseded by CommunicationSL.Endpoints.CommentThread.GetCommentThread (GB5Solution/
/// Communication module, ECP Phase 1). TCOMMENT/GetComment has no callers outside
/// GB5Framework (confirmed by repo-wide grep during Phase 1 planning) — kept only in case of
/// an undiscovered caller. Do not add new callers.
///
[Obsolete("Superseded by CommunicationSL.Endpoints.CommentThread.GetCommentThread (Communication module, ECP Phase 1). Do not use in new code.")]
public class GetComment : BaseEndpoint
{
private readonly ICommentBLL _commentBLL;
public GetComment(ICommentBLL commentBLL)
{
_commentBLL = commentBLL;
}
public override void Configure()
{
Get("/Comment/GetComment");
AllowAnonymous();
}
public record GetCommentParameters(
[property: QueryParam] int CommentId,
[property: FromHeader] string Login
);
protected override string? GetCacheKey(GetCommentParameters GetCommentParameters, LoginDTO LoginDTO)
{
try
{
return KeyGenerator.KeyGeneration(GetCommentParameters.CommentId!, EntityConstant.COMMENT, CacheKeyLevel.USER_LEVEL, LoginDTO);
}
catch (Exception)
{
throw;
}
}
protected override async Task> ExecuteAsync(GetCommentParameters parameters, LoginDTO loginDTO, CancellationToken ct)
{
try
{
var result = await _commentBLL.GetComment(parameters.CommentId, 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);
}
}
}
}