mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
fix: environment list query issue
This commit is contained in:
parent
392cac4186
commit
d6d7cdbb1f
1 changed files with 14 additions and 6 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/0xJacky/Nginx-UI/settings"
|
"github.com/0xJacky/Nginx-UI/settings"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
|
"gorm.io/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,12 +29,19 @@ func GetEnvironment(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEnvironmentList(c *gin.Context) {
|
func GetEnvironmentList(c *gin.Context) {
|
||||||
cosy.Core[model.Environment](c).
|
core := cosy.Core[model.Environment](c).
|
||||||
SetFussy("name").
|
SetFussy("name")
|
||||||
SetEqual("enabled").
|
|
||||||
SetTransformer(func(m *model.Environment) any {
|
// fix for sqlite
|
||||||
return analytic.GetNode(m)
|
if c.Query("enabled") != "" {
|
||||||
}).PagingList()
|
core.GormScope(func(tx *gorm.DB) *gorm.DB {
|
||||||
|
return tx.Where("enabled = ?", cast.ToInt(cast.ToBool(c.Query("enabled"))))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
core.SetTransformer(func(m *model.Environment) any {
|
||||||
|
return analytic.GetNode(m)
|
||||||
|
}).PagingList()
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddEnvironment(c *gin.Context) {
|
func AddEnvironment(c *gin.Context) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue