Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64c610597a
|
||
|
|
6863af47c3
|
||
|
|
05e830a824
|
@@ -4,14 +4,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"git.kundeng.us/phoenix/textsender-models/tx0/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageEventResponse struct {
|
type MessageEventResponse struct {
|
||||||
Id uuid.UUID `json:"id,omitempty"`
|
Id uuid.UUID `json:"id,omitempty"`
|
||||||
ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"`
|
ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"`
|
||||||
Response types.JSONB `json:"response"`
|
Response []byte `json:"response"`
|
||||||
UserId uuid.UUID `json:"user_id,omitempty"`
|
UserId uuid.UUID `json:"user_id,omitempty"`
|
||||||
Sent time.Time `json:"sent"`
|
Sent time.Time `json:"sent"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql/driver"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type JSONB json.RawMessage
|
|
||||||
|
|
||||||
// Scan implements sql.Scanner
|
|
||||||
func (j *JSONB) Scan(value interface{}) error {
|
|
||||||
if value == nil {
|
|
||||||
*j = nil
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var data []byte
|
|
||||||
switch v := value.(type) {
|
|
||||||
case []byte:
|
|
||||||
// pgx may pass data as []byte in binary format
|
|
||||||
data = v
|
|
||||||
case string:
|
|
||||||
// pgx may pass data as string in text format
|
|
||||||
data = []byte(v)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported type: %T", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
*j = JSONB(data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements driver.Valuer
|
|
||||||
func (j JSONB) Value() (driver.Value, error) {
|
|
||||||
if j == nil {
|
|
||||||
return nil, nil
|
|
||||||
} else {
|
|
||||||
return []byte(j), nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user