34 lines
795 B
Go
34 lines
795 B
Go
package repository
|
|
|
|
import (
|
|
"BE-MiniERP/modules/sales/models"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type InvoiceLineRepository struct {
|
|
DB *gorm.DB
|
|
}
|
|
|
|
func NewInvoiceLineRepository(db *gorm.DB) *InvoiceLineRepository {
|
|
return &InvoiceLineRepository{DB: db}
|
|
}
|
|
|
|
func (r *InvoiceLineRepository) FindAll() ([]models.InvoiceLine, error) {
|
|
var result []models.InvoiceLine
|
|
err := r.DB.Find(&result).Error
|
|
return result, err
|
|
}
|
|
|
|
func (r *InvoiceLineRepository) Create(data *models.InvoiceLine) error {
|
|
return r.DB.Create(data).Error
|
|
}
|
|
|
|
func (r *InvoiceLineRepository) Update(id uint, data *models.InvoiceLine) error {
|
|
return r.DB.Model(&models.InvoiceLine{}).Where("id = ?", id).Updates(data).Error
|
|
}
|
|
|
|
func (r *InvoiceLineRepository) Delete(id uint) error {
|
|
return r.DB.Delete(&models.InvoiceLine{}, id).Error
|
|
}
|