template-monorepo/internal/model/permission/domain/entity/role.go

31 lines
1006 B
Go
Raw Permalink Normal View History

package entity
import (
"gateway/internal/model/permission/domain/enum"
"go.mongodb.org/mongo-driver/v2/bson"
)
// Role is a tenant-scoped role definition. Key is immutable and uniquely
// identifies the role within a tenant; DisplayName may be edited freely.
//
// is_system roles are seeded when a tenant is created (`tenant_owner`,
// `tenant_admin`, `member_manager`, `member`, `viewer`); the `tenant_owner`
// role cannot be deleted.
type Role struct {
ID bson.ObjectID `bson:"_id,omitempty"`
TenantID string `bson:"tenant_id"`
Key string `bson:"key"`
DisplayName string `bson:"display_name"`
CreatorUID string `bson:"creator_uid,omitempty"`
Status enum.Status `bson:"status"`
IsSystem bool `bson:"is_system"`
CreateAt int64 `bson:"create_at"`
UpdateAt int64 `bson:"update_at"`
}
// CollectionName returns the MongoDB collection for roles.
func (Role) CollectionName() string {
return "roles"
}