package system import ( "context" "time" "management/internal/erpserver/model/dto" ) type DepartmentRepository interface { Create(ctx context.Context, obj *Department) error Update(ctx context.Context, obj *Department) error Get(ctx context.Context, id int32) (*Department, error) All(ctx context.Context) ([]*Department, error) List(ctx context.Context, q dto.SearchDto) ([]*Department, int64, error) RebuildParentPath(ctx context.Context) error } type Department struct { ID int32 `json:"id" gorm:"primaryKey;autoIncrement;not null"` Name string `json:"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;"` 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 (Department) TableName() string { return "sys_department" }