-
Notifications
You must be signed in to change notification settings - Fork 0
Tfh 0827 #404
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?
Tfh 0827 #404
Changes from all commits
68349f7
0eb1494
8c8580c
2cc9013
b32068c
9574520
7f7fc84
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 |
|---|---|---|
|
|
@@ -335,6 +335,34 @@ func (impl *daoImpl) GetDocs(filter, project bson.M, result interface{}) error { | |
| }) | ||
| } | ||
|
|
||
| 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) GetDocsCount(filter bson.M) (int64, error) { | ||
| var count int64 | ||
| err := impl.withContext(func(ctx context.Context) error { | ||
| var err error | ||
| count, err = impl.col.CountDocuments(ctx, filter) | ||
| return err | ||
| }) | ||
|
Comment on lines
+358
to
+362
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. The err := impl.withContext(func(ctx context.Context) (err error) {
count, err = impl.col.CountDocuments(ctx, filter)
return
}) |
||
| return count, err | ||
| } | ||
|
|
||
| func (impl *daoImpl) GetDocAndDelete(filter, project bson.M, result interface{}) error { | ||
| return impl.withContext(func(ctx context.Context) error { | ||
| var sr *mongo.SingleResult | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -200,6 +200,47 @@ func (ctl *CorporationSigningController) GetAll() { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // @Title GetPage | ||||||||||||||
| // @Description get all the corporations by page | ||||||||||||||
| // @Tags CorpSigning | ||||||||||||||
| // @Accept json | ||||||||||||||
| // @Param link_id path string true "link id" | ||||||||||||||
| // @Success 200 {object} models.CorporationSigningSummary | ||||||||||||||
|
Comment on lines
+207
to
+208
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. The Swagger documentation for this endpoint has a couple of issues:
Suggested change
|
||||||||||||||
| // @Failure 400 missing_url_path_parameter: missing url path parameter | ||||||||||||||
| // @Failure 401 missing_token: token is missing | ||||||||||||||
| // @Failure 402 unknown_token: token is unknown | ||||||||||||||
| // @Failure 403 expired_token: token is expired | ||||||||||||||
| // @Failure 404 unauthorized_token: the permission of token is unmatched | ||||||||||||||
| // @Failure 405 unknown_link: unkown link id | ||||||||||||||
| // @Failure 406 not_yours_org: the link doesn't belong to your community | ||||||||||||||
| // @Failure 500 system_error: system error | ||||||||||||||
| // @router /page/:link_id [get] | ||||||||||||||
| func (ctl *CorporationSigningController) GetPage() { | ||||||||||||||
| action := "community manager lists page corp signings" | ||||||||||||||
| linkID := ctl.GetString(":link_id") | ||||||||||||||
| page, pageErr := ctl.GetInt("page", 1) | ||||||||||||||
| if pageErr != nil { | ||||||||||||||
| ctl.sendModelErrorAsResp(models.NewModelError(models.ErrSystemError, pageErr), action) | ||||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
| pageSize, sizeErr := ctl.GetInt("page_size", 10) | ||||||||||||||
| if sizeErr != nil { | ||||||||||||||
| ctl.sendModelErrorAsResp(models.NewModelError(models.ErrSystemError, sizeErr), action) | ||||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
| adminAdded, sizeErr := ctl.GetBool("admin_added", false) | ||||||||||||||
| pl, fr := ctl.tokenPayloadBasedOnCorpManager() | ||||||||||||||
| if fr != nil { | ||||||||||||||
| ctl.sendFailedResultAsResp(fr, action) | ||||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
| if r, merr := models.ListPageCorpSigning(pl.UserId, linkID, page, pageSize, adminAdded); merr != nil { | ||||||||||||||
| ctl.sendModelErrorAsResp(merr, action) | ||||||||||||||
| } else { | ||||||||||||||
| ctl.sendSuccessResp(action, r) | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // @Title ListDeleted | ||||||||||||||
| // @Description get all the corporations which have been deleted | ||||||||||||||
| // @Tags CorpSigning | ||||||||||||||
|
|
||||||||||||||
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.
For consistency with other layers in the call stack, the parameter names should be
pageandpageSizeinstead ofintPageandintPageSize. Remember to update their usage within the function body as well.