Closed youngzil closed 1 month ago
The changes introduced involve modifications to the ItemController
, BizConfig
, ItemRepository
, ItemService
, and ItemSetService
classes. Key updates include the addition of a new dependency on BizConfig
, which enforces item count limits during item creation and updates. New methods for counting non-empty items and validating item limits have been added, enhancing the functionality and integrity of item management within the application.
Files | Change Summary |
---|---|
.../controller/ItemController.java , .../service/ItemSetService.java |
Added dependency on BizConfig and modified constructors. Updated methods to enforce item count limits, throwing BadRequestException if limits are exceeded. |
.../config/BizConfig.java |
Introduced a constant for default item limits and methods to retrieve and validate the item count limit from configuration. |
.../repository/ItemRepository.java |
Added a method to count items based on namespaceId and non-empty keys, enhancing data retrieval capabilities. |
.../service/ItemService.java |
Introduced a method to count non-empty items for a specified namespace, utilizing the repository for data access. |
.../test/service/ItemSetServiceTest.java |
Added unit tests for ItemSetService to validate item count limit enforcement under various configurations. |
.../test/resources/sql/itemset-test.sql |
Introduced SQL script for testing, including insert statements for Namespace and Item tables. |
.../portal/apollo-user-guide.md , .../zh/portal/apollo-user-guide.md |
Updated user guides to include new sections on item limits and security practices, enhancing clarity and usability. |
sequenceDiagram
participant User
participant ItemController
participant ItemService
participant BizConfig
User->>ItemController: createItem()
ItemController->>BizConfig: get itemNumLimit()
BizConfig-->>ItemController: return limit
ItemController->>ItemService: findNonEmptyItemCount(namespaceId)
ItemService-->>ItemController: return count
ItemController->>ItemController: validate count against limit
ItemController-->>User: BadRequestException if limit exceeded
ItemController-->>User: Item created successfully if valid
BizConfig
to manage namespace limits, which is directly related to the changes in the ItemController
that enforce item count limits based on BizConfig
.🐇 In the garden of code, changes bloom bright,
With limits now set, all feels just right.
BizConfig stands tall, a guardian so wise,
Counting the items, beneath sunny skies.
A hop and a skip, through logic we prance,
In this code-filled meadow, we joyfully dance! 🌼
Duplicated with #5228
Would you please fix the unit test error?
Would you please fix the unit test error?
@nobodyiam I have fixed this unit test, please review it again
What's the purpose of this PR
Added a new parameter
item.num.limit
,the purpose is to limit the number of configuration items in the same namespaceIn actual use, when modifying configurations in batches, if the number of configurations exceeds a certain value, it is easy to trigger a timeout or page crash.
Which issue(s) this PR fixes:
Fixes #
Brief changelog
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.Summary by CodeRabbit
New Features
Bug Fixes
Documentation