api with functioning managment

This commit is contained in:
Fran Jurmanović
2025-02-05 00:26:12 +01:00
parent 954fe0ae82
commit 9118574203
26 changed files with 2017 additions and 55 deletions

View File

@@ -0,0 +1,88 @@
package repository
import (
"acc-server-manager/local/model"
"context"
"gorm.io/gorm"
)
type LookupRepository struct {
db *gorm.DB
}
func NewLookupRepository(db *gorm.DB) *LookupRepository {
return &LookupRepository{
db: db,
}
}
// GetTracks
// Gets Tracks rows from Lookup table.
//
// Args:
// context.Context: Application context
// Returns:
// model.LookupModel: Lookup object from database.
func (as LookupRepository) GetTracks(ctx context.Context) *[]model.Track {
db := as.db.WithContext(ctx)
TrackModel := new([]model.Track)
db.Find(&TrackModel)
return TrackModel
}
// GetCarModels
// Gets CarModels rows from Lookup table.
//
// Args:
// context.Context: Application context
// Returns:
// model.LookupModel: Lookup object from database.
func (as LookupRepository) GetCarModels(ctx context.Context) *[]model.CarModel {
db := as.db.WithContext(ctx)
CarModelModel := new([]model.CarModel)
db.Find(&CarModelModel)
return CarModelModel
}
// GetDriverCategories
// Gets DriverCategories rows from Lookup table.
//
// Args:
// context.Context: Application context
// Returns:
// model.LookupModel: Lookup object from database.
func (as LookupRepository) GetDriverCategories(ctx context.Context) *[]model.DriverCategory {
db := as.db.WithContext(ctx)
DriverCategoryModel := new([]model.DriverCategory)
db.Find(&DriverCategoryModel)
return DriverCategoryModel
}
// GetCupCategories
// Gets CupCategories rows from Lookup table.
//
// Args:
// context.Context: Application context
// Returns:
// model.LookupModel: Lookup object from database.
func (as LookupRepository) GetCupCategories(ctx context.Context) *[]model.CupCategory {
db := as.db.WithContext(ctx)
CupCategoryModel := new([]model.CupCategory)
db.Find(&CupCategoryModel)
return CupCategoryModel
}
// GetSessionTypes
// Gets SessionTypes rows from Lookup table.
//
// Args:
// context.Context: Application context
// Returns:
// model.LookupModel: Lookup object from database.
func (as LookupRepository) GetSessionTypes(ctx context.Context) *[]model.SessionType {
db := as.db.WithContext(ctx)
SessionTypesModel := new([]model.SessionType)
db.Find(&SessionTypesModel)
return SessionTypesModel
}