Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Provide a new open APl to return the organization list(#5349) #5365

Merged
merged 9 commits into from
Mar 30, 2025

Conversation

wjwang00
Copy link
Contributor

@wjwang00 wjwang00 commented Mar 25, 2025

What's the purpose of this PR

feat: Provide a new open APl to return the organization list(#5349)

Which issue(s) this PR fixes:

#5349

Brief changelog

After updating the project, we can use this method like this way:

       String portalUrl = "http://localhost:8070"; // portal url
        String token = "25e545146773469d1b9874339849487dc89f28e6d6e0dbd75a1664cca3bb1ada"; // 申请的token
        ApolloOpenApiClient client = ApolloOpenApiClient.newBuilder()
                .withPortalUrl(portalUrl)
                .withToken(token)
                .build();
        client.getOrganization().forEach(System.out::println);

PixPin_2025-03-25_22-07-06

Summary by CodeRabbit

  • New Features

    • Introduced a new REST endpoint that enables retrieval of organization details.
    • Added new methods for transforming organization data into a more usable format.
    • Documented the addition of an API that returns the organization list.
  • Chores

    • Upgraded the underlying platform dependency to a newer snapshot version for improved performance and stability.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 25, 2025
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request introduces new API functionality for managing organization data. A service class and a REST controller are added to retrieve organization information. Utility methods are also provided to transform organization entities into DTOs, and redundant import statements are removed from the utility class. Additionally, the dependency version for apollo-java is updated in the pom.xml file.

Changes

File(s) Change Summary
apollo-portal/src/main/java/com/ctrip/framework/apollo/.../ServerOrganizationOpenApiService.java
apollo-portal/src/main/java/com/ctrip/framework/apollo/.../OrganizationController.java
Added new service and controller classes for organization APIs. The service implements the OrganizationOpenApiService interface and the controller exposes a REST endpoint to retrieve organizations.
apollo-portal/src/main/java/com/ctrip/framework/apollo/.../OpenApiBeanUtils.java Added methods transformFromOrganization and transformFromOrganizations to convert organization entities to DTOs; removed unused import statements.
pom.xml Updated the apollo-java dependency version from 2.4.0 to 2.5.0-SNAPSHOT.
CHANGES.md Added a new feature entry for the API that returns the organization list.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant C as Client
    participant OC as OrganizationController
    participant SO as ServerOrganizationOpenApiService
    participant PC as PortalConfig
    participant U as OpenApiBeanUtils

    C->>OC: GET /openapi/v1/organizations
    OC->>SO: getOrganizations()
    SO->>PC: organizations()
    PC-->>SO: List<Organization>
    SO->>U: transformFromOrganizations(List<Organization>)
    U-->>SO: List<OpenOrganizationDto>
    SO-->>OC: List<OpenOrganizationDto>
    OC-->>C: List<OpenOrganizationDto>

Suggested labels

size:M

Poem

Hoppin' along in the code forest green,
I found fresh changes, shiny and serene!
New services sprout and controllers bloom,
Transforming data—oh what a room!
Cheers from this rabbit, spreading joy in every byte! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff7b64 and dc93da8.

📒 Files selected for processing (1)
  • CHANGES.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGES.md

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 25, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/OrganizationController.java (1)

35-38: Method can be improved for RESTful clarity.

The method name is singular (getOrganization) but returns a list of organizations. Consider these improvements:

-@RequestMapping("/organizations")
-public List<OpenOrganizationDto> getOrganization() {
+@GetMapping("/organizations")
+public List<OpenOrganizationDto> getOrganizations() {
    return organizationOpenApiService.getOrganizations();
}

This change:

  1. Uses @GetMapping to explicitly specify HTTP GET method
  2. Renames the method to plural form to match the return type
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09e02fb and 4bf7564.

📒 Files selected for processing (4)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerOrganizationOpenApiService.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java (2 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/OrganizationController.java (1 hunks)
  • pom.xml (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerOrganizationOpenApiService.java (1)
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java (1)
  • OpenApiBeanUtils (54-204)
🔇 Additional comments (5)
pom.xml (1)

66-66:

✅ Verification successful

Version dependency updated to match new features.

The apollo-java.version has been updated to 2.5.0-SNAPSHOT to align with the new organization API functionality being introduced. Using a SNAPSHOT version implies this is development code that may change.


🏁 Script executed:

#!/bin/bash
# Check if this version is consistent with the project version
grep -n "<revision>" pom.xml

Length of output: 71


Consistent Version Update in pom.xml

The <apollo-java.version> has been correctly updated to 2.5.0-SNAPSHOT in line 66, which matches the project <revision> at line 63. This confirms that the dependency update aligns with the new organization API functionality requirements. No further changes are required.

apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerOrganizationOpenApiService.java (1)

25-37: Implementation looks good.

The service correctly implements the OrganizationOpenApiService interface, uses constructor injection for dependencies, and properly delegates to the utility method for transforming organizations to DTOs.

apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/OrganizationController.java (1)

25-32: Controller implementation follows best practices.

The controller uses constructor injection and provides a descriptive bean name to avoid conflicts.

apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java (2)

27-37: Improved import organization.

The imports have been consolidated by removing redundant individual imports for DTO classes.


194-203: Well-implemented utility methods.

The new transformation methods:

  1. Follow the same pattern as existing transformation methods in the class
  2. Properly handle null/empty collections
  3. Use precondition checks to validate inputs
  4. Leverage Java 8 streams for efficient transformation

The implementation is consistent with the coding style of the rest of the class.

@wjwang00
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the CHANGES.md.

wjwang00 and others added 5 commits March 29, 2025 11:01
…/server/service/ServerOrganizationOpenApiService.java

Co-authored-by: Jason Song <nobodyiam@gmail.com>
…/util/OpenApiBeanUtils.java

Co-authored-by: Jason Song <nobodyiam@gmail.com>
…/v1/controller/OrganizationController.java

Co-authored-by: Jason Song <nobodyiam@gmail.com>
…/util/OpenApiBeanUtils.java

Co-authored-by: Jason Song <nobodyiam@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
CHANGES.md (1)

10-10: Fix Typographical Error in Feature Description

The new feature entry on line 10 incorrectly spells "API" as "APl". Please update the entry to correct this typographical error for clarity and consistency with the intended messaging.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf7564 and cbf83c0.

📒 Files selected for processing (4)
  • CHANGES.md (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerOrganizationOpenApiService.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java (2 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/OrganizationController.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerOrganizationOpenApiService.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/OrganizationController.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java

@wjwang00
Copy link
Contributor Author

Please also update the CHANGES.md.

Thank you for your review and suggestions. I have updated the CHANGES.md and applied all the Commit suggestions.

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 30, 2025
@nobodyiam nobodyiam merged commit 7380bde into apolloconfig:master Mar 30, 2025
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants