Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
本次 PR 新增项目举报(report)功能,包含路由注册、处理逻辑、错误常量及 Swagger 文档更新:
- 在路由层
/api/v1/projects/:id/report注册 ReportProject 接口 - 实现
ReportProject逻辑,包括参数校验、重复举报检查、事务更新报告计数及隐藏状态 - 更新错误常量
AlreadyReported,并在 Swagger 文档(yaml/json/Go 模板)中添加请求体及接口定义
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/router/router.go | 添加 /projects/:id/report 路由 |
| internal/apps/project/routers.go | 实现 ReportProject 处理逻辑,引入 config 和 errors |
| internal/apps/project/err.go | 增加 AlreadyReported 错误常量 |
| docs/swagger.yaml | 增加 ReportProjectRequestBody 定义及路径 |
| docs/swagger.json | 同步更新 JSON 格式的接口定义 |
| docs/docs.go | 更新文档模板以包含新接口 |
Comments suppressed due to low confidence (4)
internal/apps/project/routers.go:412
- [nitpick] 局部变量名
project与包名冲突,建议改为如proj或targetProject以避免歧义。
project := &Project{}
internal/apps/project/routers.go:403
- [nitpick] 建议为
ReportProject接口添加单元测试,覆盖重复举报、达到阈值隐藏、正常举报等关键场景。
func ReportProject(c *gin.Context) {
docs/swagger.yaml:283
- [nitpick] Swagger 文档在 yaml/json/docs.go 多处手动同步定义,易导致版本不一致,建议使用统一生成方案或集中维护模板以提高可维护性。
project.ReportProjectRequestBody:
internal/apps/project/routers.go:28
- 缺少 net/http 导入,使用 http.StatusBadRequest/NotFound/InternalServerError/OK 会导致编译失败;请在 import 块中添加
"net/http"。
"errors"
OrenZhang
suggested changes
Jul 4, 2025
OrenZhang
approved these changes
Jul 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
例行检查
变更内容
增加项目举报功能