using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SwBLL.UserResourceRole; using SwDAL.DTO.UserResourceRole; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace SwSL.EndPoints.UserResourceRole; //[MenuRights("SWUSERROLE", RightOperation.Delete)] public class RevokeUserResourceRole : BaseEndpoint> { private readonly IUserResourceRoleBLL _bll; public RevokeUserResourceRole(IUserResourceRoleBLL bll) => _bll = bll; public override void Configure() { Delete("/UserResourceRole/RevokeUserResourceRole"); AllowAnonymous(); } // Query params, not a body — the FE's generic DELETE helper (gbhttpdelete) sends only a // query string, matching every other Delete* endpoint's own convention in this repo. public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int UserId, [property: QueryParam] int? DbServerId = null, [property: QueryParam] int? ClientDbId = null); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO loginDTO, CancellationToken ct) { var dto = new RevokeUserResourceRoleDTO { UserId = req.UserId, DbServerId = req.DbServerId, ClientDbId = req.ClientDbId, }; var result = await _bll.RevokeUserResourceRole(dto, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }