新增菜单,修改角色,分页
This commit is contained in:
@@ -5,7 +5,7 @@ type AdminMenu struct {
|
||||
Model
|
||||
MenuId int64 `gorm:"column:menu_id;type:bigint(19);primary_key;comment:主键id" json:"menu_id"`
|
||||
MenuName string `gorm:"column:menu_name;type:varchar(30);comment:菜单名称" json:"menu_name"`
|
||||
MenuTitle string `gorm:"column:title;menu_title:varchar(30);comment:菜单名称" json:"menu_title"`
|
||||
MenuTitle string `gorm:"column:menu_title;menu_title:varchar(30);comment:菜单名称" json:"menu_title"`
|
||||
ParentId int64 `gorm:"column:parent_id;type:int(10);default:0;comment:父菜单ID(0表示一级)" json:"parent_id"`
|
||||
MenuStatus int `gorm:"column:menu_status;type:tinyint(1);default:1;comment:菜单状态(0:隐藏 1:正常)此优先级最高" json:"menu_status"`
|
||||
MenuType int `gorm:"column:menu_type;type:tinyint(1);comment:菜单类型(1:模块 2:菜单 3:按钮)" json:"menu_type"`
|
||||
|
||||
@@ -121,3 +121,21 @@ func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB {
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
switch {
|
||||
case pageSize > 100:
|
||||
pageSize = 100
|
||||
case pageSize <= 0:
|
||||
pageSize = 10
|
||||
}
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
return db.Offset(offset).Limit(pageSize)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user