datamodel done without validators
This commit is contained in:
15
wagfarm-api/assets/product/model.go
Normal file
15
wagfarm-api/assets/product/model.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"wagfarm-api/assets/base"
|
||||
"wagfarm-api/database"
|
||||
"wagfarm-api/taxonomy/producttype"
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
base.SoldResource
|
||||
ProductTypeID uint `gorm:"not null"`
|
||||
ProductType producttype.ProductType `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
func RegisterModels() { database.RegisterModel(&Product{}) }
|
||||
11
wagfarm-api/assets/product/route.go
Normal file
11
wagfarm-api/assets/product/route.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"wagfarm-api/generic"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RegisterRoutes(rg *gin.RouterGroup) {
|
||||
generic.RegisterCRUDRoutes(rg.Group("/product"), generic.DefaultCRUDController[Product]())
|
||||
}
|
||||
Reference in New Issue
Block a user