Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditAction ¶
type AuditAction string
const ( ActionCreate AuditAction = "CREATE" ActionUpdate AuditAction = "UPDATE" ActionDelete AuditAction = "DELETE" ActionAccept AuditAction = "ACCEPT" ActionReject AuditAction = "REJECT" ActionComplete AuditAction = "COMPLETE" )
type AuditTrailModel ¶
type AuditTrailModel struct {
shared.BaseModel
UserID string `gorm:"not null"` // ID user yang melakukan aksi
Action AuditAction `gorm:"not null"` // Jenis aksi (CREATE, UPDATE, DELETE, dll.)
Entity string `gorm:"not null"` // Entitas yang terlibat (misalnya, "OrderRequest")
EntityID string `gorm:"not null"` // ID entitas yang terlibat
Details string `gorm:"type:json"`
}
func (*AuditTrailModel) BeforeCreate ¶
func (a *AuditTrailModel) BeforeCreate(tx *gorm.DB) (err error)
func (*AuditTrailModel) TableName ¶
func (a *AuditTrailModel) TableName() string
type AuditTrailService ¶
type AuditTrailService struct {
// contains filtered or unexported fields
}
func NewAuditTrailService ¶
func NewAuditTrailService(erpContext *context.ERPContext) *AuditTrailService
NewAuditTrailService creates a new instance of AuditTrailService with the given ERP context. It will call Migrate() if SkipMigration is not set to true.
func (*AuditTrailService) GetAuditTrails ¶
func (s *AuditTrailService) GetAuditTrails(entity string, entityID uint) ([]AuditTrailModel, error)
GetAuditTrails retrieves the audit trail for a given entity and entity ID.
It performs a query against the audit trail table with the given entity and entity ID, and returns the results. If the query fails, the error is returned to the caller.
The returned slice is empty if no audit trail records match the query.
func (*AuditTrailService) LogAction ¶
func (s *AuditTrailService) LogAction(userID string, action AuditAction, entity string, entityID, details string) error
LogAction creates a new audit trail record with the provided details.
It constructs an AuditTrailModel using the given userID, action, entity, entityID, and details, and inserts it into the database. If the insertion fails, the error is returned to the caller.