49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package entities
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Timestamp struct {
|
|
CreatedAt time.Time `gorm:"type:timestamp with time zone" json:"created_at"`
|
|
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
|
|
}
|