WIP: Export Kontor DB
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-09-30 18:55:59 +02:00
parent 914e1214de
commit f5abb44466
52 changed files with 1458 additions and 146 deletions
+37
View File
@@ -0,0 +1,37 @@
package repository
import (
"context"
"kontor-api-gin/internal/models"
"log/slog"
"gorm.io/gorm"
)
type VendorRepository struct {
db *gorm.DB
}
func NewVendorRepository(db *gorm.DB) *VendorRepository {
repo := &VendorRepository{db: db}
return repo
}
func (repository *VendorRepository) FindAll(context context.Context) ([]models.Vendor, error) {
var vendors []models.Vendor
result := repository.db.Find(&vendors)
slog.Info("VendorRepository#FindAll", "count", result.RowsAffected)
return vendors, nil
}
func (repository *VendorRepository) GetById(context context.Context, id string) (models.Vendor, error) {
var vendor = models.Vendor{ID: id}
slog.Info("VendorRepository#GetById", "id", id)
result := repository.db.First(&vendor)
if result.Error != nil {
slog.Info("VendorRepository#GetById", "error", result.Error.Error())
}
return vendor, result.Error
}