-
Notifications
You must be signed in to change notification settings - Fork 0
Feat update representative #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: review
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @JavaPythonAIForBAT, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要增强了企业CLA(贡献者许可协议)管理系统的功能。它引入了一个新的API端点和相应的后端逻辑,允许社区管理员修改已签署企业CLA的法人授权代表的姓名和邮箱。此外,为了提升数据检索效率,企业签署列表页面现在支持通过授权代表的邮箱或企业名称进行模糊搜索。这些改进旨在提高企业CLA管理的灵活性和用户体验。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
本次 PR 增加了两项主要功能:更新企业签署的授权代表信息,以及为企业签署列表添加搜索功能。代码变更结构清晰,遵循了现有的架构。我的审查主要关注于提高代码清晰度、消除冗余和解决一个潜在的性能问题。具体来说,我指出了几处中文注释,为了代码库的可维护性,建议将它们翻译成英文。我还发现适配器层(adapter)中存在多余的验证逻辑,应当移除,统一由控制器(controller)层进行验证。最后,我强调了新的基于正则表达式的搜索可能带来的性能瓶颈,并建议添加数据库索引。
| return | ||
| } | ||
| adminAdded, sizeErr := ctl.GetBool("admin_added", false) | ||
| searchQuery := ctl.GetString("search") // 新增搜索参数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Date string `json:"date"` | ||
| } | ||
|
|
||
| // models/corp_signing.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 验证参数 | ||
| if opt.RepName == "" || opt.RepEmail == "" { | ||
| return toModelError(errors.New("representative name and email are required")) | ||
| } | ||
|
|
||
| // 验证邮箱格式 | ||
| if _, err := dp.NewEmailAddr(opt.RepEmail); err != nil { | ||
| return toModelError(err) | ||
| } | ||
|
|
||
| // 调用service层更新 | ||
| err := adapter.s.UpdateRepresentative(userId, linkID, signingID, opt.RepName, opt.RepEmail) | ||
| return toModelError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分验证逻辑是多余的。RepresentativeUpdateOption 结构体已经有了 valid 标签(Required, Email),这些标签应该由控制器中的 ctl.fetchInputPayload 来处理。在此处重复验证可能导致维护问题。请移除此代码块,并依赖于控制器层的验证。此外,这里的注释是中文,也应改为英文。
// Call the service layer to update. Input validation is handled in the controller.
err := adapter.s.UpdateRepresentative(userId, linkID, signingID, opt.RepName, opt.RepEmail)
return toModelError(err)| } | ||
|
|
||
| func (s *corpSigningService) UpdateRepresentative(userId, linkID, signingID, repName, repEmail string) error { | ||
| // 权限验证 - 只有社区管理员可以操作 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| func (impl *corpSigning) FindPage(linkId string, intPage, intPageSize int, adminAdded bool) (repository.CorpSigningSummaryPage, error) { | ||
| // 邮箱验证辅助函数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| filter[childField(fieldRep, fieldEmail)] = searchQuery | ||
| } else { | ||
| // 按企业名称搜索(模糊匹配) | ||
| filter[childField(fieldCorp, fieldName)] = bson.M{"$regex": searchQuery, "$options": "i"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return err | ||
| } | ||
|
|
||
| // 构建更新文档 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
commit合并为一个 |
CLA支持修改企业法人的授权代表和邮箱