Skip to content

Conversation

Menci
Copy link
Contributor

@Menci Menci commented Sep 16, 2025

Sourcery 总结

重构 Fedy 集成,使其使用基于卡的數據管理和事件通知,引入新的數據拉取/推送和卡片管理端點,並移除舊的用戶鏈接實現。

新功能:

  • 添加 /data/pull/data/push 端點,用於通過卡片 ID 進行外部遊戲數據同步
  • 引入 /card/resolve/card/link/card/unlink 存根端點,用於卡片生命週期管理
  • 定義新的 Fedy 事件,用於卡片創建、鏈接、解除鏈接和數據更新,以通知下游服務

改進:

  • 重構 Fedy 以使用 CardRepository 和外部卡片 ID,而不是 AquaNetUser 鏈接
  • CardControllerFrontierAimeDB 和遊戲導入控制器中,於卡片創建、鏈接、解除鏈接和數據更新時觸發 Fedy 事件
  • 將遊戲導入/導出操作切換到基於卡的上下文,並發送 DataUpdated 事件

日常任務:

  • 移除 AquaNetUserFedy 實體並刪除其數據庫表
Original summary in English

Sourcery 总结

全面改进 Fedy 集成以使用基于卡的數據管理:用卡片解析/链接/取消链接和数据拉取/推送端点替换旧的用户链接,发送卡片生命周期和数据更新事件,相应地更新控制器和游戏处理器,并移除旧的 AquaNetUserFedy 实体

新功能:

  • 添加 /data/pull/data/push 端点,用于通过卡片 extId 同步游戏数据
  • 引入 /card/resolve/card/link/card/unlink 端点,用于管理卡片生命周期
  • 定义新的 Fedy 事件 (CardCreatedCardLinkedCardUnlinkedDataUpdated),以通知下游服务

改进:

  • 重构 Fedy 服务,以使用 CardRepository 和外部卡片 ID,而不是 AquaNetUser 链接
  • 更新导入/导出控制器和游戏处理器,以操作卡片实体并触发 DataUpdated 事件
  • CardControllerFrontierAimeDB 中,在卡片创建、链接和取消链接时发送 Fedy 事件
  • 增强 CardGameService,以在幽灵卡和活跃卡之间迁移和孤立游戏数据

杂项:

  • 移除 AquaNetUserFedy 实体并删除 aqua_net_user_fedy
Original summary in English

Summary by Sourcery

Overhaul Fedy integration to use card-based data management: replace legacy user linking with card resolve/link/unlink and data pull/push endpoints, emit card lifecycle and data update events, update controllers and game handlers accordingly, and remove the old AquaNetUserFedy entity

New Features:

  • Add /data/pull and /data/push endpoints for syncing game data by card extId
  • Introduce /card/resolve, /card/link, and /card/unlink endpoints for managing card lifecycle
  • Define new Fedy events (CardCreated, CardLinked, CardUnlinked, DataUpdated) to notify downstream services

Enhancements:

  • Refactor Fedy service to use CardRepository and external card IDs instead of AquaNetUser linking
  • Update import/export controllers and game handlers to operate on card entities and trigger DataUpdated events
  • Emit Fedy events in CardController, Frontier, and AimeDB on card creation, linkage, and unlinkage
  • Enhance CardGameService to migrate and orphan game data between ghost and active cards

Chores:

  • Remove AquaNetUserFedy entity and drop the aqua_net_user_fedy table

Copy link
Contributor

sourcery-ai bot commented Sep 16, 2025

审阅者指南

此 PR 将 Fedy 集成从以用户为中心的事件模型重构为以卡片为中心的事件模型,引入了新的数据拉取/推送 API 以及卡片解析/链接/解除链接端点,将这些事件连接到多个控制器中,并移除了过时的 AquaNetUserFedy 逻辑。

通过 Fedy 进行卡片创建事件通知的序列图

sequenceDiagram
    participant Frontier
    participant CardService
    participant Fedy
    participant RemoteService
    Frontier->>CardService: registerByAccessCode(accessCode)
    CardService-->>Frontier: Card
    Frontier->>Fedy: onCardCreated(accessCode, card.extId)
    Fedy->>RemoteService: POST /notify (cardCreated event payload)
Loading

通过 Fedy 进行卡片链接事件通知的序列图

sequenceDiagram
    participant CardController
    participant CardService
    participant Fedy
    participant RemoteService
    CardController->>CardService: registerByAccessCode(cardId, user)
    CardService-->>CardController: Card
    CardController->>Fedy: onCardLinked(newCard.luid, oldExtId, extId, migratedGames)
    Fedy->>RemoteService: POST /notify (cardLinked event payload)
Loading

通过 Fedy 进行卡片解除链接事件通知的序列图

sequenceDiagram
    participant CardController
    participant CardRepository
    participant Fedy
    participant RemoteService
    CardController->>CardRepository: save(card)
    CardController->>Fedy: onCardUnlinked(luid)
    Fedy->>RemoteService: POST /notify (cardUnlinked event payload)
Loading

通过 Fedy 进行数据更新事件通知的序列图

sequenceDiagram
    participant ImportController
    participant Fedy
    participant RemoteService
    ImportController->>Fedy: onDataUpdated(extId, game, removeOldData)
    Fedy->>RemoteService: POST /notify (dataUpdated event payload)
Loading

移除 AquaNetUserFedy 表的 ER 图

erDiagram
    AQUA_NET_USER_FEDY {
        LONG id
        LONG aqua_net_user_id
        DATETIME created_at
    }
    AQUA_NET_USER_FEDY ||--|| AQUA_NET_USER : "aqua_net_user_id references id"
    %% Table AQUA_NET_USER_FEDY is dropped in this PR
Loading

新 Fedy 事件模型和 API 请求/响应类型的类图

classDiagram
    class Fedy {
        +handleDataPull(key: Str, req: DataPullReq): DataPullRes
        +handleDataPush(key: Str, req: DataPushReq): Any
        +handleCardResolve(key: Str, req: CardResolveReq): CardResolveRes
        +handleCardLink(key: Str, req: CardLinkReq): Any
        +handleCardUnlink(key: Str, req: CardUnlinkReq): Any
        +onCardCreated(luid: Str, extId: Long)
        +onCardLinked(luid: Str, oldExtId: Long?, extId: Long, migratedGames: List<Str>)
        +onCardUnlinked(luid: Str)
        +onDataUpdated(extId: Long, game: Str, removeOldData: Bool)
    }
    class CardCreatedEvent {
        +luid: Str
        +extId: Long
    }
    class CardLinkedEvent {
        +luid: Str
        +oldExtId: Long?
        +extId: Long
        +migratedGames: List<Str>
    }
    class CardUnlinkedEvent {
        +luid: Str
    }
    class DataUpdatedEvent {
        +extId: Long
        +game: Str
        +removeOldData: Bool
    }
    class FedyEvent {
        +cardCreated: CardCreatedEvent?
        +cardLinked: CardLinkedEvent?
        +cardUnlinked: CardUnlinkedEvent?
        +dataUpdated: DataUpdatedEvent?
    }
    class DataPullReq {
        +extId: Long
        +game: Str
        +exportOptions: ExportOptions
    }
    class DataPullRes {
        +error: DataPullErr?
        +result: Any?
    }
    class DataPullErr {
        +code: Int
        +message: Str
    }
    class DataPushReq {
        +extId: Long
        +game: Str
        +data: JDict
        +removeOldData: Bool
    }
    class CardResolveReq {
        +luid: Str
        +pairedLuid: Str?
        +createIfNotFound: Bool
    }
    class CardResolveRes {
        +extId: Long
        +isGhost: Bool
        +isNewlyCreated: Bool
        +isPairedLuidDiverged: Bool
    }
    class CardLinkReq {
        +auId: Long
        +luid: Str
    }
    class CardUnlinkReq {
        +auId: Long
        +luid: Str
    }
    FedyEvent --> CardCreatedEvent
    FedyEvent --> CardLinkedEvent
    FedyEvent --> CardUnlinkedEvent
    FedyEvent --> DataUpdatedEvent
    Fedy --> FedyEvent
    Fedy --> DataPullReq
    Fedy --> DataPullRes
    Fedy --> DataPushReq
    Fedy --> CardResolveReq
    Fedy --> CardResolveRes
    Fedy --> CardLinkReq
    Fedy --> CardUnlinkReq
Loading

文件级更改

更改 详情 文件
大修 Fedy 服务以使用以卡片为中心的事件和统一数据 API
  • 将 FedyEvent 枚举替换为包含 cardCreated、cardLinked、cardUnlinked、dataUpdated 字段的数据类
  • 引入 DataPull 和 DataPush 请求/响应模型以及新的 /data/pull 和 /data/push 端点
  • 添加了卡片解析、链接和解除链接的存根端点
  • 重构了 maybeNotifyAsync 和 notify 以将 JSON 负载发送到单个 /notify 端点
  • 将 AquaNetUserFedyRepo 替换为 CardRepository 并移除了遗留的链接/解除链接/状态处理程序
src/main/java/icu/samnyan/aqua/net/Fedy.kt
将 Fedy 事件触发器挂接到控制器和导入流程中
  • 在 CardController 的注册、链接和解除链接操作后调用 fedy.onCardLinked/onCardUnlinked
  • 在新卡片注册时在 Frontier 和 AimeDB 中调用 fedy.onCardCreated
  • 更新 ImportController 和 Maimai2ServletController 以使用基于卡片的导出并调用 fedy.onDataUpdated 而不是 onImported/onUpserted
src/main/java/icu/samnyan/aqua/net/CardController.kt
src/main/java/icu/samnyan/aqua/net/Frontier.kt
src/main/java/icu/samnyan/aqua/net/games/ImportController.kt
src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDB.kt
src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2ServletController.kt
清理遗留的 AquaNetUserFedy 实体和表
  • 移除 AquaNetUserFedy.kt 实体文件
  • 添加 SQL 迁移以删除 aqua_net_user_fedy 表
src/main/java/icu/samnyan/aqua/net/db/AquaNetUserFedy.kt
src/main/resources/db/80/V1000_57__aqua_net_user_fedy_drop.sql

提示和命令

与 Sourcery 互动

  • 触发新审阅: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论,请求 Sourcery 从中创建 issue。您也可以回复审阅评论并加上 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 随时在拉取请求标题的任意位置写入 @sourcery-ai,以生成标题。您也可以在拉取请求上评论 @sourcery-ai title,以随时(重新)生成标题。
  • 生成拉取请求摘要: 随时在拉取请求正文的任意位置写入 @sourcery-ai summary,以在您希望的位置生成 PR 摘要。您也可以在拉取请求上评论 @sourcery-ai summary,以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide,以随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这会很有用。
  • 驳回所有 Sourcery 审阅: 在拉取请求上评论 @sourcery-ai dismiss,以驳回所有现有的 Sourcery 审阅。如果您想重新开始新的审阅,这特别有用——别忘了评论 @sourcery-ai review 来触发新的审阅!

自定义您的体验

访问您的 仪表板 以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅指令。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide

This PR refactors the Fedy integration from a user-centric to a card-centric event model, introducing new data pull/push APIs and card resolve/link/unlink endpoints, wiring those events across multiple controllers, and removing obsolete AquaNetUserFedy logic.

Sequence diagram for card creation event notification via Fedy

sequenceDiagram
    participant Frontier
    participant CardService
    participant Fedy
    participant RemoteService
    Frontier->>CardService: registerByAccessCode(accessCode)
    CardService-->>Frontier: Card
    Frontier->>Fedy: onCardCreated(accessCode, card.extId)
    Fedy->>RemoteService: POST /notify (cardCreated event payload)
Loading

Sequence diagram for card linking event notification via Fedy

sequenceDiagram
    participant CardController
    participant CardService
    participant Fedy
    participant RemoteService
    CardController->>CardService: registerByAccessCode(cardId, user)
    CardService-->>CardController: Card
    CardController->>Fedy: onCardLinked(newCard.luid, oldExtId, extId, migratedGames)
    Fedy->>RemoteService: POST /notify (cardLinked event payload)
Loading

Sequence diagram for card unlinking event notification via Fedy

sequenceDiagram
    participant CardController
    participant CardRepository
    participant Fedy
    participant RemoteService
    CardController->>CardRepository: save(card)
    CardController->>Fedy: onCardUnlinked(luid)
    Fedy->>RemoteService: POST /notify (cardUnlinked event payload)
Loading

Sequence diagram for data update event notification via Fedy

sequenceDiagram
    participant ImportController
    participant Fedy
    participant RemoteService
    ImportController->>Fedy: onDataUpdated(extId, game, removeOldData)
    Fedy->>RemoteService: POST /notify (dataUpdated event payload)
Loading

ER diagram for removal of AquaNetUserFedy table

erDiagram
    AQUA_NET_USER_FEDY {
        LONG id
        LONG aqua_net_user_id
        DATETIME created_at
    }
    AQUA_NET_USER_FEDY ||--|| AQUA_NET_USER : "aqua_net_user_id references id"
    %% Table AQUA_NET_USER_FEDY is dropped in this PR
Loading

Class diagram for new Fedy event model and API request/response types

classDiagram
    class Fedy {
        +handleDataPull(key: Str, req: DataPullReq): DataPullRes
        +handleDataPush(key: Str, req: DataPushReq): Any
        +handleCardResolve(key: Str, req: CardResolveReq): CardResolveRes
        +handleCardLink(key: Str, req: CardLinkReq): Any
        +handleCardUnlink(key: Str, req: CardUnlinkReq): Any
        +onCardCreated(luid: Str, extId: Long)
        +onCardLinked(luid: Str, oldExtId: Long?, extId: Long, migratedGames: List<Str>)
        +onCardUnlinked(luid: Str)
        +onDataUpdated(extId: Long, game: Str, removeOldData: Bool)
    }
    class CardCreatedEvent {
        +luid: Str
        +extId: Long
    }
    class CardLinkedEvent {
        +luid: Str
        +oldExtId: Long?
        +extId: Long
        +migratedGames: List<Str>
    }
    class CardUnlinkedEvent {
        +luid: Str
    }
    class DataUpdatedEvent {
        +extId: Long
        +game: Str
        +removeOldData: Bool
    }
    class FedyEvent {
        +cardCreated: CardCreatedEvent?
        +cardLinked: CardLinkedEvent?
        +cardUnlinked: CardUnlinkedEvent?
        +dataUpdated: DataUpdatedEvent?
    }
    class DataPullReq {
        +extId: Long
        +game: Str
        +exportOptions: ExportOptions
    }
    class DataPullRes {
        +error: DataPullErr?
        +result: Any?
    }
    class DataPullErr {
        +code: Int
        +message: Str
    }
    class DataPushReq {
        +extId: Long
        +game: Str
        +data: JDict
        +removeOldData: Bool
    }
    class CardResolveReq {
        +luid: Str
        +pairedLuid: Str?
        +createIfNotFound: Bool
    }
    class CardResolveRes {
        +extId: Long
        +isGhost: Bool
        +isNewlyCreated: Bool
        +isPairedLuidDiverged: Bool
    }
    class CardLinkReq {
        +auId: Long
        +luid: Str
    }
    class CardUnlinkReq {
        +auId: Long
        +luid: Str
    }
    FedyEvent --> CardCreatedEvent
    FedyEvent --> CardLinkedEvent
    FedyEvent --> CardUnlinkedEvent
    FedyEvent --> DataUpdatedEvent
    Fedy --> FedyEvent
    Fedy --> DataPullReq
    Fedy --> DataPullRes
    Fedy --> DataPushReq
    Fedy --> CardResolveReq
    Fedy --> CardResolveRes
    Fedy --> CardLinkReq
    Fedy --> CardUnlinkReq
Loading

File-Level Changes

Change Details Files
Overhaul Fedy service to use card-centric events and unified data APIs
  • replaced FedyEvent enum with a data class holding cardCreated, cardLinked, cardUnlinked, dataUpdated fields
  • introduced DataPull and DataPush request/response models and new /data/pull and /data/push endpoints
  • added stub endpoints for card resolve, link, and unlink
  • refactored maybeNotifyAsync and notify to send JSON payloads to a single /notify endpoint
  • swapped out AquaNetUserFedyRepo for CardRepository and removed legacy link/unlink/status handlers
src/main/java/icu/samnyan/aqua/net/Fedy.kt
Hook Fedy event triggers into controllers and import flows
  • invoke fedy.onCardLinked/onCardUnlinked in CardController after register, link, and unlink operations
  • call fedy.onCardCreated in Frontier and AimeDB when new cards are registered
  • update ImportController and Maimai2ServletController to use card-based export and invoke fedy.onDataUpdated instead of onImported/onUpserted
src/main/java/icu/samnyan/aqua/net/CardController.kt
src/main/java/icu/samnyan/aqua/net/Frontier.kt
src/main/java/icu/samnyan/aqua/net/games/ImportController.kt
src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDB.kt
src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2ServletController.kt
Clean up legacy AquaNetUserFedy entity and table
  • remove AquaNetUserFedy.kt entity file
  • add SQL migration to drop aqua_net_user_fedy table
src/main/java/icu/samnyan/aqua/net/db/AquaNetUserFedy.kt
src/main/resources/db/80/V1000_57__aqua_net_user_fedy_drop.sql

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Menci
Copy link
Contributor Author

Menci commented Sep 17, 2025

@sourcery-ai review
@sourcery-ai summary

@Menci
Copy link
Contributor Author

Menci commented Sep 18, 2025

@sourcery-ai summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant