-
Notifications
You must be signed in to change notification settings - Fork 25
/
entities_gen.go
630 lines (568 loc) · 17.6 KB
/
entities_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
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
// Code generated by codegen. DO NOT EDIT.
// Generated by sql/dmlgen. DO NOT EDIT.
package store
import (
"fmt"
"io"
"github.com/corestoreio/errors"
"github.com/corestoreio/pkg/storage/null"
)
// Store represents a single row for DB table store. Auto generated.
//easyjson:json
type Store struct {
StoreID uint32 `max_len:"5"` // store_id smallint(5) unsigned NOT NULL PRI auto_increment "Store ID"
Code string `max_len:"64"` // code varchar(64) NOT NULL UNI "Code"
WebsiteID uint32 `max_len:"5"` // website_id smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Website ID"
GroupID uint32 `max_len:"5"` // group_id smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Group ID"
Name string `max_len:"255"` // name varchar(255) NOT NULL "Store Name"
SortOrder uint32 `max_len:"5"` // sort_order smallint(5) unsigned NOT NULL DEFAULT '0' "Store Sort Order"
IsActive bool `max_len:"5"` // is_active smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Store Activity"
StoreGroup *StoreGroup // 1:1 store.group_id => store_group.group_id
StoreWebsite *StoreWebsite // 1:1 store.website_id => store_website.website_id
}
// Copy copies the struct and returns a new pointer
func (e *Store) Copy() *Store {
e2 := new(Store)
*e2 = *e // for now a shallow copy
return e2
}
// Empty empties all the fields of the current object. Also known as Reset.
func (e *Store) Empty() *Store { *e = Store{}; return e }
// This variable can be set in another file to provide a custom validator.
var validateStore func(*Store) error
// Validate runs internal consistency tests.
func (e *Store) Validate() error {
if e == nil {
return errors.NotValid.Newf("Type %T cannot be nil", e)
}
if validateStore != nil {
return validateStore(e)
}
return nil
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (e *Store) WriteTo(w io.Writer) (n int64, err error) {
// for now this printing is good enough. If you need better swap out with your code.
n2, err := fmt.Fprint(w,
"store_id:", e.StoreID, "\n",
"code:", e.Code, "\n",
"website_id:", e.WebsiteID, "\n",
"group_id:", e.GroupID, "\n",
"name:", e.Name, "\n",
"sort_order:", e.SortOrder, "\n",
"is_active:", e.IsActive, "\n",
)
return int64(n2), err
}
// Stores represents a collection type for DB table store
// Not thread safe. Auto generated.
//easyjson:json
type Stores struct {
Data []*Store `json:"data,omitempty"`
}
// NewStores creates a new initialized collection. Auto generated.
func NewStores() *Stores {
return &Stores{
Data: make([]*Store, 0, 5),
}
}
// Append will add a new item at the end of * Stores . Auto generated via dmlgen.
func (cc *Stores) Append(n ...*Store) *Stores {
cc.Data = append(cc.Data, n...)
return cc
}
// Cut will remove items i through j-1. Auto generated via dmlgen.
func (cc *Stores) Cut(i, j int) *Stores {
z := cc.Data // copy slice header
copy(z[i:], z[j:])
for k, n := len(z)-j+i, len(z); k < n; k++ {
z[k] = nil // this avoids the memory leak
}
z = z[:len(z)-j+i]
cc.Data = z
return cc
}
// Delete will remove an item from the slice. Auto generated via dmlgen.
func (cc *Stores) Delete(i int) *Stores {
z := cc.Data // copy the slice header
end := len(z) - 1
cc.Swap(i, end)
copy(z[i:], z[i+1:])
z[end] = nil // this should avoid the memory leak
z = z[:end]
cc.Data = z
return cc
}
// Each will run function f on all items in []* Store . Auto generated via
// dmlgen.
func (cc *Stores) Each(f func(*Store)) *Stores {
if cc == nil {
return nil
}
for i := range cc.Data {
f(cc.Data[i])
}
return cc
}
// Filter filters the current slice by predicate f without memory allocation.
// Auto generated via dmlgen.
func (cc *Stores) Filter(f func(*Store) bool) *Stores {
if cc == nil {
return nil
}
b, i := cc.Data[:0], 0
for _, e := range cc.Data {
if f(e) {
b = append(b, e)
}
i++
}
for i := len(b); i < len(cc.Data); i++ {
cc.Data[i] = nil // this should avoid the memory leak
}
cc.Data = b
return cc
}
// Insert will place a new item at position i. Auto generated via dmlgen.
func (cc *Stores) Insert(n *Store, i int) *Stores {
z := cc.Data // copy the slice header
z = append(z, &Store{})
copy(z[i+1:], z[i:])
z[i] = n
cc.Data = z
return cc
}
// Swap will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *Stores) Swap(i, j int) { cc.Data[i], cc.Data[j] = cc.Data[j], cc.Data[i] }
// Len will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *Stores) Len() int {
if cc == nil {
return 0
}
return len(cc.Data)
}
// StoreIDs returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *Stores) StoreIDs(ret ...uint32) []uint32 {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]uint32, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.StoreID)
}
return ret
}
// Codes returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *Stores) Codes(ret ...string) []string {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]string, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.Code)
}
return ret
}
// Validate runs internal consistency tests on all items.
func (cc *Stores) Validate() (err error) {
if len(cc.Data) == 0 {
return nil
}
for i, ld := 0, len(cc.Data); i < ld && err == nil; i++ {
err = cc.Data[i].Validate()
}
return
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (cc *Stores) WriteTo(w io.Writer) (n int64, err error) {
for i, d := range cc.Data {
n2, err := d.WriteTo(w)
if err != nil {
return 0, errors.Wrapf(err, "[store] WriteTo failed at index %d", i)
}
n += n2
}
return n, nil
}
// StoreGroup represents a single row for DB table store_group. Auto generated.
//easyjson:json
type StoreGroup struct {
GroupID uint32 `max_len:"5"` // group_id smallint(5) unsigned NOT NULL PRI auto_increment "Group ID"
WebsiteID uint32 `max_len:"5"` // website_id smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Website ID"
Name string `max_len:"255"` // name varchar(255) NOT NULL "Store Group Name"
RootCategoryID uint32 `max_len:"10"` // root_category_id int(10) unsigned NOT NULL DEFAULT '0' "Root Category ID"
DefaultStoreID uint32 `max_len:"5"` // default_store_id smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Default Store ID"
Code string `max_len:"64"` // code varchar(64) NOT NULL UNI "Store group unique code"
StoreWebsite *StoreWebsite // 1:1 store_group.website_id => store_website.website_id
}
// Copy copies the struct and returns a new pointer
func (e *StoreGroup) Copy() *StoreGroup {
e2 := new(StoreGroup)
*e2 = *e // for now a shallow copy
return e2
}
// Empty empties all the fields of the current object. Also known as Reset.
func (e *StoreGroup) Empty() *StoreGroup { *e = StoreGroup{}; return e }
// This variable can be set in another file to provide a custom validator.
var validateStoreGroup func(*StoreGroup) error
// Validate runs internal consistency tests.
func (e *StoreGroup) Validate() error {
if e == nil {
return errors.NotValid.Newf("Type %T cannot be nil", e)
}
if validateStoreGroup != nil {
return validateStoreGroup(e)
}
return nil
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (e *StoreGroup) WriteTo(w io.Writer) (n int64, err error) {
// for now this printing is good enough. If you need better swap out with your code.
n2, err := fmt.Fprint(w,
"group_id:", e.GroupID, "\n",
"website_id:", e.WebsiteID, "\n",
"name:", e.Name, "\n",
"root_category_id:", e.RootCategoryID, "\n",
"default_store_id:", e.DefaultStoreID, "\n",
"code:", e.Code, "\n",
)
return int64(n2), err
}
// StoreGroups represents a collection type for DB table store_group
// Not thread safe. Auto generated.
//easyjson:json
type StoreGroups struct {
Data []*StoreGroup `json:"data,omitempty"`
}
// NewStoreGroups creates a new initialized collection. Auto generated.
func NewStoreGroups() *StoreGroups {
return &StoreGroups{
Data: make([]*StoreGroup, 0, 5),
}
}
// Append will add a new item at the end of * StoreGroups . Auto generated via
// dmlgen.
func (cc *StoreGroups) Append(n ...*StoreGroup) *StoreGroups {
cc.Data = append(cc.Data, n...)
return cc
}
// Cut will remove items i through j-1. Auto generated via dmlgen.
func (cc *StoreGroups) Cut(i, j int) *StoreGroups {
z := cc.Data // copy slice header
copy(z[i:], z[j:])
for k, n := len(z)-j+i, len(z); k < n; k++ {
z[k] = nil // this avoids the memory leak
}
z = z[:len(z)-j+i]
cc.Data = z
return cc
}
// Delete will remove an item from the slice. Auto generated via dmlgen.
func (cc *StoreGroups) Delete(i int) *StoreGroups {
z := cc.Data // copy the slice header
end := len(z) - 1
cc.Swap(i, end)
copy(z[i:], z[i+1:])
z[end] = nil // this should avoid the memory leak
z = z[:end]
cc.Data = z
return cc
}
// Each will run function f on all items in []* StoreGroup . Auto generated via
// dmlgen.
func (cc *StoreGroups) Each(f func(*StoreGroup)) *StoreGroups {
if cc == nil {
return nil
}
for i := range cc.Data {
f(cc.Data[i])
}
return cc
}
// Filter filters the current slice by predicate f without memory allocation.
// Auto generated via dmlgen.
func (cc *StoreGroups) Filter(f func(*StoreGroup) bool) *StoreGroups {
if cc == nil {
return nil
}
b, i := cc.Data[:0], 0
for _, e := range cc.Data {
if f(e) {
b = append(b, e)
}
i++
}
for i := len(b); i < len(cc.Data); i++ {
cc.Data[i] = nil // this should avoid the memory leak
}
cc.Data = b
return cc
}
// Insert will place a new item at position i. Auto generated via dmlgen.
func (cc *StoreGroups) Insert(n *StoreGroup, i int) *StoreGroups {
z := cc.Data // copy the slice header
z = append(z, &StoreGroup{})
copy(z[i+1:], z[i:])
z[i] = n
cc.Data = z
return cc
}
// Swap will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *StoreGroups) Swap(i, j int) { cc.Data[i], cc.Data[j] = cc.Data[j], cc.Data[i] }
// Len will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *StoreGroups) Len() int {
if cc == nil {
return 0
}
return len(cc.Data)
}
// GroupIDs returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *StoreGroups) GroupIDs(ret ...uint32) []uint32 {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]uint32, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.GroupID)
}
return ret
}
// Codes returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *StoreGroups) Codes(ret ...string) []string {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]string, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.Code)
}
return ret
}
// Validate runs internal consistency tests on all items.
func (cc *StoreGroups) Validate() (err error) {
if len(cc.Data) == 0 {
return nil
}
for i, ld := 0, len(cc.Data); i < ld && err == nil; i++ {
err = cc.Data[i].Validate()
}
return
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (cc *StoreGroups) WriteTo(w io.Writer) (n int64, err error) {
for i, d := range cc.Data {
n2, err := d.WriteTo(w)
if err != nil {
return 0, errors.Wrapf(err, "[store] WriteTo failed at index %d", i)
}
n += n2
}
return n, nil
}
// StoreWebsite represents a single row for DB table store_website. Auto
// generated.
//easyjson:json
type StoreWebsite struct {
WebsiteID uint32 `max_len:"5"` // website_id smallint(5) unsigned NOT NULL PRI auto_increment "Website ID"
Code string `max_len:"64"` // code varchar(64) NOT NULL UNI "Code"
Name null.String `max_len:"128"` // name varchar(128) NULL DEFAULT 'NULL' "Website Name"
SortOrder uint32 `max_len:"5"` // sort_order smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Sort Order"
DefaultGroupID uint32 `max_len:"5"` // default_group_id smallint(5) unsigned NOT NULL MUL DEFAULT '0' "Default Group ID"
IsDefault bool `max_len:"5"` // is_default smallint(5) unsigned NOT NULL DEFAULT '0' "Defines Is Website Default"
Stores *Stores // Reversed 1:M store_website.website_id => store.website_id
StoreGroups *StoreGroups // Reversed 1:M store_website.website_id => store_group.website_id
}
// Copy copies the struct and returns a new pointer
func (e *StoreWebsite) Copy() *StoreWebsite {
e2 := new(StoreWebsite)
*e2 = *e // for now a shallow copy
return e2
}
// Empty empties all the fields of the current object. Also known as Reset.
func (e *StoreWebsite) Empty() *StoreWebsite { *e = StoreWebsite{}; return e }
// This variable can be set in another file to provide a custom validator.
var validateStoreWebsite func(*StoreWebsite) error
// Validate runs internal consistency tests.
func (e *StoreWebsite) Validate() error {
if e == nil {
return errors.NotValid.Newf("Type %T cannot be nil", e)
}
if validateStoreWebsite != nil {
return validateStoreWebsite(e)
}
return nil
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (e *StoreWebsite) WriteTo(w io.Writer) (n int64, err error) {
// for now this printing is good enough. If you need better swap out with your code.
n2, err := fmt.Fprint(w,
"website_id:", e.WebsiteID, "\n",
"code:", e.Code, "\n",
"name:", e.Name, "\n",
"sort_order:", e.SortOrder, "\n",
"default_group_id:", e.DefaultGroupID, "\n",
"is_default:", e.IsDefault, "\n",
)
return int64(n2), err
}
// StoreWebsites represents a collection type for DB table store_website
// Not thread safe. Auto generated.
//easyjson:json
type StoreWebsites struct {
Data []*StoreWebsite `json:"data,omitempty"`
}
// NewStoreWebsites creates a new initialized collection. Auto generated.
func NewStoreWebsites() *StoreWebsites {
return &StoreWebsites{
Data: make([]*StoreWebsite, 0, 5),
}
}
// Append will add a new item at the end of * StoreWebsites . Auto generated via
// dmlgen.
func (cc *StoreWebsites) Append(n ...*StoreWebsite) *StoreWebsites {
cc.Data = append(cc.Data, n...)
return cc
}
// Cut will remove items i through j-1. Auto generated via dmlgen.
func (cc *StoreWebsites) Cut(i, j int) *StoreWebsites {
z := cc.Data // copy slice header
copy(z[i:], z[j:])
for k, n := len(z)-j+i, len(z); k < n; k++ {
z[k] = nil // this avoids the memory leak
}
z = z[:len(z)-j+i]
cc.Data = z
return cc
}
// Delete will remove an item from the slice. Auto generated via dmlgen.
func (cc *StoreWebsites) Delete(i int) *StoreWebsites {
z := cc.Data // copy the slice header
end := len(z) - 1
cc.Swap(i, end)
copy(z[i:], z[i+1:])
z[end] = nil // this should avoid the memory leak
z = z[:end]
cc.Data = z
return cc
}
// Each will run function f on all items in []* StoreWebsite . Auto generated via
// dmlgen.
func (cc *StoreWebsites) Each(f func(*StoreWebsite)) *StoreWebsites {
if cc == nil {
return nil
}
for i := range cc.Data {
f(cc.Data[i])
}
return cc
}
// Filter filters the current slice by predicate f without memory allocation.
// Auto generated via dmlgen.
func (cc *StoreWebsites) Filter(f func(*StoreWebsite) bool) *StoreWebsites {
if cc == nil {
return nil
}
b, i := cc.Data[:0], 0
for _, e := range cc.Data {
if f(e) {
b = append(b, e)
}
i++
}
for i := len(b); i < len(cc.Data); i++ {
cc.Data[i] = nil // this should avoid the memory leak
}
cc.Data = b
return cc
}
// Insert will place a new item at position i. Auto generated via dmlgen.
func (cc *StoreWebsites) Insert(n *StoreWebsite, i int) *StoreWebsites {
z := cc.Data // copy the slice header
z = append(z, &StoreWebsite{})
copy(z[i+1:], z[i:])
z[i] = n
cc.Data = z
return cc
}
// Swap will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *StoreWebsites) Swap(i, j int) { cc.Data[i], cc.Data[j] = cc.Data[j], cc.Data[i] }
// Len will satisfy the sort.Interface. Auto generated via dmlgen.
func (cc *StoreWebsites) Len() int {
if cc == nil {
return 0
}
return len(cc.Data)
}
// WebsiteIDs returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *StoreWebsites) WebsiteIDs(ret ...uint32) []uint32 {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]uint32, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.WebsiteID)
}
return ret
}
// Codes returns a slice with the data or appends it to a slice.
// Auto generated.
func (cc *StoreWebsites) Codes(ret ...string) []string {
if cc == nil {
return nil
}
if ret == nil {
ret = make([]string, 0, len(cc.Data))
}
for _, e := range cc.Data {
ret = append(ret, e.Code)
}
return ret
}
// Validate runs internal consistency tests on all items.
func (cc *StoreWebsites) Validate() (err error) {
if len(cc.Data) == 0 {
return nil
}
for i, ld := 0, len(cc.Data); i < ld && err == nil; i++ {
err = cc.Data[i].Validate()
}
return
}
// WriteTo implements io.WriterTo and writes the field names and their values to
// w. This is especially useful for debugging or or generating a hash of the
// struct.
func (cc *StoreWebsites) WriteTo(w io.Writer) (n int64, err error) {
for i, d := range cc.Data {
n2, err := d.WriteTo(w)
if err != nil {
return 0, errors.Wrapf(err, "[store] WriteTo failed at index %d", i)
}
n += n2
}
return n, nil
}