Skip to content

Conversation

@tfhddd
Copy link
Contributor

@tfhddd tfhddd commented Sep 1, 2025

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @tfhddd, 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!

This pull request primarily focuses on enhancing the corporate signing management system by introducing pagination capabilities. This allows community managers to efficiently browse and retrieve corporate signing records in manageable chunks, improving performance and user experience when dealing with a large number of entries. Additionally, a minor update to the SMTP configuration has been included.

Highlights

  • Pagination for Corporate Signings: Introduced new functionality to retrieve corporate signing records with pagination, allowing for efficient fetching of large datasets.
  • New API Endpoint: Added a new GET API endpoint /page/:link_id under CorporationSigningController to expose the paginated corporate signing data.
  • MongoDB DAO Enhancements: Implemented new GetDocsPage and GetDocsCount methods in the MongoDB Data Access Object (DAO) to support paginated queries and total document counts.
  • SMTP Host Update: Updated the default SMTP host configuration from smtp.exmail.qq.com to smtp.qq.com.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully adds pagination support for listing corporation signings. The changes span across the data, application, and controller layers, including a new API endpoint. The implementation is mostly solid. I've identified a few areas for improvement:

  • API Documentation: The Swagger documentation for the new endpoint is incomplete and has an error.
  • Code Style: There's some inconsistent naming for pagination parameters (page vs intPage) across different layers, and a case of variable shadowing.
  • Performance: The repository implementation for fetching paginated data makes two database calls, which could be optimized in the future.

My detailed comments provide specific suggestions to address these points.

Comment on lines +338 to +354
func (impl *daoImpl) GetDocsPage(filter, project bson.M, intPage, intPageSize int, result interface{}) error {
return impl.withContext(func(ctx context.Context) error {
// 构建查询选项
opts := options.Find()
if len(project) > 0 {
opts.SetProjection(project)
}
opts.SetSkip(int64((intPage - 1) * intPageSize))
opts.SetLimit(int64(intPageSize))
// 执行查询
cursor, err := impl.col.Find(ctx, filter, opts)
if err != nil {
return err
}
return cursor.All(ctx, result)
})
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other layers in the call stack, the parameter names should be page and pageSize instead of intPage and intPageSize. Remember to update their usage within the function body as well.

Suggested change
func (impl *daoImpl) GetDocsPage(filter, project bson.M, intPage, intPageSize int, result interface{}) error {
return impl.withContext(func(ctx context.Context) error {
// 构建查询选项
opts := options.Find()
if len(project) > 0 {
opts.SetProjection(project)
}
opts.SetSkip(int64((intPage - 1) * intPageSize))
opts.SetLimit(int64(intPageSize))
// 执行查询
cursor, err := impl.col.Find(ctx, filter, opts)
if err != nil {
return err
}
return cursor.All(ctx, result)
})
}
func (impl *daoImpl) GetDocsPage(filter, project bson.M, page, pageSize int, result interface{}) error {
return impl.withContext(func(ctx context.Context) error {
// 构建查询选项
opts := options.Find()
if len(project) > 0 {
opts.SetProjection(project)
}
opts.SetSkip(int64((page - 1) * pageSize))
opts.SetLimit(int64(pageSize))
// 执行查询
cursor, err := impl.col.Find(ctx, filter, opts)
if err != nil {
return err
}
return cursor.All(ctx, result)
})
}
Comment on lines +358 to +362
err := impl.withContext(func(ctx context.Context) error {
var err error
count, err = impl.col.CountDocuments(ctx, filter)
return err
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The err variable is shadowed inside the closure. While this is not a bug, it makes the code harder to read and is generally discouraged in Go. You can refactor this to be more idiomatic and avoid shadowing by using a named return for the closure.

err := impl.withContext(func(ctx context.Context) (err error) { count, err = impl.col.CountDocuments(ctx, filter) return	})
Comment on lines +207 to +208
// @Param link_id path string true "link id"
// @Success 200 {object} models.CorporationSigningSummary

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Swagger documentation for this endpoint has a couple of issues:

  1. It's missing definitions for the page and page_size query parameters.
  2. The success response object is incorrect. It should be models.CorporationSigningPageSummary which includes total count and data array.
Suggested change
// @Param link_id path string true "link id"
// @Success 200 {object} models.CorporationSigningSummary
// @Param link_id path string true "link id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} models.CorporationSigningPageSummary
Find(string) (domain.CorpSigning, error)
Remove(*domain.CorpSigning) error
FindAll(linkId string) ([]CorpSigningSummary, error)
FindPage(linkId string, intPage, intPageSize int) (CorpSigningSummaryPage, error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parameter names intPage and intPageSize are inconsistent with the naming used in other layers (e.g., page, pageSize in the application and adapter layers). For consistency across the codebase, it's better to use page and pageSize. This change should be propagated down to the repository implementation and DAO layers.

Suggested change
FindPage(linkId string, intPage, intPageSize int) (CorpSigningSummaryPage, error)
FindPage(linkId string, page, pageSize int) (CorpSigningSummaryPage, error)
Comment on lines 146 to 184
func (impl *corpSigning) FindPage(linkId string, intPage, intPageSize int) (repository.CorpSigningSummaryPage, error) {
filter := linkIdFilter(linkId)

project := bson.M{
fieldDate: 1,
fieldCLAId: 1,
fieldLang: 1,
fieldRep: 1,
fieldCorp: 1,
fieldAdmin: 1,
fieldLinkId: 1,
fieldHasPDF: 1,
fieldCLANotify: 1,
}

var docsPage repository.CorpSigningSummaryPage
docsPage.Total = 0
total, err := impl.dao.GetDocsCount(filter)
if err != nil {
return docsPage, err
}
if total == 0 {
return docsPage, nil
}

var dos []corpSigningDO

if err := impl.dao.GetDocsPage(filter, project, intPage, intPageSize, &dos); err != nil {
return docsPage, err
}

v := make([]repository.CorpSigningSummary, len(dos))
for i := range dos {
v[i] = dos[i].toCorpSigningSummary()
}
docsPage.Data = v
docsPage.Total = total
return docsPage, nil
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other layers and the interface definition, the parameter names should be page and pageSize instead of intPage and intPageSize.

func (impl *corpSigning) FindPage(linkId string, page, pageSize int) (repository.CorpSigningSummaryPage, error) { filter := linkIdFilter(linkId) project := bson.M{ fieldDate: 1, fieldCLAId: 1, fieldLang: 1, fieldRep: 1, fieldCorp: 1, fieldAdmin: 1, fieldLinkId: 1, fieldHasPDF: 1, fieldCLANotify: 1,	} var docsPage repository.CorpSigningSummaryPage docsPage.Total = 0 total, err := impl.dao.GetDocsCount(filter) if err != nil { return docsPage, err	} if total == 0 { return docsPage, nil	} var dos []corpSigningDO if err := impl.dao.GetDocsPage(filter, project, page, pageSize, &dos); err != nil { return docsPage, err	} v := make([]repository.CorpSigningSummary, len(dos)) for i := range dos { v[i] = dos[i].toCorpSigningSummary()	} docsPage.Data = v docsPage.Total = total return docsPage, nil }
Comment on lines +163 to +175
total, err := impl.dao.GetDocsCount(filter)
if err != nil {
return docsPage, err
}
if total == 0 {
return docsPage, nil
}

var dos []corpSigningDO

if err := impl.dao.GetDocsPage(filter, project, intPage, intPageSize, &dos); err != nil {
return docsPage, err
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This implementation makes two separate database calls: one to get the total count of documents and another to fetch the paginated data. While this is a common pattern, it can be inefficient under high load. For future optimization, consider using a single aggregation query with the $facet operator to retrieve both the count and the data in one round trip to the database. This would improve performance by reducing network latency and database load.

Comment on lines +49 to +50
GetDocsPage(filter, project bson.M, intPage, intPageSize int, result interface{}) error
GetDocsCount(filter bson.M) (int64, error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency, the parameter names should be page and pageSize instead of intPage and intPageSize.

Suggested change
GetDocsPage(filter, project bson.M, intPage, intPageSize int, result interface{}) error
GetDocsCount(filter bson.M) (int64, error)
GetDocsPage(filter, project bson.M, page, pageSize int, result interface{}) error
GetDocsCount(filter bson.M) (int64, error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants