File tree 5 files changed +12
-3
lines changed
app/src/views/site/site_category
5 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,17 @@ import (
4
4
"github.com/0xJacky/Nginx-UI/model"
5
5
"github.com/gin-gonic/gin"
6
6
"github.com/uozi-tech/cosy"
7
+ "gorm.io/gorm"
7
8
)
8
9
9
10
func GetCategory (c * gin.Context ) {
10
11
cosy.Core [model.SiteCategory ](c ).Get ()
11
12
}
12
13
13
14
func GetCategoryList (c * gin.Context ) {
14
- cosy.Core [model.SiteCategory ](c ).PagingList ()
15
+ cosy.Core [model.SiteCategory ](c ).GormScope (func (tx * gorm.DB ) * gorm.DB {
16
+ return tx .Order ("order_id ASC" )
17
+ }).PagingList ()
15
18
}
16
19
17
20
func AddCategory (c * gin.Context ) {
@@ -39,3 +42,7 @@ func DeleteCategory(c *gin.Context) {
39
42
func RecoverCategory (c * gin.Context ) {
40
43
cosy.Core [model.SiteCategory ](c ).Recover ()
41
44
}
45
+
46
+ func UpdateCategoriesOrder (c * gin.Context ) {
47
+ cosy.Core [model.SiteCategory ](c ).UpdateOrder ()
48
+ }
Original file line number Diff line number Diff line change @@ -31,4 +31,5 @@ func InitCategoryRouter(r *gin.RouterGroup) {
31
31
r .POST ("site_categories/:id" , ModifyCategory )
32
32
r .DELETE ("site_categories/:id" , DeleteCategory )
33
33
r .POST ("site_categories/:id/recover" , RecoverCategory )
34
+ r .POST ("site_categories/order" , UpdateCategoriesOrder )
34
35
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import columns from '@/views/site/site_category/columns'
11
11
:api =" site_category"
12
12
:columns =" columns"
13
13
:scroll-x =" 600"
14
+ sortable
14
15
>
15
16
<template #edit =" { data } " >
16
17
<div class =" mb-2" >
Original file line number Diff line number Diff line change @@ -9,20 +9,19 @@ const columns: Column[] = [{
9
9
edit : {
10
10
type : input ,
11
11
} ,
12
+ handle : true ,
12
13
pithy : true ,
13
14
width : 120 ,
14
15
} , {
15
16
title : ( ) => $gettext ( 'Created at' ) ,
16
17
dataIndex : 'created_at' ,
17
18
customRender : datetime ,
18
- sorter : true ,
19
19
pithy : true ,
20
20
width : 150 ,
21
21
} , {
22
22
title : ( ) => $gettext ( 'Updated at' ) ,
23
23
dataIndex : 'updated_at' ,
24
24
customRender : datetime ,
25
- sorter : true ,
26
25
pithy : true ,
27
26
width : 150 ,
28
27
} , {
Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ type SiteCategory struct {
4
4
Model
5
5
Name string `json:"name"`
6
6
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
7
+ OrderID int `json:"-" gorm:"default:0"`
7
8
}
You can’t perform that action at this time.
0 commit comments