-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCatalogProductIndexPriceOptTmp.go
80 lines (71 loc) · 3.03 KB
/
CatalogProductIndexPriceOptTmp.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
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
// CatalogProductIndexPriceOptTmp :
type CatalogProductIndexPriceOptTmp struct {
EntityId uint16 `gorm:"column:entity_id;primary_key" form:"entity_id;primary_key" json:"entity_id;primary_key"`
CustomerGroupId uint16 `gorm:"column:customer_group_id;primary_key" form:"customer_group_id;primary_key" json:"customer_group_id;primary_key"`
WebsiteId uint16 `gorm:"column:website_id;primary_key" form:"website_id;primary_key" json:"website_id;primary_key"`
MinPrice float64 `gorm:"column:min_price" form:"min_price" json:"min_price"`
MaxPrice float64 `gorm:"column:max_price" form:"max_price" json:"max_price"`
TierPrice float64 `gorm:"column:tier_price" form:"tier_price" json:"tier_price"`
GroupPrice float64 `gorm:"column:group_price" form:"group_price" json:"group_price"`
}
// TableName :
func (*CatalogProductIndexPriceOptTmp) TableName() string {
return "catalog_product_index_price_opt_tmp"
}
// handler create
func initRoutersCatalogProductIndexPriceOptTmp(r *gin.Engine, catalogproductindexpriceopttmp string) {
route := r.Group("catalogproductindexpriceopttmp")
route.GET("/", getCatalogProductIndexPriceOptTmps)
route.GET("/:id", getCatalogProductIndexPriceOptTmp)
route.POST("/", createCatalogProductIndexPriceOptTmp)
route.PUT("/:id", updateCatalogProductIndexPriceOptTmp)
route.DELETE("/:id", deleteCatalogProductIndexPriceOptTmp)
}
func getCatalogProductIndexPriceOptTmps(c *gin.Context) {
var catalogProductIndexPriceOptTmps []CatalogProductIndexPriceOptTmp
if err := g.Find(&catalogProductIndexPriceOptTmps).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
} else {
c.JSON(200, catalogProductIndexPriceOptTmps)
}
}
func getCatalogProductIndexPriceOptTmp(c *gin.Context) {
id := c.Params.ByName("id")
var catalogProductIndexPriceOptTmp CatalogProductIndexPriceOptTmp
if err := g.Where("id = ?", id).First(&catalogProductIndexPriceOptTmp).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
} else {
c.JSON(200, catalogProductIndexPriceOptTmp)
}
}
func createCatalogProductIndexPriceOptTmp(c *gin.Context) {
var catalogProductIndexPriceOptTmp CatalogProductIndexPriceOptTmp
c.BindJSON(&catalogProductIndexPriceOptTmp)
g.Create(&catalogProductIndexPriceOptTmp)
c.JSON(200, catalogProductIndexPriceOptTmp)
}
func updateCatalogProductIndexPriceOptTmp(c *gin.Context) {
var catalogProductIndexPriceOptTmp CatalogProductIndexPriceOptTmp
id := c.Params.ByName("id")
if err := g.Where("id = ?", id).First(&catalogProductIndexPriceOptTmp).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
}
c.BindJSON(&catalogProductIndexPriceOptTmp)
g.Save(&catalogProductIndexPriceOptTmp)
c.JSON(200, catalogProductIndexPriceOptTmp)
}
func deleteCatalogProductIndexPriceOptTmp(c *gin.Context) {
id := c.Params.ByName("id")
var catalogProductIndexPriceOptTmp CatalogProductIndexPriceOptTmp
d := g.Where("id = ?", id).Delete(&catalogProductIndexPriceOptTmp)
fmt.Println(d)
c.JSON(200, gin.H{"id #" + id: "deleted"})
}