-
Notifications
You must be signed in to change notification settings - Fork 0
feat:支持企业通过邮箱地址或者企业名称进行信息检索 #423
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -212,8 +212,26 @@ func (impl *corpSigning) CountByLinkId(linkId string) (int64, error) { | |||||||||||||||||
| return impl.dao.CountDocs(filter) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func (impl *corpSigning) FindPage(linkId string, intPage, intPageSize int, adminAdded bool) (repository.CorpSigningSummaryPage, error) { | ||||||||||||||||||
| // 邮箱验证辅助函数 | ||||||||||||||||||
| func isEmail(query string) bool { | ||||||||||||||||||
| // 使用现有的邮箱验证逻辑 | ||||||||||||||||||
| _, err := dp.NewEmailAddr(query) | ||||||||||||||||||
|
Comment on lines
+215
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为了保持代码库语言一致性并提高可维护性,建议将此处的中文注释修改为英文。
Suggested change
|
||||||||||||||||||
| return err == nil | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func (impl *corpSigning) FindPage(linkId string, intPage, intPageSize int, adminAdded bool, searchQuery string) (repository.CorpSigningSummaryPage, error) { | ||||||||||||||||||
| filter := linkIdFilter(linkId) | ||||||||||||||||||
| // 添加搜索过滤条件 | ||||||||||||||||||
| if searchQuery != "" { | ||||||||||||||||||
| if isEmail(searchQuery) { | ||||||||||||||||||
| // 按邮箱搜索 | ||||||||||||||||||
| filter[childField(fieldRep, fieldEmail)] = searchQuery | ||||||||||||||||||
| } else { | ||||||||||||||||||
| // 按企业名称搜索(模糊匹配) | ||||||||||||||||||
| filter[childField(fieldCorp, fieldName)] = bson.M{"$regex": searchQuery, "$options": "i"} | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+225
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此处的搜索逻辑存在几个问题:
建议修改为使用 if searchQuery != "" {
// To prevent ReDoS, escape the search query for use in regex.
escapedQuery := regexp.QuoteMeta(searchQuery)
regexFilter := bson.M{"\$regex": escapedQuery, "\$options": "i"}
filter["\$or"] = bson.A{
bson.M{childField(fieldCorp, fieldName): regexFilter},
bson.M{childField(fieldRep, fieldEmail): regexFilter},
}
} |
||||||||||||||||||
|
|
||||||||||||||||||
| if adminAdded { | ||||||||||||||||||
| filter["admin.id"] = bson.M{"$ne": ""} | ||||||||||||||||||
| } else { | ||||||||||||||||||
|
|
||||||||||||||||||
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.
为了保持代码库语言一致性并提高可维护性,建议将此处的中文注释修改为英文。