Skip to content

Commit

Permalink
refactor(Consumer): Spelling error in attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
youngzil committed Nov 17, 2024
1 parent 826ea74 commit 9e2c4e8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static BadRequestException orgIdIsBlank() {
}

public static BadRequestException rateLimitIsInvalid() {
return new BadRequestException("Ratelimit must be greater than 1");
return new BadRequestException("rate limit must be greater than 1");
}

public static BadRequestException itemAlreadyExists(String itemKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public Consumer createConsumer(Consumer consumer) {

public ConsumerToken generateAndSaveConsumerToken(Consumer consumer, Integer rateLimit, Date expires) {
Preconditions.checkArgument(consumer != null, "Consumer can not be null");
Preconditions.checkArgument(rateLimit != null && rateLimit >= 0, "Rate limit must be non-negative");

ConsumerToken consumerToken = generateConsumerToken(consumer, rateLimit, expires);
consumerToken.setId(0);
Expand Down Expand Up @@ -322,6 +323,10 @@ private ConsumerToken generateConsumerToken(Consumer consumer, Integer rateLimit
String createdBy = userInfoHolder.getUser().getUserId();
Date createdTime = new Date();

if (rateLimit == null || rateLimit < 0) {
rateLimit = 0;
}

ConsumerToken consumerToken = new ConsumerToken();
consumerToken.setConsumerId(consumerId);
consumerToken.setRateLimit(rateLimit);
Expand Down Expand Up @@ -353,7 +358,7 @@ String generateToken(String consumerAppId, Date generationTime, String consumerT
(generationTime), consumerTokenSalt), Charsets.UTF_8).toString();
}

ConsumerRole createConsumerRole(Long consumerId, Long roleId, String operator) {
ConsumerRole createConsumerRole(Long consumerId, Long roleId, String operator) {
ConsumerRole consumerRole = new ConsumerRole();

consumerRole.setConsumerId(consumerId);
Expand Down Expand Up @@ -392,7 +397,7 @@ private Set<String> findAppIdsByRoleIds(List<Long> roleIds) {
return appIds;
}

List<Consumer> findAllConsumer(Pageable page){
List<Consumer> findAllConsumer(Pageable page) {
return this.consumerRepository.findAll(page).getContent();
}

Expand All @@ -417,7 +422,7 @@ public List<ConsumerInfo> findConsumerInfoList(Pageable page) {
}

@Transactional
public void deleteConsumer(String appId){
public void deleteConsumer(String appId) {
Consumer consumer = consumerRepository.findByAppId(appId);
if (consumer == null) {
throw new BadRequestException("ConsumerApp not exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public ConsumerInfo create(
throw BadRequestException.orgIdIsBlank();
}

if (requestVO.isRateLimitEenabled()) {
if (requestVO.isRateLimitEnabled()) {
if (requestVO.getRateLimit() <= 0) {
throw BadRequestException.rateLimitIsInvalid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ConsumerCreateRequestVO {
private String orgId;
private String orgName;
private String ownerName;
private boolean rateLimitEenabled;
private boolean rateLimitEnabled;
private int rateLimit;

public String getAppId() {
Expand Down Expand Up @@ -77,12 +77,12 @@ public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}

public boolean isRateLimitEenabled() {
return rateLimitEenabled;
public boolean isRateLimitEnabled() {
return rateLimitEnabled;
}

public void setRateLimitEenabled(boolean rateLimitEenabled) {
this.rateLimitEenabled = rateLimitEenabled;
public void setRateLimitEnabled(boolean rateLimitEnabled) {
this.rateLimitEnabled = rateLimitEnabled;
}

public int getRateLimit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ <h5>{{'Open.Manage.CreateThirdApp' | translate }}
</label>
<div class="col-sm-3">
<input type="checkbox"
ng-model="consumer.rateLimitEenabled"
name="rateLimitEenabled"
ng-change="toggleRateLimitEenabledInput()"
ng-model="consumer.rateLimitEnabled"
name="rateLimitEnabled"
ng-change="toggleRateLimitEnabledInput()"
/>
<small>{{ 'Open.Manage.Consumer.RateLimit.Enabled.Tips' | translate }}</small>
</div>
</div>

<div class="form-group" ng-show="consumer.rateLimitEenabled">
<div class="form-group" ng-show="consumer.rateLimitEnabled">
<label class="col-sm-2 control-label">
{{ 'Open.Manage.Consumer.RateLimitValue' | translate }}
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function OpenManageController($scope, $translate, toastr, AppUtil, OrganizationS
$scope.preDeleteConsumer = preDeleteConsumer;
$scope.deleteConsumer = deleteConsumer;
$scope.preGrantPermission = preGrantPermission;
$scope.toggleRateLimitEenabledInput = function() {
if (!$scope.consumer.rateLimitEenabled) {
$scope.toggleRateLimitEnabledInput = function() {
if (!$scope.consumer.rateLimitEnabled) {
$scope.consumer.rateLimit = 0;
}
};
Expand Down Expand Up @@ -169,7 +169,7 @@ function OpenManageController($scope, $translate, toastr, AppUtil, OrganizationS
return;
}

if ($scope.consumer.rateLimitEenabled) {
if ($scope.consumer.rateLimitEnabled) {
if ($scope.consumer.rateLimit < 1) {
toastr.warning($translate.instant('Open.Manage.Consumer.RateLimitValue.Error'));
$scope.submitBtnDisabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public class NamespaceControllerTest extends AbstractControllerTest {

static final HttpHeaders HTTP_HEADERS_WITH_TOKEN = new HttpHeaders() {{
set(HttpHeaders.AUTHORIZATION, "3c16bf5b1f44b465179253442460e8c0ad845289");
set(HttpHeaders.AUTHORIZATION, "test-token");
}};
@Autowired
private ConsumerPermissionValidator consumerPermissionValidator;
Expand Down

0 comments on commit 9e2c4e8

Please sign in to comment.