Skip to content

Library#40

Merged
XinxinAkuma merged 2 commits into
mainfrom
library
May 26, 2026
Merged

Library#40
XinxinAkuma merged 2 commits into
mainfrom
library

Conversation

@XinxinAkuma
Copy link
Copy Markdown
Contributor

@XinxinAkuma XinxinAkuma commented May 26, 2026

Summary by CodeRabbit

发行说明

  • 新功能

    • 新增图书馆考勤统计及阅读数据分析功能,支持按时段、楼层、月份等多维度统计查询
    • 提供个人阅读偏好分析、借阅清单管理和热门书籍排行榜等功能
    • 支持阅读数据分享和兑换码生成机制
  • 功能移除

    • 图书详细信息和借阅历史查询功能已下线

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fdbde4d-904d-4dfd-bbf1-72dc84b7fb83

📥 Commits

Reviewing files that changed from the base of the PR and between eb00df8 and 325b1e3.

⛔ Files ignored due to path filters (3)
  • campusapis/library/v1/library.pb.go is excluded by !**/*.pb.go
  • campusapis/library/v1/library.pb.gw.go is excluded by !**/*.pb.gw.go
  • campusapis/library/v1/library_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (2)
  • campusapis/library/v1/library.proto
  • docs/swagger/campusapis/library/v1/library.swagger.json

总体说明

本 PR 对 LibraryService API 进行了全量重设计,将原有的图书编目、MARC、借阅记录查询能力,替换为基于阅读统计与考勤数据的分析和排行功能。变更涉及 Proto 服务契约定义和配套 Swagger 文档的完整重构。

改动内容

LibraryService API 重设计

层级 / 文件 说明
Proto 服务定义与 HTTP 路由配置
campusapis/library/v1/library.proto
新增 google.protobuf.Emptygoogle.protobuf.Timestamp 导入;将 LibraryService 的 RPC 从 GetBookInfo*GetBookMARC*GetBookLend* 等,替换为 GetAttendanceStatsGetTimeSlotStatsGetFloorStatsGetMonthlyStatsGetReadingSummaryGetFirstBookGetMonthStatsGetMaxMonthGetLeastPopularGetPreferenceGetTotalTimeGetBorrowListCheckReadNewerGetAllReadDataGetUnreturnedBooksGetShareIDGetStaffIDByShareID 共 18 个接口,每个接口配置对应的 google.api.http GET 路由。
Proto 请求/响应消息和数据实体
campusapis/library/v1/library.proto
新增统一的 response wrapper 消息包含 int32 errorstring msgdata 字段;为各接口新增 request/response 消息对(如 GetAttendanceStatsRequest/ResponseGetBorrowListRequest/Response 等);新增数据承载实体(AttendanceStatsTimeSlotStatsFloorStatsMonthlyStatsReadingSummaryFirstBookMonthStatsMaxMonthBookStatsPreferenceTotalBookListBorrowListFlatReadData)。
Swagger 路径、端点和查询参数定义
docs/swagger/campusapis/library/v1/library.swagger.json
paths 中原有的图书信息、借阅历史端点替换为考勤端点(/attendance/floors/attendance/months/attendance/stats/attendance/time-slots)和阅读端点(/read/all/read/borrows/read/first-book/read/least-popular/read/max-month/read/months/read/newer/read/preference/read/summary/read/total-time/read/unreturned)及分享端点(/share/staff-by-shareId/{shareId});统一查询参数为 start/end(字符串,可选)、为列表接口新增 page/size(int32)、shareId 作为路径参数。
Swagger 响应包装和数据模型定义
docs/swagger/campusapis/library/v1/library.swagger.json
definitions 中新增/调整所有 v1Get*Response 响应包装结构(如 v1GetAttendanceStatsResponsev1GetBorrowListResponse 等),将其 data 字段指向对应的数据模型(v1AttendanceStatsv1TimeSlotStatsv1FloorStatsv1MonthlyStatsv1ReadingSummaryv1FirstBookv1MonthStatsv1MaxMonthv1BookStatsv1Preferencev1Totalv1BookListv1BorrowListv1FlatReadData 等)。

序列图

sequenceDiagram
  participant Client
  participant LibraryService as LibraryService<br/>(18 endpoints)
  participant AttendanceData as Attendance Data
  participant ReadingData as Reading Data
  participant ShareData as Share Data
  
  Client->>LibraryService: GET /attendance/stats?start=...&end=...
  LibraryService->>AttendanceData: Query AttendanceStats
  AttendanceData-->>LibraryService: AttendanceStats
  LibraryService-->>Client: GetAttendanceStatsResponse (data: AttendanceStats)
  
  Client->>LibraryService: GET /read/all?start=...&end=...&page=1&size=10
  LibraryService->>ReadingData: Query FlatReadData
  ReadingData-->>LibraryService: FlatReadData list
  LibraryService-->>Client: GetAllReadDataResponse (data: FlatReadData[])
  
  Client->>LibraryService: GET /share/{shareId}
  LibraryService->>ShareData: Query ShareID
  ShareData-->>LibraryService: ShareID mapping
  LibraryService-->>Client: GetShareIDResponse (data: ShareID)
Loading

代码审查工作量评估

🎯 4 (复杂) | ⏱️ ~60 分钟

庆祝诗

🐰 旧时编目已远去,新的统计闪闪发光,
考勤与阅读齐排行,数据流转赛月光。
十八个端点新启航,Swagger 图谱更完全,
请求响应齐对齐,API 合约焕新颜! ✨📚

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch library

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.

@XinxinAkuma XinxinAkuma merged commit 65e7b57 into main May 26, 2026
1 of 2 checks passed
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