/
fnetdocument.go
416 lines (398 loc) · 16.8 KB
/
fnetdocument.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/lenon/gofii/ent/fnetcategory"
"github.com/lenon/gofii/ent/fnetdocument"
"github.com/lenon/gofii/ent/fnetsubcategory1"
"github.com/lenon/gofii/ent/fnetsubcategory2"
)
// FnetDocument is the model entity for the FnetDocument schema.
type FnetDocument struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// FnetID holds the value of the "fnet_id" field.
FnetID int `json:"fnet_id,omitempty"`
// AdditionalInformation holds the value of the "additional_information" field.
AdditionalInformation string `json:"additional_information,omitempty"`
// CategoryStr holds the value of the "category_str" field.
CategoryStr string `json:"category_str,omitempty"`
// FundDescription holds the value of the "fund_description" field.
FundDescription string `json:"fund_description,omitempty"`
// FundMarketName holds the value of the "fund_market_name" field.
FundMarketName string `json:"fund_market_name,omitempty"`
// HighPriority holds the value of the "high_priority" field.
HighPriority bool `json:"high_priority,omitempty"`
// ReferenceDate holds the value of the "reference_date" field.
ReferenceDate time.Time `json:"reference_date,omitempty"`
// ReferenceDateFormat holds the value of the "reference_date_format" field.
ReferenceDateFormat string `json:"reference_date_format,omitempty"`
// ReferenceDateStr holds the value of the "reference_date_str" field.
ReferenceDateStr string `json:"reference_date_str,omitempty"`
// Reviewed holds the value of the "reviewed" field.
Reviewed string `json:"reviewed,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// SubCategory1Str holds the value of the "sub_category1_str" field.
SubCategory1Str string `json:"sub_category1_str,omitempty"`
// SubCategory2Str holds the value of the "sub_category2_str" field.
SubCategory2Str string `json:"sub_category2_str,omitempty"`
// SubmissionDate holds the value of the "submission_date" field.
SubmissionDate time.Time `json:"submission_date,omitempty"`
// SubmissionDateStr holds the value of the "submission_date_str" field.
SubmissionDateStr string `json:"submission_date_str,omitempty"`
// SubmissionMethod holds the value of the "submission_method" field.
SubmissionMethod string `json:"submission_method,omitempty"`
// SubmissionMethodDescription holds the value of the "submission_method_description" field.
SubmissionMethodDescription string `json:"submission_method_description,omitempty"`
// SubmissionStatus holds the value of the "submission_status" field.
SubmissionStatus string `json:"submission_status,omitempty"`
// SubmissionStatusDescription holds the value of the "submission_status_description" field.
SubmissionStatusDescription string `json:"submission_status_description,omitempty"`
// Version holds the value of the "version" field.
Version int `json:"version,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the FnetDocumentQuery when eager-loading is set.
Edges FnetDocumentEdges `json:"edges"`
category_id *int
sub_category1_id *int
sub_category2_id *int
}
// FnetDocumentEdges holds the relations/edges for other nodes in the graph.
type FnetDocumentEdges struct {
// Category holds the value of the category edge.
Category *FnetCategory `json:"category,omitempty"`
// SubCategory1 holds the value of the sub_category1 edge.
SubCategory1 *FnetSubCategory1 `json:"sub_category1,omitempty"`
// SubCategory2 holds the value of the sub_category2 edge.
SubCategory2 *FnetSubCategory2 `json:"sub_category2,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [3]bool
}
// CategoryOrErr returns the Category value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e FnetDocumentEdges) CategoryOrErr() (*FnetCategory, error) {
if e.loadedTypes[0] {
if e.Category == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: fnetcategory.Label}
}
return e.Category, nil
}
return nil, &NotLoadedError{edge: "category"}
}
// SubCategory1OrErr returns the SubCategory1 value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e FnetDocumentEdges) SubCategory1OrErr() (*FnetSubCategory1, error) {
if e.loadedTypes[1] {
if e.SubCategory1 == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: fnetsubcategory1.Label}
}
return e.SubCategory1, nil
}
return nil, &NotLoadedError{edge: "sub_category1"}
}
// SubCategory2OrErr returns the SubCategory2 value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e FnetDocumentEdges) SubCategory2OrErr() (*FnetSubCategory2, error) {
if e.loadedTypes[2] {
if e.SubCategory2 == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: fnetsubcategory2.Label}
}
return e.SubCategory2, nil
}
return nil, &NotLoadedError{edge: "sub_category2"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*FnetDocument) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
for i := range columns {
switch columns[i] {
case fnetdocument.FieldHighPriority:
values[i] = new(sql.NullBool)
case fnetdocument.FieldID, fnetdocument.FieldFnetID, fnetdocument.FieldVersion:
values[i] = new(sql.NullInt64)
case fnetdocument.FieldAdditionalInformation, fnetdocument.FieldCategoryStr, fnetdocument.FieldFundDescription, fnetdocument.FieldFundMarketName, fnetdocument.FieldReferenceDateFormat, fnetdocument.FieldReferenceDateStr, fnetdocument.FieldReviewed, fnetdocument.FieldStatus, fnetdocument.FieldSubCategory1Str, fnetdocument.FieldSubCategory2Str, fnetdocument.FieldSubmissionDateStr, fnetdocument.FieldSubmissionMethod, fnetdocument.FieldSubmissionMethodDescription, fnetdocument.FieldSubmissionStatus, fnetdocument.FieldSubmissionStatusDescription:
values[i] = new(sql.NullString)
case fnetdocument.FieldReferenceDate, fnetdocument.FieldSubmissionDate:
values[i] = new(sql.NullTime)
case fnetdocument.ForeignKeys[0]: // category_id
values[i] = new(sql.NullInt64)
case fnetdocument.ForeignKeys[1]: // sub_category1_id
values[i] = new(sql.NullInt64)
case fnetdocument.ForeignKeys[2]: // sub_category2_id
values[i] = new(sql.NullInt64)
default:
return nil, fmt.Errorf("unexpected column %q for type FnetDocument", columns[i])
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the FnetDocument fields.
func (fd *FnetDocument) assignValues(columns []string, values []interface{}) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case fnetdocument.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
fd.ID = int(value.Int64)
case fnetdocument.FieldFnetID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field fnet_id", values[i])
} else if value.Valid {
fd.FnetID = int(value.Int64)
}
case fnetdocument.FieldAdditionalInformation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field additional_information", values[i])
} else if value.Valid {
fd.AdditionalInformation = value.String
}
case fnetdocument.FieldCategoryStr:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field category_str", values[i])
} else if value.Valid {
fd.CategoryStr = value.String
}
case fnetdocument.FieldFundDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field fund_description", values[i])
} else if value.Valid {
fd.FundDescription = value.String
}
case fnetdocument.FieldFundMarketName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field fund_market_name", values[i])
} else if value.Valid {
fd.FundMarketName = value.String
}
case fnetdocument.FieldHighPriority:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field high_priority", values[i])
} else if value.Valid {
fd.HighPriority = value.Bool
}
case fnetdocument.FieldReferenceDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field reference_date", values[i])
} else if value.Valid {
fd.ReferenceDate = value.Time
}
case fnetdocument.FieldReferenceDateFormat:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reference_date_format", values[i])
} else if value.Valid {
fd.ReferenceDateFormat = value.String
}
case fnetdocument.FieldReferenceDateStr:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reference_date_str", values[i])
} else if value.Valid {
fd.ReferenceDateStr = value.String
}
case fnetdocument.FieldReviewed:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reviewed", values[i])
} else if value.Valid {
fd.Reviewed = value.String
}
case fnetdocument.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
fd.Status = value.String
}
case fnetdocument.FieldSubCategory1Str:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sub_category1_str", values[i])
} else if value.Valid {
fd.SubCategory1Str = value.String
}
case fnetdocument.FieldSubCategory2Str:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sub_category2_str", values[i])
} else if value.Valid {
fd.SubCategory2Str = value.String
}
case fnetdocument.FieldSubmissionDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field submission_date", values[i])
} else if value.Valid {
fd.SubmissionDate = value.Time
}
case fnetdocument.FieldSubmissionDateStr:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field submission_date_str", values[i])
} else if value.Valid {
fd.SubmissionDateStr = value.String
}
case fnetdocument.FieldSubmissionMethod:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field submission_method", values[i])
} else if value.Valid {
fd.SubmissionMethod = value.String
}
case fnetdocument.FieldSubmissionMethodDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field submission_method_description", values[i])
} else if value.Valid {
fd.SubmissionMethodDescription = value.String
}
case fnetdocument.FieldSubmissionStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field submission_status", values[i])
} else if value.Valid {
fd.SubmissionStatus = value.String
}
case fnetdocument.FieldSubmissionStatusDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field submission_status_description", values[i])
} else if value.Valid {
fd.SubmissionStatusDescription = value.String
}
case fnetdocument.FieldVersion:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field version", values[i])
} else if value.Valid {
fd.Version = int(value.Int64)
}
case fnetdocument.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field category_id", value)
} else if value.Valid {
fd.category_id = new(int)
*fd.category_id = int(value.Int64)
}
case fnetdocument.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field sub_category1_id", value)
} else if value.Valid {
fd.sub_category1_id = new(int)
*fd.sub_category1_id = int(value.Int64)
}
case fnetdocument.ForeignKeys[2]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field sub_category2_id", value)
} else if value.Valid {
fd.sub_category2_id = new(int)
*fd.sub_category2_id = int(value.Int64)
}
}
}
return nil
}
// QueryCategory queries the "category" edge of the FnetDocument entity.
func (fd *FnetDocument) QueryCategory() *FnetCategoryQuery {
return (&FnetDocumentClient{config: fd.config}).QueryCategory(fd)
}
// QuerySubCategory1 queries the "sub_category1" edge of the FnetDocument entity.
func (fd *FnetDocument) QuerySubCategory1() *FnetSubCategory1Query {
return (&FnetDocumentClient{config: fd.config}).QuerySubCategory1(fd)
}
// QuerySubCategory2 queries the "sub_category2" edge of the FnetDocument entity.
func (fd *FnetDocument) QuerySubCategory2() *FnetSubCategory2Query {
return (&FnetDocumentClient{config: fd.config}).QuerySubCategory2(fd)
}
// Update returns a builder for updating this FnetDocument.
// Note that you need to call FnetDocument.Unwrap() before calling this method if this FnetDocument
// was returned from a transaction, and the transaction was committed or rolled back.
func (fd *FnetDocument) Update() *FnetDocumentUpdateOne {
return (&FnetDocumentClient{config: fd.config}).UpdateOne(fd)
}
// Unwrap unwraps the FnetDocument entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (fd *FnetDocument) Unwrap() *FnetDocument {
_tx, ok := fd.config.driver.(*txDriver)
if !ok {
panic("ent: FnetDocument is not a transactional entity")
}
fd.config.driver = _tx.drv
return fd
}
// String implements the fmt.Stringer.
func (fd *FnetDocument) String() string {
var builder strings.Builder
builder.WriteString("FnetDocument(")
builder.WriteString(fmt.Sprintf("id=%v, ", fd.ID))
builder.WriteString("fnet_id=")
builder.WriteString(fmt.Sprintf("%v", fd.FnetID))
builder.WriteString(", ")
builder.WriteString("additional_information=")
builder.WriteString(fd.AdditionalInformation)
builder.WriteString(", ")
builder.WriteString("category_str=")
builder.WriteString(fd.CategoryStr)
builder.WriteString(", ")
builder.WriteString("fund_description=")
builder.WriteString(fd.FundDescription)
builder.WriteString(", ")
builder.WriteString("fund_market_name=")
builder.WriteString(fd.FundMarketName)
builder.WriteString(", ")
builder.WriteString("high_priority=")
builder.WriteString(fmt.Sprintf("%v", fd.HighPriority))
builder.WriteString(", ")
builder.WriteString("reference_date=")
builder.WriteString(fd.ReferenceDate.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("reference_date_format=")
builder.WriteString(fd.ReferenceDateFormat)
builder.WriteString(", ")
builder.WriteString("reference_date_str=")
builder.WriteString(fd.ReferenceDateStr)
builder.WriteString(", ")
builder.WriteString("reviewed=")
builder.WriteString(fd.Reviewed)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fd.Status)
builder.WriteString(", ")
builder.WriteString("sub_category1_str=")
builder.WriteString(fd.SubCategory1Str)
builder.WriteString(", ")
builder.WriteString("sub_category2_str=")
builder.WriteString(fd.SubCategory2Str)
builder.WriteString(", ")
builder.WriteString("submission_date=")
builder.WriteString(fd.SubmissionDate.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("submission_date_str=")
builder.WriteString(fd.SubmissionDateStr)
builder.WriteString(", ")
builder.WriteString("submission_method=")
builder.WriteString(fd.SubmissionMethod)
builder.WriteString(", ")
builder.WriteString("submission_method_description=")
builder.WriteString(fd.SubmissionMethodDescription)
builder.WriteString(", ")
builder.WriteString("submission_status=")
builder.WriteString(fd.SubmissionStatus)
builder.WriteString(", ")
builder.WriteString("submission_status_description=")
builder.WriteString(fd.SubmissionStatusDescription)
builder.WriteString(", ")
builder.WriteString("version=")
builder.WriteString(fmt.Sprintf("%v", fd.Version))
builder.WriteByte(')')
return builder.String()
}
// FnetDocuments is a parsable slice of FnetDocument.
type FnetDocuments []*FnetDocument
func (fd FnetDocuments) config(cfg config) {
for _i := range fd {
fd[_i].config = cfg
}
}