mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 13:47:15 +08:00
feat: 优化分页
This commit is contained in:
@@ -125,15 +125,15 @@ func (r *CertController) Algorithms(ctx http.Context) http.Response {
|
||||
// @Failure 500 {object} ErrorResponse "系统内部错误"
|
||||
// @Router /panel/cert/users [get]
|
||||
func (r *CertController) UserList(ctx http.Context) http.Response {
|
||||
var updateProfileRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &updateProfileRequest)
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
var users []models.CertUser
|
||||
var total int64
|
||||
err := facades.Orm().Query().Paginate(updateProfileRequest.Page, updateProfileRequest.Limit, &users, &total)
|
||||
err := facades.Orm().Query().Paginate(paginateRequest.Page, paginateRequest.Limit, &users, &total)
|
||||
if err != nil {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
@@ -215,15 +215,15 @@ func (r *CertController) UserDelete(ctx http.Context) http.Response {
|
||||
// @Failure 500 {object} ErrorResponse "系统内部错误"
|
||||
// @Router /panel/cert/dns [get]
|
||||
func (r *CertController) DNSList(ctx http.Context) http.Response {
|
||||
var updateProfileRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &updateProfileRequest)
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
var dns []models.CertDNS
|
||||
var total int64
|
||||
err := facades.Orm().Query().Paginate(updateProfileRequest.Page, updateProfileRequest.Limit, &dns, &total)
|
||||
err := facades.Orm().Query().Paginate(paginateRequest.Page, paginateRequest.Limit, &dns, &total)
|
||||
if err != nil {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
@@ -305,15 +305,15 @@ func (r *CertController) DNSDelete(ctx http.Context) http.Response {
|
||||
// @Failure 500 {object} ErrorResponse "系统内部错误"
|
||||
// @Router /panel/cert/certs [get]
|
||||
func (r *CertController) CertList(ctx http.Context) http.Response {
|
||||
var updateProfileRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &updateProfileRequest)
|
||||
var paginateRequest commonrequests.Paginate
|
||||
sanitize := Sanitize(ctx, &paginateRequest)
|
||||
if sanitize != nil {
|
||||
return sanitize
|
||||
}
|
||||
|
||||
var certs []models.Cert
|
||||
var total int64
|
||||
err := facades.Orm().Query().Paginate(updateProfileRequest.Page, updateProfileRequest.Limit, &certs, &total)
|
||||
err := facades.Orm().Query().Paginate(paginateRequest.Page, paginateRequest.Limit, &certs, &total)
|
||||
if err != nil {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
|
||||
@@ -44,10 +44,5 @@ func (r *CertAdd) Attributes(ctx http.Context) map[string]string {
|
||||
}
|
||||
|
||||
func (r *CertAdd) PrepareForValidation(ctx http.Context, data validation.Data) error {
|
||||
err := data.Set("user_id", uint(ctx.Request().InputInt("user_id")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -37,8 +37,5 @@ func (r *Paginate) Attributes(ctx http.Context) map[string]string {
|
||||
}
|
||||
|
||||
func (r *Paginate) PrepareForValidation(ctx http.Context, data validation.Data) error {
|
||||
_ = data.Set("page", ctx.Request().QueryInt("page"))
|
||||
_ = data.Set("limit", ctx.Request().QueryInt("limit"))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -8,7 +8,7 @@ require (
|
||||
github.com/go-acme/lego/v4 v4.14.2
|
||||
github.com/gookit/color v1.5.4
|
||||
github.com/goravel/fiber v1.1.10
|
||||
github.com/goravel/framework v1.13.1-0.20231104153423-7bfd9573b12d
|
||||
github.com/goravel/framework v1.13.1-0.20231105145249-62c723ac8fd1
|
||||
github.com/iancoleman/strcase v0.3.0
|
||||
github.com/imroc/req/v3 v3.42.1
|
||||
github.com/mojocn/base64Captcha v1.3.5
|
||||
|
||||
2
go.sum
2
go.sum
@@ -387,6 +387,8 @@ github.com/goravel/file-rotatelogs/v2 v2.4.1 h1:ogkeIFcTHSBRUBpZYiyJbpul8hkVXxHP
|
||||
github.com/goravel/file-rotatelogs/v2 v2.4.1/go.mod h1:euk9qr52WrzM8ICs1hecFcR4CZ/ZZOPdacHfvHgbOf0=
|
||||
github.com/goravel/framework v1.13.1-0.20231104153423-7bfd9573b12d h1:20bsAUUZWGcB8LvCP3nbO+fxGPuwYITiUJGnyx2xUgQ=
|
||||
github.com/goravel/framework v1.13.1-0.20231104153423-7bfd9573b12d/go.mod h1:5jKFbJzfqhaQTP3HCgbyrpnrCyoJjxN5JWSXO96H0iQ=
|
||||
github.com/goravel/framework v1.13.1-0.20231105145249-62c723ac8fd1 h1:Bi86UTQtrQIo74ler6NbbXTy0dOGGZaNwtRcBOuZom8=
|
||||
github.com/goravel/framework v1.13.1-0.20231105145249-62c723ac8fd1/go.mod h1:5jKFbJzfqhaQTP3HCgbyrpnrCyoJjxN5JWSXO96H0iQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
|
||||
|
||||
Reference in New Issue
Block a user