mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
feat(site-category): support for custom sorting #902
This commit is contained in:
parent
efc9b1c365
commit
f3d4cdbeb4
5 changed files with 12 additions and 3 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetCategory(c *gin.Context) {
|
||||
|
@ -11,7 +12,9 @@ func GetCategory(c *gin.Context) {
|
|||
}
|
||||
|
||||
func GetCategoryList(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).PagingList()
|
||||
cosy.Core[model.SiteCategory](c).GormScope(func(tx *gorm.DB) *gorm.DB {
|
||||
return tx.Order("order_id ASC")
|
||||
}).PagingList()
|
||||
}
|
||||
|
||||
func AddCategory(c *gin.Context) {
|
||||
|
@ -39,3 +42,7 @@ func DeleteCategory(c *gin.Context) {
|
|||
func RecoverCategory(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).Recover()
|
||||
}
|
||||
|
||||
func UpdateCategoriesOrder(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).UpdateOrder()
|
||||
}
|
||||
|
|
|
@ -31,4 +31,5 @@ func InitCategoryRouter(r *gin.RouterGroup) {
|
|||
r.POST("site_categories/:id", ModifyCategory)
|
||||
r.DELETE("site_categories/:id", DeleteCategory)
|
||||
r.POST("site_categories/:id/recover", RecoverCategory)
|
||||
r.POST("site_categories/order", UpdateCategoriesOrder)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue