using AmpDAL.DTO.ApiOperation; using AmpDAL.Query.ApiOperation; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; namespace AmpDAL.CustomCode.ApiOperation; public class ApiOperationDAL(IQueryExecutor _qe) : IApiOperationDAL { public async Task GetOperationAsync(long ApiOperationId, LoginDTO login, CancellationToken ct) => await _qe.QuerySingleAsync( login, ApiOperationQB.GET_OPERATION, new { ApiOperationId = ApiOperationId }).ConfigureAwait(false); public async Task> GetOperationListAsync(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiOperationQB.GET_OPERATION_LIST, new { TenantId = login.ClientId }).ConfigureAwait(false); return result.ToList(); } public async Task SaveOperationAsync(ApiOperationSaveDTO dto, LoginDTO login, CancellationToken ct) => await _qe.ExecuteScalarAsync( login, ApiOperationQB.SAVE_OPERATION, new { dto.ApiOperationId, dto.TenantId, dto.ApiId, dto.ApiInterfaceId, dto.OperationKey, dto.HttpMethod, dto.RelativePath, dto.Summary, dto.Remarks, dto.SortOrder, dto.Status, dto.Version, dto.SourceType, dto.CreatedById, dto.CreatedOn, dto.ModifiedById, dto.ModifiedOn }).ConfigureAwait(false); public async Task UpdateOperationAsync(ApiOperationSaveDTO dto, LoginDTO login, CancellationToken ct) => await _qe.ExecuteScalarAsync( login, ApiOperationQB.UPDATE_OPERATION, new { dto.ApiOperationId, dto.ApiInterfaceId, dto.OperationKey, dto.HttpMethod, dto.RelativePath, dto.Summary, dto.Remarks, dto.SortOrder, dto.Status, dto.Version, dto.SourceType, dto.ModifiedById, dto.ModifiedOn }).ConfigureAwait(false); public async Task> GetOperationSelectListAsync(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiOperationQB.GET_OPERATION_SELECT_LIST, new { TenantId = login.ClientId }).ConfigureAwait(false); return result.ToList(); } public async Task> GetPagedOperationList(int firstNumber, int maxResult, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiOperationQB.GET_OPERATION_LIST_PAGED, new { TenantId = login.ClientId, FirstNumber = firstNumber, MaxResult = maxResult }).ConfigureAwait(false); return result.ToList(); } public async Task DeleteById(int apiOperationId, LoginDTO login, CancellationToken ct) => await _qe.ExecuteAsync( login, ApiOperationQB.DELETE_OPERATION, new { ApiOperationId = apiOperationId, TenantId = login.ClientId }).ConfigureAwait(false); }