mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 15:46:37 +08:00
Merge remote-tracking branch 'wavelet/main'
This commit is contained in:
@@ -5,6 +5,9 @@ package contracts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql/driver"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -21,6 +24,27 @@ type UploadMetadataDTO struct {
|
|||||||
Extra map[string]any `json:"extra,omitempty"`
|
Extra map[string]any `json:"extra,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Value implements the driver.Valuer interface for database serialization.
|
||||||
|
func (m UploadMetadataDTO) Value() (driver.Value, error) {
|
||||||
|
return json.Marshal(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan implements the sql.Scanner interface for database deserialization.
|
||||||
|
func (m *UploadMetadataDTO) Scan(value any) error {
|
||||||
|
if value == nil {
|
||||||
|
*m = UploadMetadataDTO{}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
switch v := value.(type) {
|
||||||
|
case []byte:
|
||||||
|
return json.Unmarshal(v, m)
|
||||||
|
case string:
|
||||||
|
return json.Unmarshal([]byte(v), m)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("cannot scan type %T into UploadMetadataDTO", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// UploadDTO represents an uploaded file record.
|
// UploadDTO represents an uploaded file record.
|
||||||
type UploadDTO struct {
|
type UploadDTO struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|||||||
Reference in New Issue
Block a user