Kategorien und Produkte können zur DB hinzugefügt werden.
This commit is contained in:
@@ -24,6 +24,25 @@ type Product struct {
|
||||
DeletedAt gorm.DeletedAt
|
||||
}
|
||||
|
||||
func (p *Product) CreateProduct(db *gorm.DB, param *Product) (*Product, error) {
|
||||
product := &Product{
|
||||
ID: param.ID,
|
||||
Name: param.Name,
|
||||
Price: param.Price,
|
||||
CategoryID: param.CategoryID,
|
||||
Description: param.Description,
|
||||
ShortDescription: param.ShortDescription,
|
||||
CreatedAt: time.Time{},
|
||||
UpdatedAt: time.Time{},
|
||||
}
|
||||
|
||||
err := db.Debug().Create(&product).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return product, nil
|
||||
}
|
||||
|
||||
func (p *Product) GetProducts(db *gorm.DB, perPage int, page int) (*[]Product, int64, error) {
|
||||
|
||||
var count int64
|
||||
|
||||
Reference in New Issue
Block a user