|
|
@ -26,49 +26,49 @@ namespace LINGYUN.ApiGateway.Ocelot |
|
|
_aggregateReRouteRepository = aggregateReRouteRepository; |
|
|
_aggregateReRouteRepository = aggregateReRouteRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<AggregateReRouteDto> GetAsync(AggregateRouteGetByRouteIdInputDto aggregateRouteGetByRouteId) |
|
|
public virtual async Task<AggregateReRouteDto> GetAsync(AggregateRouteGetByRouteIdInputDto input) |
|
|
{ |
|
|
{ |
|
|
var routeId = long.Parse(aggregateRouteGetByRouteId.RouteId); |
|
|
var routeId = long.Parse(input.RouteId); |
|
|
var reroute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
var reroute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
|
|
|
|
|
|
return ObjectMapper.Map<AggregateReRoute, AggregateReRouteDto>(reroute); |
|
|
return ObjectMapper.Map<AggregateReRoute, AggregateReRouteDto>(reroute); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Export)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Export)] |
|
|
public async Task<ListResultDto<AggregateReRouteDto>> GetAsync(AggregateRouteGetByAppIdInputDto aggregateRouteGetByAppId) |
|
|
public async Task<ListResultDto<AggregateReRouteDto>> GetAsync(AggregateRouteGetByAppIdInputDto input) |
|
|
{ |
|
|
{ |
|
|
var reroutes = await _aggregateReRouteRepository.GetByAppIdAsync(aggregateRouteGetByAppId.AppId); |
|
|
var reroutes = await _aggregateReRouteRepository.GetByAppIdAsync(input.AppId); |
|
|
|
|
|
|
|
|
return new ListResultDto<AggregateReRouteDto>(ObjectMapper.Map<List<AggregateReRoute>, List<AggregateReRouteDto>>(reroutes)); |
|
|
return new ListResultDto<AggregateReRouteDto>(ObjectMapper.Map<List<AggregateReRoute>, List<AggregateReRouteDto>>(reroutes)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async Task<PagedResultDto<AggregateReRouteDto>> GetPagedListAsync(AggregateRouteGetByPagedInputDto aggregateRouteGetByPaged) |
|
|
public async Task<PagedResultDto<AggregateReRouteDto>> GetPagedListAsync(AggregateRouteGetByPagedInputDto input) |
|
|
{ |
|
|
{ |
|
|
var reroutesTuple = await _aggregateReRouteRepository |
|
|
var reroutesTuple = await _aggregateReRouteRepository |
|
|
.GetPagedListAsync(aggregateRouteGetByPaged.AppId, aggregateRouteGetByPaged.Filter, |
|
|
.GetPagedListAsync(input.AppId, input.Filter, |
|
|
aggregateRouteGetByPaged.Sorting, aggregateRouteGetByPaged.SkipCount, |
|
|
input.Sorting, input.SkipCount, |
|
|
aggregateRouteGetByPaged.MaxResultCount); |
|
|
input.MaxResultCount); |
|
|
|
|
|
|
|
|
return new PagedResultDto<AggregateReRouteDto>(reroutesTuple.total, |
|
|
return new PagedResultDto<AggregateReRouteDto>(reroutesTuple.total, |
|
|
ObjectMapper.Map<List<AggregateReRoute>, List<AggregateReRouteDto>>(reroutesTuple.routes)); |
|
|
ObjectMapper.Map<List<AggregateReRoute>, List<AggregateReRouteDto>>(reroutesTuple.routes)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Create)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Create)] |
|
|
public virtual async Task<AggregateReRouteDto> CreateAsync(AggregateReRouteCreateDto aggregateReRouteCreate) |
|
|
public virtual async Task<AggregateReRouteDto> CreateAsync(AggregateReRouteCreateDto input) |
|
|
{ |
|
|
{ |
|
|
var aggregateNameExists = await _aggregateReRouteRepository |
|
|
var aggregateNameExists = await _aggregateReRouteRepository |
|
|
.AggregateReRouteNameExistsAsync(aggregateReRouteCreate.Name); |
|
|
.AggregateReRouteNameExistsAsync(input.Name); |
|
|
if (aggregateNameExists) |
|
|
if (aggregateNameExists) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException(L["AggregateReRouteExists", aggregateReRouteCreate.Name]); |
|
|
throw new UserFriendlyException(L["AggregateReRouteExists", input.Name]); |
|
|
} |
|
|
} |
|
|
var aggregateRoute = ObjectMapper.Map<AggregateReRouteCreateDto, AggregateReRoute>(aggregateReRouteCreate); |
|
|
var aggregateRoute = ObjectMapper.Map<AggregateReRouteCreateDto, AggregateReRoute>(input); |
|
|
aggregateRoute.SetUpstream(aggregateReRouteCreate.UpstreamHost, aggregateReRouteCreate.UpstreamPathTemplate); |
|
|
aggregateRoute.SetUpstream(input.UpstreamHost, input.UpstreamPathTemplate); |
|
|
foreach (var httpMethod in aggregateReRouteCreate.UpstreamHttpMethod) |
|
|
foreach (var httpMethod in input.UpstreamHttpMethod) |
|
|
{ |
|
|
{ |
|
|
aggregateRoute.AddUpstreamHttpMethod(httpMethod); |
|
|
aggregateRoute.AddUpstreamHttpMethod(httpMethod); |
|
|
} |
|
|
} |
|
|
foreach (var routeKey in aggregateReRouteCreate.ReRouteKeys) |
|
|
foreach (var routeKey in input.ReRouteKeys) |
|
|
{ |
|
|
{ |
|
|
aggregateRoute.AddRouteKey(routeKey); |
|
|
aggregateRoute.AddRouteKey(routeKey); |
|
|
} |
|
|
} |
|
|
@ -80,24 +80,24 @@ namespace LINGYUN.ApiGateway.Ocelot |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Update)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Update)] |
|
|
public virtual async Task<AggregateReRouteDto> UpdateAsync(AggregateReRouteUpdateDto aggregateReRouteUpdate) |
|
|
public virtual async Task<AggregateReRouteDto> UpdateAsync(AggregateReRouteUpdateDto input) |
|
|
{ |
|
|
{ |
|
|
var routeId = long.Parse(aggregateReRouteUpdate.RouteId); |
|
|
var routeId = long.Parse(input.RouteId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
aggregateRoute.Priority = aggregateReRouteUpdate.Priority; |
|
|
aggregateRoute.Priority = input.Priority; |
|
|
aggregateRoute.ConcurrencyStamp = aggregateReRouteUpdate.ConcurrencyStamp; |
|
|
aggregateRoute.ConcurrencyStamp = input.ConcurrencyStamp; |
|
|
aggregateRoute.ReRouteIsCaseSensitive = aggregateReRouteUpdate.ReRouteIsCaseSensitive; |
|
|
aggregateRoute.ReRouteIsCaseSensitive = input.ReRouteIsCaseSensitive; |
|
|
aggregateRoute.Aggregator = aggregateReRouteUpdate.Aggregator; |
|
|
aggregateRoute.Aggregator = input.Aggregator; |
|
|
aggregateRoute.SetUpstream(aggregateReRouteUpdate.UpstreamHost, aggregateReRouteUpdate.UpstreamPathTemplate); |
|
|
aggregateRoute.SetUpstream(input.UpstreamHost, input.UpstreamPathTemplate); |
|
|
|
|
|
|
|
|
aggregateRoute.RemoveAllUpstreamHttpMethod(); |
|
|
aggregateRoute.RemoveAllUpstreamHttpMethod(); |
|
|
foreach (var httpMethod in aggregateReRouteUpdate.UpstreamHttpMethod) |
|
|
foreach (var httpMethod in input.UpstreamHttpMethod) |
|
|
{ |
|
|
{ |
|
|
aggregateRoute.AddUpstreamHttpMethod(httpMethod); |
|
|
aggregateRoute.AddUpstreamHttpMethod(httpMethod); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
aggregateRoute.RemoveAllRouteKey(); |
|
|
aggregateRoute.RemoveAllRouteKey(); |
|
|
foreach (var routeKey in aggregateReRouteUpdate.ReRouteKeys) |
|
|
foreach (var routeKey in input.ReRouteKeys) |
|
|
{ |
|
|
{ |
|
|
aggregateRoute.AddRouteKey(routeKey); |
|
|
aggregateRoute.AddRouteKey(routeKey); |
|
|
} |
|
|
} |
|
|
@ -110,9 +110,9 @@ namespace LINGYUN.ApiGateway.Ocelot |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Delete)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.Delete)] |
|
|
public virtual async Task DeleteAsync(AggregateRouteGetByRouteIdInputDto aggregateRouteGetByRouteId) |
|
|
public virtual async Task DeleteAsync(AggregateRouteGetByRouteIdInputDto input) |
|
|
{ |
|
|
{ |
|
|
var routeId = long.Parse(aggregateRouteGetByRouteId.RouteId); |
|
|
var routeId = long.Parse(input.RouteId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
await _aggregateReRouteRepository.DeleteAsync(aggregateRoute); |
|
|
await _aggregateReRouteRepository.DeleteAsync(aggregateRoute); |
|
|
|
|
|
|
|
|
@ -120,14 +120,14 @@ namespace LINGYUN.ApiGateway.Ocelot |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.ManageRouteConfig)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.ManageRouteConfig)] |
|
|
public virtual async Task<AggregateReRouteConfigDto> AddRouteConfigAsync(AggregateReRouteConfigCreateDto aggregateReRouteConfigCreate) |
|
|
public virtual async Task<AggregateReRouteConfigDto> AddRouteConfigAsync(AggregateReRouteConfigCreateDto input) |
|
|
{ |
|
|
{ |
|
|
var routeId = long.Parse(aggregateReRouteConfigCreate.RouteId); |
|
|
var routeId = long.Parse(input.RouteId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
aggregateRoute.RemoveReRouteConfig(aggregateReRouteConfigCreate.ReRouteKey) |
|
|
aggregateRoute.RemoveReRouteConfig(input.ReRouteKey) |
|
|
.AddReRouteConfig(aggregateReRouteConfigCreate.ReRouteKey, aggregateReRouteConfigCreate.Parameter, |
|
|
.AddReRouteConfig(input.ReRouteKey, input.Parameter, |
|
|
aggregateReRouteConfigCreate.JsonPath); |
|
|
input.JsonPath); |
|
|
var aggregateRouteConfig = aggregateRoute.FindReRouteConfig(aggregateReRouteConfigCreate.ReRouteKey); |
|
|
var aggregateRouteConfig = aggregateRoute.FindReRouteConfig(input.ReRouteKey); |
|
|
|
|
|
|
|
|
await _aggregateReRouteRepository.UpdateAsync(aggregateRoute); |
|
|
await _aggregateReRouteRepository.UpdateAsync(aggregateRoute); |
|
|
|
|
|
|
|
|
@ -137,11 +137,11 @@ namespace LINGYUN.ApiGateway.Ocelot |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.ManageRouteConfig)] |
|
|
[Authorize(ApiGatewayPermissions.AggregateRoute.ManageRouteConfig)] |
|
|
public virtual async Task DeleteRouteConfigAsync(AggregateReRouteConfigGetByKeyInputDto aggregateReRouteConfigGetByKey) |
|
|
public virtual async Task DeleteRouteConfigAsync(AggregateReRouteConfigGetByKeyInputDto input) |
|
|
{ |
|
|
{ |
|
|
var routeId = long.Parse(aggregateReRouteConfigGetByKey.RouteId); |
|
|
var routeId = long.Parse(input.RouteId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
var aggregateRoute = await _aggregateReRouteRepository.GetByRouteIdAsync(routeId); |
|
|
aggregateRoute.RemoveReRouteConfig(aggregateReRouteConfigGetByKey.ReRouteKey); |
|
|
aggregateRoute.RemoveReRouteConfig(input.ReRouteKey); |
|
|
|
|
|
|
|
|
await _aggregateReRouteRepository.UpdateAsync(aggregateRoute); |
|
|
await _aggregateReRouteRepository.UpdateAsync(aggregateRoute); |
|
|
|
|
|
|
|
|
|