-
Notifications
You must be signed in to change notification settings - Fork 28
/
platform_gen.go
72 lines (60 loc) · 1.51 KB
/
platform_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// GENERATED. DO NOT MODIFY!
package postgres
import (
"github.com/Peripli/service-manager/pkg/types"
"github.com/Peripli/service-manager/storage"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"database/sql"
"time"
)
var _ PostgresEntity = &Platform{}
const PlatformTable = "platforms"
func (*Platform) LabelEntity() PostgresLabel {
return &PlatformLabel{}
}
func (*Platform) TableName() string {
return PlatformTable
}
func (e *Platform) NewLabel(id, key, value string) storage.Label {
now := pq.NullTime{
Time: time.Now(),
Valid: true,
}
return &PlatformLabel{
BaseLabelEntity: BaseLabelEntity{
ID: sql.NullString{String: id, Valid: id != ""},
Key: sql.NullString{String: key, Valid: key != ""},
Val: sql.NullString{String: value, Valid: value != ""},
CreatedAt: now,
UpdatedAt: now,
},
PlatformID: sql.NullString{String: e.ID, Valid: e.ID != ""},
}
}
func (e *Platform) RowsToList(rows *sqlx.Rows) (types.ObjectList, error) {
rowCreator := func() EntityLabelRow {
return &struct {
*Platform
PlatformLabel `db:"platform_labels"`
}{}
}
result := &types.Platforms{
Platforms: make([]*types.Platform, 0),
}
err := rowsToList(rows, rowCreator, result)
if err != nil {
return nil, err
}
return result, nil
}
type PlatformLabel struct {
BaseLabelEntity
PlatformID sql.NullString `db:"platform_id"`
}
func (el PlatformLabel) LabelsTableName() string {
return "platform_labels"
}
func (el PlatformLabel) ReferenceColumn() string {
return "platform_id"
}