summaryrefslogtreecommitdiff
path: root/app/domain/entity.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-24 15:55:09 -0600
committermo khan <mo@mokhan.ca>2025-07-24 15:55:09 -0600
commitf6ad289b8d27219c47aefec24113ccb02a62dd99 (patch)
tree8febaf35f6686c3f46ed4b8a1990138b6f622300 /app/domain/entity.go
parent7fb5255aafc435f5b47725716963f3aebfb9feb2 (diff)
refactor: extract defaultEntity type
Diffstat (limited to 'app/domain/entity.go')
-rw-r--r--app/domain/entity.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/domain/entity.go b/app/domain/entity.go
index 0377c51..0dc3995 100644
--- a/app/domain/entity.go
+++ b/app/domain/entity.go
@@ -1,6 +1,40 @@
package domain
+import (
+ "errors"
+
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
+)
+
type Entity interface {
Identifiable
Validate() error
}
+
+type defaultEntity struct {
+ ID ID `json:"id" jsonapi:"primary,entities"`
+}
+
+func (s *defaultEntity) GetID() ID {
+ return s.ID
+}
+
+func (s *defaultEntity) SetID(id ID) error {
+ s.ID = id
+ return nil
+}
+
+func (s *defaultEntity) ToGID() string {
+ return "gid://sparkle/Entity/" + s.ID.String()
+}
+
+func (self *defaultEntity) ToObjectReference() *v1.ObjectReference {
+ return &v1.ObjectReference{
+ ObjectType: "entity",
+ ObjectId: self.ID.String(),
+ }
+}
+
+func (s *defaultEntity) Validate() error {
+ return errors.New("method Validate not implemented")
+}