This commit is contained in:
@@ -11,7 +11,7 @@ type Audit struct {
|
||||
UserId int `db:"UserId" json:"userId"`
|
||||
SecretId int `db:"SecretId" json:"secretId"`
|
||||
EventText string `db:"EventText" json:"eventText"`
|
||||
Timestamp time.Time `db:"Timestamp" json:"Timestamp"`
|
||||
EventTime time.Time `db:"EventTime" json:"eventTime"`
|
||||
}
|
||||
|
||||
// AuditAdd adds a new audit record to the database
|
||||
@@ -19,11 +19,11 @@ func (a *Audit) AuditAdd() (*Audit, error) {
|
||||
var err error
|
||||
|
||||
// Populate timestamp field if not already set
|
||||
if a.Timestamp.IsZero() {
|
||||
a.Timestamp = time.Now()
|
||||
if a.EventTime.IsZero() {
|
||||
a.EventTime = time.Now()
|
||||
}
|
||||
|
||||
result, err := db.NamedExec(("INSERT INTO audit (UserId, SecretId, EventText, Timestamp) VALUES (:UserId, :SecretId, :EventText, :Timestamp);"), a)
|
||||
result, err := db.NamedExec(("INSERT INTO audit (UserId, SecretId, EventText, EventTime) VALUES (:UserId, :SecretId, :EventText, :EventTime);"), a)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("AuditAdd error executing sql record : '%s'\n", err)
|
||||
|
@@ -84,7 +84,7 @@ const createAudit string = `
|
||||
UserId INTEGER DEFAULT 0,
|
||||
SecretId INTEGER DEFAULT 0,
|
||||
EventText VARCHAR,
|
||||
Timestamp datetime
|
||||
EventTime datetime
|
||||
);
|
||||
`
|
||||
|
||||
|
BIN
www/database.png
BIN
www/database.png
Binary file not shown.
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 80 KiB |
Reference in New Issue
Block a user