36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"management/internal/erpserver/model/dto"
|
|
)
|
|
|
|
type RoleRepository interface {
|
|
Initialize(ctx context.Context) (*Role, error)
|
|
Create(ctx context.Context, obj *Role) error
|
|
Update(ctx context.Context, obj *Role) error
|
|
Get(ctx context.Context, id int32) (*Role, error)
|
|
All(ctx context.Context) ([]*Role, error)
|
|
List(ctx context.Context, q dto.SearchDto) ([]*Role, int64, error)
|
|
RebuildParentPath(ctx context.Context) error
|
|
}
|
|
|
|
type Role 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"`
|
|
ParentID int32 `json:"parent_id" gorm:"type:int;not null;"`
|
|
ParentPath string `json:"parent_path" gorm:"type:varchar(500);not null;"`
|
|
Vip bool `json:"-" 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 (Role) TableName() string {
|
|
return "sys_role"
|
|
}
|