-
Notifications
You must be signed in to change notification settings - Fork 28
/
serviceplan_gen.go
72 lines (60 loc) · 1.58 KB
/
serviceplan_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 = &ServicePlan{}
const ServicePlanTable = "service_plans"
func (*ServicePlan) LabelEntity() PostgresLabel {
return &ServicePlanLabel{}
}
func (*ServicePlan) TableName() string {
return ServicePlanTable
}
func (e *ServicePlan) NewLabel(id, key, value string) storage.Label {
now := pq.NullTime{
Time: time.Now(),
Valid: true,
}
return &ServicePlanLabel{
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,
},
ServicePlanID: sql.NullString{String: e.ID, Valid: e.ID != ""},
}
}
func (e *ServicePlan) RowsToList(rows *sqlx.Rows) (types.ObjectList, error) {
rowCreator := func() EntityLabelRow {
return &struct {
*ServicePlan
ServicePlanLabel `db:"service_plan_labels"`
}{}
}
result := &types.ServicePlans{
ServicePlans: make([]*types.ServicePlan, 0),
}
err := rowsToList(rows, rowCreator, result)
if err != nil {
return nil, err
}
return result, nil
}
type ServicePlanLabel struct {
BaseLabelEntity
ServicePlanID sql.NullString `db:"service_plan_id"`
}
func (el ServicePlanLabel) LabelsTableName() string {
return "service_plan_labels"
}
func (el ServicePlanLabel) ReferenceColumn() string {
return "service_plan_id"
}