diff --git a/database/entities/common.go b/database/entities/common.go index 1061647..e7f977e 100644 --- a/database/entities/common.go +++ b/database/entities/common.go @@ -2,6 +2,9 @@ package entities import ( "time" + + "github.com/google/uuid" + "gorm.io/gorm" ) type Timestamp struct { @@ -9,7 +12,37 @@ type Timestamp struct { UpdatedAt time.Time `gorm:"type:timestamp with time zone" json:"updated_at"` } +// SoftDelete menyediakan soft delete functionality +type SoftDelete struct { + DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"` +} + +// TimestampWithSoftDelete menggabungkan timestamp dan soft delete +type TimestampWithSoftDelete struct { + Timestamp + SoftDelete +} + type Authorization struct { Token string `json:"token" binding:"required"` Role string `json:"role" binding:"required,oneof=user admin"` } + +// Audit menyediakan audit trail functionality +type Audit struct { + CreatedBy uuid.UUID `gorm:"type:uuid;not null" json:"created_by"` + UpdatedBy uuid.UUID `gorm:"type:uuid;not null" json:"updated_by"` +} + +// TimestampWithAudit menggabungkan timestamp dan audit +type TimestampWithAudit struct { + Timestamp + Audit +} + +// FullAuditTrail menggabungkan timestamp, audit, dan soft delete +type FullAuditTrail struct { + Timestamp + Audit + SoftDelete +}