Skip to content

Commit

Permalink
feat(openapi): Added consumer rate limit query function and optimized…
Browse files Browse the repository at this point in the history
… related display
  • Loading branch information
youngzil committed Nov 26, 2024
1 parent 0fe67f5 commit 5390f62
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.ctrip.framework.apollo.openapi.entity.ConsumerToken;

import java.util.List;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;
Expand All @@ -35,4 +36,7 @@ public interface ConsumerTokenRepository extends PagingAndSortingRepository<Cons
ConsumerToken findTopByTokenAndExpiresAfter(String token, Date validDate);

ConsumerToken findByConsumerId(Long consumerId);

List<ConsumerToken> findByConsumerIdIn(List<Long> consumerIds);

}
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,13 @@ private List<Boolean> isAllowCreateApplication(List<Long> consumerIdList) {
return list;
}

private List<Integer> getRateLimit(List<Long> consumerIdList) {
List<Integer> list = new ArrayList<>(consumerIdList.size());
for (Long consumerId : consumerIdList) {
ConsumerToken consumerToken = consumerTokenRepository.findByConsumerId(consumerId);
private List<Integer> getRateLimit(List<Long> consumerIds) {
List<Integer> list = new ArrayList<>(consumerIds.size());
List<ConsumerToken> consumerTokens = consumerTokenRepository.findByConsumerIdIn(consumerIds);
for (ConsumerToken consumerToken : consumerTokens) {
Integer rateLimit = consumerToken != null ? consumerToken.getRateLimit() : 0;
list.add(rateLimit);
}

return list;
}

Expand Down
1 change: 1 addition & 0 deletions apollo-portal/src/main/resources/static/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@
"Open.Manage.Consumer.RateLimitValue": "Rate limiting QPS",
"Open.Manage.Consumer.RateLimitValueTips": "(Unit: times/second, for example: 100 means that the configuration is published at most 100 times per second)",
"Open.Manage.Consumer.RateLimitValue.Error": "The minimum rate limiting QPS is 1",
"Open.Manage.Consumer.RateLimitValue.Display": "Unlimited",
"Namespace.Role.Title": "Permission Management",
"Namespace.Role.GrantModifyTo": "Permission to edit",
"Namespace.Role.GrantModifyTo2": "(Can edit the configuration)",
Expand Down
1 change: 1 addition & 0 deletions apollo-portal/src/main/resources/static/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@
"Open.Manage.Consumer.RateLimitValue": "限流QPS",
"Open.Manage.Consumer.RateLimitValueTips": "(单位:次/秒,例如: 100 表示每秒最多发布 100 次配置)",
"Open.Manage.Consumer.RateLimitValue.Error": "限流QPS最小为1",
"Open.Manage.Consumer.RateLimitValue.Display": "无限制",
"Namespace.Role.Title": "权限管理",
"Namespace.Role.GrantModifyTo": "修改权",
"Namespace.Role.GrantModifyTo2": "(可以修改配置)",
Expand Down
5 changes: 3 additions & 2 deletions apollo-portal/src/main/resources/static/open/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ <h5>{{'Open.Manage.CreateThirdApp' | translate }}
{{'Open.Manage.Consumer.AllowCreateApplication.No' | translate}}
</div>
</td>
<td style="width: 10%">{{ consumer.rateLimit }}</td>

<td style="width: 10%">
{{ consumer.rateLimit && consumer.rateLimit > 0 ? consumer.rateLimit : 'Open.Manage.Consumer.RateLimitValue.Display' | translate }}
</td>
<td style="width: 15%">{{ consumer.orgName + '(' + consumer.orgId + ')' }}</td>
<td style="width: 20%"><b>{{ consumer.ownerName }}</b>/{{ consumer.ownerEmail }}</td>
<td style="width: 20%;">
Expand Down

0 comments on commit 5390f62

Please sign in to comment.