-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCatalogCategoryProductIndexEnblIdx.go
75 lines (66 loc) · 2.62 KB
/
CatalogCategoryProductIndexEnblIdx.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
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
// CatalogCategoryProductIndexEnblIdx :
type CatalogCategoryProductIndexEnblIdx struct {
ProductId uint16 `gorm:"column:product_id" form:"product_id" json:"product_id"`
Visibility uint16 `gorm:"column:visibility" form:"visibility" json:"visibility"`
}
// TableName :
func (*CatalogCategoryProductIndexEnblIdx) TableName() string {
return "catalog_category_product_index_enbl_idx"
}
// handler create
func initRoutersCatalogCategoryProductIndexEnblIdx(r *gin.Engine, catalogcategoryproductindexenblidx string) {
route := r.Group("catalogcategoryproductindexenblidx")
route.GET("/", getCatalogCategoryProductIndexEnblIdxs)
route.GET("/:id", getCatalogCategoryProductIndexEnblIdx)
route.POST("/", createCatalogCategoryProductIndexEnblIdx)
route.PUT("/:id", updateCatalogCategoryProductIndexEnblIdx)
route.DELETE("/:id", deleteCatalogCategoryProductIndexEnblIdx)
}
func getCatalogCategoryProductIndexEnblIdxs(c *gin.Context) {
var catalogCategoryProductIndexEnblIdxs []CatalogCategoryProductIndexEnblIdx
if err := g.Find(&catalogCategoryProductIndexEnblIdxs).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
} else {
c.JSON(200, catalogCategoryProductIndexEnblIdxs)
}
}
func getCatalogCategoryProductIndexEnblIdx(c *gin.Context) {
id := c.Params.ByName("id")
var catalogCategoryProductIndexEnblIdx CatalogCategoryProductIndexEnblIdx
if err := g.Where("id = ?", id).First(&catalogCategoryProductIndexEnblIdx).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
} else {
c.JSON(200, catalogCategoryProductIndexEnblIdx)
}
}
func createCatalogCategoryProductIndexEnblIdx(c *gin.Context) {
var catalogCategoryProductIndexEnblIdx CatalogCategoryProductIndexEnblIdx
c.BindJSON(&catalogCategoryProductIndexEnblIdx)
g.Create(&catalogCategoryProductIndexEnblIdx)
c.JSON(200, catalogCategoryProductIndexEnblIdx)
}
func updateCatalogCategoryProductIndexEnblIdx(c *gin.Context) {
var catalogCategoryProductIndexEnblIdx CatalogCategoryProductIndexEnblIdx
id := c.Params.ByName("id")
if err := g.Where("id = ?", id).First(&catalogCategoryProductIndexEnblIdx).Error; err != nil {
c.AbortWithStatus(404)
fmt.Println(err)
}
c.BindJSON(&catalogCategoryProductIndexEnblIdx)
g.Save(&catalogCategoryProductIndexEnblIdx)
c.JSON(200, catalogCategoryProductIndexEnblIdx)
}
func deleteCatalogCategoryProductIndexEnblIdx(c *gin.Context) {
id := c.Params.ByName("id")
var catalogCategoryProductIndexEnblIdx CatalogCategoryProductIndexEnblIdx
d := g.Where("id = ?", id).Delete(&catalogCategoryProductIndexEnblIdx)
fmt.Println(d)
c.JSON(200, gin.H{"id #" + id: "deleted"})
}