Skip to content

新增附件查询接口#151

Merged
xezzon merged 4 commits intodevelopfrom
feature/attachment
Feb 5, 2026
Merged

新增附件查询接口#151
xezzon merged 4 commits intodevelopfrom
feature/attachment

Conversation

@xezzon
Copy link
Owner

@xezzon xezzon commented Feb 5, 2026

Pull Request Checklist

  • base分支是 develop
  • 选择合适的标签(单选) feature/bug/refactor/document
  • 关联 issue。
  • 代码经过了格式化。
  • 没有引入编译警告。
  • 功能已完成。

Description

Code Review Checklist

  • 已通过单元测试与 SAST。(由 CI 自动完成)
  • 满足需求规格说明书中的功能性需求、非功能性需求。
  • 文档已更新。
    • 详细设计文档
    • 代码注释
  • 对外接口保持兼容。
  • 代码风格与现有代码一致。
  • 不存在的安全风险、性能风险。
  • 没有引入不受信任的依赖。
  • Code Review 后,审批或驳回 PR。

Summary by CodeRabbit

  • New Features

    • Added API endpoints to retrieve individual attachments by ID and to query paginated attachment lists.
    • Enhanced file downloads to include filename metadata.
  • Tests

    • Added tests for attachment retrieval by ID and for paginated listing, plus lifecycle cleanup to ensure isolation.

@xezzon xezzon added the feature New feature or request label Feb 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds pagination and single-item retrieval for attachments: Attachment now implements IEntity, a new AttachmentDAO is introduced, service and HTTP endpoints for querying by ID and paginated results are added, DownloadEndpoint gains a filename setter, and tests for the new endpoints were added/updated.

Changes

Cohort / File(s) Summary
Entity
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/Attachment.java
Attachment now implements IEntity<String>; import and class signature updated.
DAO
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentDAO.java
New AttachmentDAO class added, annotated @Repository, extends BaseDAO<Attachment, String, AttachmentRepository> and injects AttachmentRepository.
HTTP Endpoints
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentHttpEndpoint.java
Added queryById(String id) (GET /attachment/{id}) and queryPage(ODataRequestParam odata) (GET /attachment/page, @SaCheckPermission).
Service Layer
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentService.java
Injected AttachmentDAO via constructor; added queryPage(ODataQueryOption) delegating to DAO; getDownloadEndpoint now sets filename from attachment.
Storage / Download
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/storage/DownloadEndpoint.java
Added private String filename with Lombok-generated setter to allow setting download filename.
Tests
zeroweb-service/zeroweb-service-file/src/test/java/io/github/xezzon/zeroweb/attachment/AttachmentHttpTest.java
Added queryById and queryPage tests, updated setup/teardown (marking upload DONE, clearing state), and added imports for paged assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HttpEndpoint as "AttachmentHttpEndpoint"
    participant Service as "AttachmentService"
    participant DAO as "AttachmentDAO"
    participant Repo as "AttachmentRepository/DB"

    Client->>HttpEndpoint: GET /attachment/{id} or /attachment/page
    HttpEndpoint->>Service: queryById(id) / queryPage(odata)
    Service->>DAO: findById(id) / findAll(odata)
    DAO->>Repo: JPA query / repository call
    Repo-->>DAO: Attachment or Page<Attachment>
    DAO-->>Service: result
    Service-->>HttpEndpoint: Attachment or Page<Attachment> (DownloadEndpoint filename set for downloads)
    HttpEndpoint-->>Client: HTTP 200 with payload
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through code with eager cheer,

New DAO burrows, pages near,
By ID or page I fetch and bring,
A filename tied to every fling,
Hooray—attachments dance and sing! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description follows the required template structure with checklist items, but the 'Description' section is completely empty, leaving no explanation of what was implemented, why it was needed, or any implementation details. Fill in the 'Description' section with details about the new attachment query interfaces, their purpose, and any relevant implementation notes or design decisions.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title '新增附件查询接口' (Add attachment query interface) clearly and concisely describes the main change: introducing new query endpoints for attachments, which aligns with the substantial changes across multiple files including queryById and queryPage endpoints.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/attachment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentService.java (1)

154-162: ⚠️ Potential issue | 🟡 Minor

Document that the download endpoint now includes filename.
The method now enriches the response, so the return doc should mention the filename to avoid surprises.

📝 Suggested update
-  /// `@return` 下载访问点信息,包含下载URL和相关参数
+  /// `@return` 下载访问点信息,包含下载URL和文件名等参数
As per coding guidelines, Include explanatory comments for information that cannot be expressed through code alone, such as field units and non-obvious details.
🤖 Fix all issues with AI agents
In
`@zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentDAO.java`:
- Around line 21-25: Replace the traditional Javadoc block above the
AttachmentDAO class with the project's preferred triple-slash style: remove the
/** ... */ block and add a line (or lines) starting with /// directly above the
class declaration for AttachmentDAO (which extends BaseDAO<Attachment, String,
AttachmentRepository>), ensuring any author or summary text from the original
Javadoc is preserved in the new /// comment format.

In
`@zeroweb-service/zeroweb-service-file/src/main/java/io/github/xezzon/zeroweb/attachment/internal/AttachmentHttpEndpoint.java`:
- Around line 157-166: Replace the Javadoc block above the queryPage method in
AttachmentHttpEndpoint with a triple-slash (///) documentation comment, and
include a short usage example showing how to call the paging endpoint (e.g.,
HTTP GET to "/page" with OData query params or an SDK call that constructs
ODataRequestParam and passes it to queryPage) and the expected return type
Page<Attachment>; ensure the doc references the method name queryPage, parameter
ODataRequestParam, and return type Page<Attachment> so external consumers and
SDK users can see how to invoke and parse results.
- Around line 132-139: Update the queryById documentation to use triple-slash
style comments (///) and include a short usage example (e.g., "GET
/attachments/{id}" with expected response shape) above the method, and add
javax.validation.constraints.NotBlank to the id method parameter in
AttachmentHttpEndpoint.queryById (i.e., change the signature to annotate the
`@PathVariable` String id with `@NotBlank`); also ensure the controller class
AttachmentHttpEndpoint is annotated with
org.springframework.validation.annotation.Validated (or validation is otherwise
enabled) and import NotBlank so the parameter validation is active.
🧹 Nitpick comments (1)
zeroweb-service/zeroweb-service-file/src/test/java/io/github/xezzon/zeroweb/attachment/AttachmentHttpTest.java (1)

167-175: Clear largeFileParts in teardown to avoid accumulation across tests.

♻️ Suggested change
   `@AfterEach`
   void tearDown() {
     repository.deleteAll();
+    largeFileParts.clear();
   }

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

@xezzon xezzon merged commit 6ab9bf9 into develop Feb 5, 2026
9 checks passed
@xezzon xezzon deleted the feature/attachment branch February 5, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants