2021-09-01 20:46:15 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MarshalJSON returns the JSON encoding.
|
|
|
|
func (m *Marker) MarshalJSON() ([]byte, error) {
|
|
|
|
var subj *Subject
|
|
|
|
var name string
|
|
|
|
|
|
|
|
if subj = m.Subject(); subj == nil {
|
|
|
|
name = m.MarkerName
|
|
|
|
} else {
|
2021-09-17 14:26:12 +02:00
|
|
|
name = subj.SubjName
|
2021-09-01 20:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return json.Marshal(&struct {
|
2021-09-17 14:26:12 +02:00
|
|
|
UID string
|
|
|
|
FileUID string
|
|
|
|
FileHash string
|
|
|
|
CropArea string
|
|
|
|
Type string
|
|
|
|
Src string
|
|
|
|
Name string
|
|
|
|
Invalid bool
|
|
|
|
Review bool
|
|
|
|
FaceID string
|
|
|
|
SubjUID string
|
|
|
|
SubjSrc string
|
|
|
|
X float32
|
|
|
|
Y float32
|
|
|
|
W float32 `json:",omitempty"`
|
|
|
|
H float32 `json:",omitempty"`
|
2021-09-17 18:51:24 +02:00
|
|
|
Q int `json:",omitempty"`
|
2021-09-17 14:26:12 +02:00
|
|
|
Size int `json:",omitempty"`
|
|
|
|
Score int `json:",omitempty"`
|
|
|
|
CreatedAt time.Time
|
2021-09-01 20:46:15 +02:00
|
|
|
}{
|
2021-09-17 14:26:12 +02:00
|
|
|
UID: m.MarkerUID,
|
|
|
|
FileUID: m.FileUID,
|
|
|
|
FileHash: m.FileHash,
|
|
|
|
CropArea: m.CropArea,
|
|
|
|
Type: m.MarkerType,
|
|
|
|
Src: m.MarkerSrc,
|
|
|
|
Name: name,
|
|
|
|
Invalid: m.MarkerInvalid,
|
|
|
|
Review: m.MarkerReview,
|
|
|
|
FaceID: m.FaceID,
|
|
|
|
SubjUID: m.SubjUID,
|
|
|
|
SubjSrc: m.SubjSrc,
|
|
|
|
X: m.X,
|
|
|
|
Y: m.Y,
|
|
|
|
W: m.W,
|
|
|
|
H: m.H,
|
2021-09-17 18:51:24 +02:00
|
|
|
Q: m.Q,
|
2021-09-17 14:26:12 +02:00
|
|
|
Size: m.Size,
|
|
|
|
Score: m.Score,
|
|
|
|
CreatedAt: m.CreatedAt,
|
2021-09-01 20:46:15 +02:00
|
|
|
})
|
|
|
|
}
|