39 lines
1.6 KiB
Go
39 lines
1.6 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type MenuRepository interface {
|
|
Initialize(ctx context.Context) error
|
|
Create(ctx context.Context, obj *Menu) (*Menu, error)
|
|
Update(ctx context.Context, obj *Menu) error
|
|
Get(ctx context.Context, id int32) (*Menu, error)
|
|
GetByUrl(ctx context.Context, url string) (*Menu, error)
|
|
All(ctx context.Context) ([]*Menu, error)
|
|
RebuildParentPath(ctx context.Context) error
|
|
}
|
|
|
|
type Menu struct {
|
|
ID int32 `json:"id" gorm:"primaryKey;autoIncrement;not null"`
|
|
Name string `json:"name" gorm:"type:varchar(200);not null;uniqueIndex"`
|
|
DisplayName string `json:"display_name" gorm:"type:varchar(200);not null;uniqueIndex"`
|
|
Url string `json:"url" gorm:"type:varchar(200);not null;"`
|
|
Type string `json:"type" gorm:"type:varchar(50);not null;"`
|
|
ParentID int32 `json:"parent_id" gorm:"type:int;not null;"`
|
|
ParentPath string `json:"parent_path" gorm:"type:varchar(500);not null;"`
|
|
Avatar string `json:"avatar" gorm:"type:varchar(100);not null;"`
|
|
Style string `json:"style" gorm:"type:varchar(100);not null;"`
|
|
Visible bool `json:"visible" gorm:"type:boolean;not null;"`
|
|
IsList bool `json:"is_list" gorm:"type:boolean;not null;"`
|
|
Status int32 `json:"status" gorm:"type:int;not null;default:0;"`
|
|
Sort int32 `json:"sort" gorm:"type:int;not null;default:0;"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"type:timestamptz;not null;default:'now()'"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamptz;not null;default:'0001-01-01 00:00:00+8';"`
|
|
}
|
|
|
|
func (Menu) TableName() string {
|
|
return "sys_menu"
|
|
}
|