mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Updates
This commit is contained in:
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -47,7 +47,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -33,7 +33,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,21 @@ type ListResponse struct {
|
||||
// ListQueryBuilder is used to setup queries for lists
|
||||
func ListQueryBuilder(
|
||||
pageInfo *model.PageInfo,
|
||||
defaultSort model.Sort,
|
||||
filters []model.Filter,
|
||||
filterMap map[string]filterMapValue,
|
||||
) *gorm.DB {
|
||||
scopes := make([]func(*gorm.DB) *gorm.DB, 0)
|
||||
scopes = append(scopes, ScopeOrderBy(pageInfo, defaultSort))
|
||||
scopes = append(scopes, ScopeOffsetLimit(pageInfo))
|
||||
scopes = append(scopes, ScopeFilters(filters, filterMap))
|
||||
return database.GetDB().Scopes(scopes...)
|
||||
}
|
||||
|
||||
// AddOrderToList is used after query above is used for counting
|
||||
// Postgres in particular doesn't like count(*) when ordering at the same time
|
||||
func AddOrderToList(
|
||||
dbo *gorm.DB,
|
||||
pageInfo *model.PageInfo,
|
||||
defaultSort model.Sort,
|
||||
) *gorm.DB {
|
||||
return dbo.Scopes(ScopeOrderBy(pageInfo, defaultSort))
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -31,7 +31,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"npm/internal/database"
|
||||
"npm/internal/entity"
|
||||
"npm/internal/logger"
|
||||
@ -41,7 +42,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Direction: "ASC",
|
||||
}
|
||||
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, defaultSort, filters, entity.GetFilterMap(Model{}, true))
|
||||
dbo := entity.ListQueryBuilder(&pageInfo, filters, entity.GetFilterMap(Model{}, true))
|
||||
|
||||
// Get count of items in this search
|
||||
var totalRows int64
|
||||
@ -51,7 +52,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
|
||||
// Get rows
|
||||
items := make([]Model, 0)
|
||||
if res := dbo.Find(&items); res.Error != nil {
|
||||
if res := entity.AddOrderToList(dbo, &pageInfo, defaultSort).Find(&items); res.Error != nil {
|
||||
return result, res.Error
|
||||
}
|
||||
|
||||
@ -84,8 +85,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
func DeleteAll() error {
|
||||
db := database.GetDB()
|
||||
// nolint errcheck
|
||||
db.Exec("DELETE FROM auth")
|
||||
result := db.Exec("DELETE FROM user WHERE is_system = ?", false)
|
||||
result := db.Exec(fmt.Sprintf(`DELETE FROM %s WHERE is_system = ?`, database.QuoteTableName("user")), false)
|
||||
return result.Error
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user