Skip to content

feat(client): 新增 JmApiClient#getPromoteList 方法、完善 JmApiClient#getPromote 方法 - #10

Merged
JUKOMU merged 3 commits into
masterfrom
dev
Jul 13, 2026
Merged

feat(client): 新增 JmApiClient#getPromoteList 方法、完善 JmApiClient#getPromote 方法#10
JUKOMU merged 3 commits into
masterfrom
dev

Conversation

@JUKOMU

@JUKOMU JUKOMU commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • 新功能
    • 首页推荐现在可获取“推荐分类”列表,并支持按分类类型分页加载对应内容。
  • 变更
    • 推荐接口返回结构从原先的原始数据改为推荐分类列表;新增统一的分页结果返回。
    • “最新上架”解析逻辑与“推荐/推广”解析彻底分离,分页口径随之调整。
  • 说明
    • 不支持推荐能力的客户端会明确提示该能力不可用。

@JUKOMU JUKOMU self-assigned this Jul 13, 2026
@JUKOMU JUKOMU added the enhancement New feature or request label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

首页推荐接口改为返回推荐分类列表,并新增按分类分页获取内容的方法;API 客户端根据分类类型请求不同数据源,解析器同步支持分类与分页响应,HTML 客户端保留不支持状态。

Changes

首页推荐接口

Layer / File(s) Summary
推荐接口契约与数据模型
jmcomic-api/.../JmClient.java, jmcomic-api/.../JmPromoteCategory.java
getPromote() 返回 List<JmPromoteCategory>,新增 getPromoteList(category, page) 返回 JmSearchPage,并新增推荐分类记录模型及 getX 访问器。
响应解析
jmcomic-core/.../ApiParser.java
新增最新列表、推荐分类及推荐分页列表解析逻辑,兼容数字或字符串形式的 total
客户端实现与能力边界
jmcomic-core/.../JmApiClient.java, jmcomic-core/.../JmHtmlClient.java
API 客户端按分类类型请求推广、分类或搜索数据;HTML 客户端实现新签名并继续抛出不支持异常。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JmClient
  participant JmApiClient
  participant ApiParser
  JmClient->>JmApiClient: getPromote()
  JmApiClient->>ApiParser: parsePromote(response)
  ApiParser-->>JmApiClient: List<JmPromoteCategory>
  JmClient->>JmApiClient: getPromoteList(category, page)
  JmApiClient->>ApiParser: parsePromoteList(response, page)
  ApiParser-->>JmApiClient: JmSearchPage
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次对 JmApiClient 的推荐接口调整,且与主要变更一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/parser/ApiParser.java (1)

546-548: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

异常信息文案未同步更新

方法已从 parseLatestOrPromoteList 重命名/收窄为仅处理 latest 的 parseLatestList,但捕获异常时的提示信息仍写作 "Failed to parse latest/promote list API JSON",与新语义不符,容易在排查问题时产生误导。

✏️ 建议的修复
         } catch (Exception e) {
-            throw new ParseResponseException("Failed to parse latest/promote list API JSON", e);
+            throw new ParseResponseException("Failed to parse latest list API JSON", e);
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/parser/ApiParser.java`
around lines 546 - 548, 更新 ApiParser 中 parseLatestList 的异常提示文案,将 “latest/promote
list” 改为仅描述 latest list,保持异常类型、原因链和其他错误处理逻辑不变。
🧹 Nitpick comments (2)
jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/client/JmClient.java (1)

317-324: 📐 Maintainability & Code Quality | 🔵 Trivial

建议补充 getPromoteList 的异常说明

JmApiClient 的实现看,当 category.getType() 为未知类型,或 category_id 类型的 slug 无法映射到已知分类时,会抛出 UnsupportedOperationException。接口 Javadoc 目前未提及这一行为,建议补充 @throws 说明,方便调用方在不查看具体实现的情况下了解该方法的边界情况。

📝 建议的文档补充
     /**
      * 获取首页推荐栏分类详情(分页)
      *
      * `@param` category 推荐栏分类
      * `@param` page     页码(从1开始)
      * `@return` 分页结果
+     * `@throws` UnsupportedOperationException 若分类类型不受支持,或分类的 slug 无法解析
      */
     JmSearchPage getPromoteList(JmPromoteCategory category, int page);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/client/JmClient.java`
around lines 317 - 324, Update the Javadoc for JmClient.getPromoteList to add an
`@throws` UnsupportedOperationException entry describing that it is raised when
the category type is unknown or a category_id slug cannot be mapped to a
supported category.
jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/client/impl/JmApiClient.java (1)

730-771: 📐 Maintainability & Code Quality | 🔵 Trivial

建议用枚举/常量替代裸字符串分支

switch 直接匹配 "promote""category_id""not_in_category_id" 字符串字面量。这类魔法字符串一旦与解析层(ApiParser.parsePromotetype 字段的取值)出现拼写不一致或后续新增类型时,只能在运行期落入 default 抛出 UnsupportedOperationException,而非编译期发现。建议为这些取值定义常量或枚举,集中管理并配合解析层复用。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/client/impl/JmApiClient.java`
around lines 730 - 771, 将 getPromoteList 中基于字符串字面量的分支改为使用统一定义的常量或枚举,并让
ApiParser.parsePromote 复用同一组类型值。集中管理 promote、category_id 和 not_in_category_id,更新
switch 的匹配逻辑,保留现有各分支行为及未知类型抛出 UnsupportedOperationException 的处理。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/parser/ApiParser.java`:
- Around line 546-548: 更新 ApiParser 中 parseLatestList 的异常提示文案,将 “latest/promote
list” 改为仅描述 latest list,保持异常类型、原因链和其他错误处理逻辑不变。

---

Nitpick comments:
In `@jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/client/JmClient.java`:
- Around line 317-324: Update the Javadoc for JmClient.getPromoteList to add an
`@throws` UnsupportedOperationException entry describing that it is raised when
the category type is unknown or a category_id slug cannot be mapped to a
supported category.

In
`@jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/client/impl/JmApiClient.java`:
- Around line 730-771: 将 getPromoteList 中基于字符串字面量的分支改为使用统一定义的常量或枚举,并让
ApiParser.parsePromote 复用同一组类型值。集中管理 promote、category_id 和 not_in_category_id,更新
switch 的匹配逻辑,保留现有各分支行为及未知类型抛出 UnsupportedOperationException 的处理。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a2150ccb-ec08-4fc8-a153-436a3bc98a1a

📥 Commits

Reviewing files that changed from the base of the PR and between 9760a96 and d73401b.

📒 Files selected for processing (4)
  • jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/client/JmClient.java
  • jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/client/impl/JmApiClient.java
  • jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/client/impl/JmHtmlClient.java
  • jmcomic-core/src/main/java/io/github/jukomu/jmcomic/core/parser/ApiParser.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/model/JmPromoteCategory.java (1)

34-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

避免使用原始 Map 类型。

List<Map> 丢失键和值的类型信息,会削弱编译期检查并引入 unchecked 操作。至少改为 List<Map<String, Object>>;如果不同 type 的内容结构稳定,建议进一步定义对应的 DTO,并同步确认解析器的反序列化类型。

建议修改
-        List<Map> content
+        List<Map<String, Object>> content
...
-    public List<Map> getContent() {
+    public List<Map<String, Object>> getContent() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/model/JmPromoteCategory.java`
around lines 34 - 36, Update the content field in JmPromoteCategory from raw
List<Map> to a parameterized map type, at minimum List<Map<String, Object>>, to
preserve key/value type information and eliminate unchecked usage. If the
content structures for each type are stable, use appropriate DTOs and update the
parser’s deserialization types accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/model/JmPromoteCategory.java`:
- Around line 34-36: Update the content field in JmPromoteCategory from raw
List<Map> to a parameterized map type, at minimum List<Map<String, Object>>, to
preserve key/value type information and eliminate unchecked usage. If the
content structures for each type are stable, use appropriate DTOs and update the
parser’s deserialization types accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5684ff86-dfd8-4ae4-b978-7e419f898830

📥 Commits

Reviewing files that changed from the base of the PR and between affd175 and a166347.

📒 Files selected for processing (1)
  • jmcomic-api/src/main/java/io/github/jukomu/jmcomic/api/model/JmPromoteCategory.java

@JUKOMU
JUKOMU merged commit 1a329f3 into master Jul 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

完善 JmApiClient#getPromote 方法,增加 JmApiClient#getPromoteList 方法

1 participant