-
Notifications
You must be signed in to change notification settings - Fork 0
/
category_product.go
154 lines (129 loc) · 3.07 KB
/
category_product.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
package main
import "log"
type categoryproduct struct {
category
product
ID int
CategoryID int
ProductID int
Forced bool
}
func (c *categoryproduct) getName() string {
return c.category.Name
}
func (c *categoryproduct) setSiteID(siteID int) {
}
func (c *categoryproduct) getEntityType() string {
return "categoryproduct"
}
func (c *categoryproduct) getSearchString() string {
return c.Search
}
func (c *categoryproduct) getDescription() string {
return c.category.Description
}
func (c *categoryproduct) getCategoryID() int {
return c.CategoryID
}
func (c *categoryproduct) getCreatedByID() int {
return c.CreatedByID
}
func (c *categoryproduct) setCreatedByID(createdById int) {
c.CreatedByID = createdById
}
func (c *categoryproduct) getDBAction() int {
return 0
}
func (c *categoryproduct) setDBAction(action int) {
c.category.DBAction = action
}
func (c *categoryproduct) getID() int {
return c.ID
}
func (c *categoryproduct) setCategoryID(id int) {
c.CategoryID = id
}
func (c *categoryproduct) insert(s *session) error {
var err error
return err
}
func (c *categoryproduct) update(s *session) error {
var err error
return err
}
func (c *categoryproduct) delete(s *session) error {
var err error
return err
}
func (c *categoryproduct) selectProducts(s *session) ([]categoryproduct, error) {
var categoryproducts []categoryproduct
rows, err := s.selectCategoryProductByCategoryProductIDStmt.Query(c.ID)
if err != nil {
log.Println(err)
return categoryproducts, err
}
defer rows.Close()
for rows.Next() {
cp := categoryproduct{}
err := rows.Scan(
&cp.ID,
&cp.product.SiteID,
&cp.product.FeedID,
&cp.product.Name,
&cp.product.NameByUser,
&cp.product.Identifier,
&cp.product.Price,
&cp.product.RegularPrice,
&cp.product.Description,
&cp.product.DescriptionByUser,
&cp.product.Currency,
&cp.product.ProductURL,
&cp.product.GraphicURL,
&cp.product.ShippingPrice,
&cp.product.InStock,
&cp.product.Points,
&cp.product.HasCategories,
&cp.product.Active,
&cp.CategoryID,
&cp.product.ID,
&cp.Forced,
)
if err != nil {
log.Println(err)
return categoryproducts, err
} else {
categoryproducts = append(categoryproducts, cp)
}
}
err = rows.Err()
return categoryproducts, err
}
// func (c *categoryproduct) indexesOf(slice []categoryinterface) []int {
// indexes := []int{}
// for i, ele := range slice {
// if strings.ToLower(ele.getName()) == strings.ToLower(c.getName()) {
// indexes = append(indexes, i)
// }
// }
// return indexes
// }
// func (c *categoryproduct) appendIfMissing(slice []categoryinterface) []categoryinterface {
// indexes := c.indexesOf(slice)
// if len(indexes) == 0 {
// return append(slice, c)
// }
// return slice
// }
// func (c *categoryproduct) removeIfPresent(slice []categoryinterface) []categoryinterface {
// indexes := c.indexesOf(slice)
// if len(indexes) > 0 {
// for i := range indexes {
// slice = append(slice[:i], slice[i+1:]...)
// }
// }
// return slice
// }
func syncProducts(s *session) error {
var err error
return err
}