Skip to content
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

分页列表接口,兼容不分页获取全部数据 #1526

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion server/resource/autocode_template/server/service.go.tpl

Choose a reason for hiding this comment

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

if limit !=0 {
db=db.limit(limit).offset(offset)
}
db.Find(&{{.Abbreviation}}s).Error

Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis
}
{{- end}}

err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
if limit == 0 {
err = db.Find(&{{.Abbreviation}}s).Error
} else {
err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
}
return {{.Abbreviation}}s, total, err
}
Loading