Files

20 lines
544 B
Go

package middleware
import (
"encoding/json"
"lan-manager/server/db"
)
func LogOperation(action, entityType string, entityID *int64, entityName, oldValue, newValue, sourceIP, username string) {
_, _ = db.DB.Exec(
`INSERT INTO operation_logs (action, entity_type, entity_id, entity_name, old_value, new_value, source_ip, username)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
action, entityType, entityID, entityName, oldValue, newValue, sourceIP, username,
)
}
func ToJSON(v interface{}) string {
b, _ := json.Marshal(v)
return string(b)
}