-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
119 lines (106 loc) · 2.16 KB
/
service.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package model
import (
"database/sql"
"time"
"github.com/claion-org/claiflow/pkg/cryptography"
)
//go:generate go run -mod=mod github.com/abice/go-enum --file=service.go --names --nocase=true
/*
ENUM(
none
database
)
*/
type ResultSaveType int
/*
ENUM(
regist = 0
sent = 1
processing = 2
succeeded = 4
failed = 8
)
*/
type StepStatus int
/*
ENUM(
low
middle
high
)
*/
type Priority int
/*
ENUM(
pdate
cluster_uuid
uuid
name
summary
template_uuid
flow
inputs
step_max
subscribed_channel
priority
created
)
*/
type ClusterServiceFields int
type ClusterService struct {
PartitionDate time.Time `column:"pdate"` // PK date
ClusterUUID string `column:"cluster_uuid"` // PK char(32) cluster.uuid
UUID string `column:"uuid"` // PK char(32) service.uuid
Name string `column:"name"`
Summary sql.NullString `column:"summary"`
TemplateUUID string `column:"template_uuid"`
Flow string `column:"flow"`
Inputs cryptography.CipherObject `column:"inputs"`
StepMax int `column:"step_max"`
SubscribedChannel sql.NullString `column:"subscribed_channel"`
Priority Priority `column:"priority"`
Created time.Time `column:"created"`
}
var _ ModelContext = (*ClusterService)(nil)
func (ClusterService) TableName() string { return "service" }
func (ClusterService) ColumnNames() []string {
return ClusterServiceFieldsNames()
}
func (r *ClusterService) Scan(s Scanner) error {
var (
created sql.NullTime
)
defer func() {
r.Created = created.Time
}()
return s.Scan(
&r.PartitionDate,
&r.ClusterUUID,
&r.UUID,
&r.Name,
&r.Summary,
&r.TemplateUUID,
&r.Flow,
&r.Inputs,
&r.StepMax,
&r.SubscribedChannel,
&r.Priority,
&created,
)
}
func (r ClusterService) ColumnValues() []any {
return []any{
r.PartitionDate,
r.ClusterUUID,
r.UUID,
r.Name,
r.Summary,
r.TemplateUUID,
r.Flow,
r.Inputs,
r.StepMax,
r.SubscribedChannel,
r.Priority,
r.Created,
}
}