sourcen übernommen und wieder compilierbar gemacht.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func InitConfig(fileName string) *viper.Viper {
|
||||
config := viper.New()
|
||||
config.SetConfigName(fileName)
|
||||
config.AddConfigPath(".")
|
||||
config.AddConfigPath("$HOME")
|
||||
err := config.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Fatal("Error while parsing configuration file! ", err)
|
||||
}
|
||||
return config
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ImportHandler struct {
|
||||
importService *services.Import_Service
|
||||
}
|
||||
|
||||
func NewImportHandler(i *services.Import_Service) *ImportHandler {
|
||||
return &ImportHandler{
|
||||
importService: i,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *ImportHandler) ImportPropertyTypeGroups(ctx *gin.Context) {
|
||||
// Implement the logic to import property types groups here
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MainHandler struct {
|
||||
propertyTypeService *services.PropertyTypeService
|
||||
}
|
||||
|
||||
func NewMainHandler(p *services.PropertyTypeService) *MainHandler {
|
||||
return &MainHandler{
|
||||
propertyTypeService: p,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *MainHandler) Home(ctx *gin.Context) {
|
||||
// Implement the logic for the main handler's home endpoint here
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PropertyTypeHandler struct {
|
||||
propertyTypeService *services.PropertyTypeService
|
||||
}
|
||||
|
||||
func NewPropertyTypeHandler(propertyTypeService *services.PropertyTypeService) *PropertyTypeHandler {
|
||||
return &PropertyTypeHandler{
|
||||
propertyTypeService: propertyTypeService,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *PropertyTypeHandler) GetRootPropertyTypeGroups(ctx *gin.Context) {
|
||||
// Implement the logic to get root property types groups here
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
type Product struct {
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
ImageURL string
|
||||
Properties []Property
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
type ProductGroup struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
Properties []Property `json:"properties,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
type Property struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
//Property_Type *Property_Type `json:"property_type,omitempty"`
|
||||
Parent_Property *Property `json:"parent_property,omitempty"`
|
||||
Products_Group *ProductGroup `json:"products_group,omitempty"`
|
||||
Product *Product `json:"products,omitempty"`
|
||||
Values []Value `json:"values,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
type Property_Type struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
Property Property `json:"property"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type PropertyTypeGroup struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
PropertyTypes []Property_Type `json:"PropertyTypes,omitempty"`
|
||||
PropertyTypeGroups []PropertyTypeGroup `json:"PropertyTypeGroups,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
type Value struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Value string `json:"value"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type ImportRepository struct {
|
||||
db *sql.DB
|
||||
vr *ValueRepository
|
||||
pt *PropertyTypeRepository
|
||||
ptg *PropertyTypeGroupRepository
|
||||
pr *PropertyRepository
|
||||
}
|
||||
|
||||
func NewImportRepository(db *sql.DB, vr *ValueRepository, pt *PropertyTypeRepository, ptg *PropertyTypeGroupRepository, pr *PropertyRepository) *ImportRepository {
|
||||
return &ImportRepository{
|
||||
db: db,
|
||||
vr: vr,
|
||||
pt: pt,
|
||||
ptg: ptg,
|
||||
pr: pr,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyRepository struct {
|
||||
db *sql.DB
|
||||
vr *ValueRepository
|
||||
}
|
||||
|
||||
func NewPropertyRepository(db *sql.DB, valueRepository *ValueRepository) *PropertyRepository {
|
||||
return &PropertyRepository{
|
||||
db: db,
|
||||
vr: valueRepository,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyTypeGroupRepository struct {
|
||||
db *sql.DB
|
||||
PropertyTypeRepository *PropertyTypeRepository
|
||||
}
|
||||
|
||||
func NewPropertyTypesGroupRepository(db *sql.DB, PropertyTypeRepository *PropertyTypeRepository) *PropertyTypeGroupRepository {
|
||||
return &PropertyTypeGroupRepository{
|
||||
db: db,
|
||||
PropertyTypeRepository: PropertyTypeRepository,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyTypeRepository struct {
|
||||
db *sql.DB
|
||||
pr *PropertyRepository
|
||||
}
|
||||
|
||||
func NewPropertyTypeRepository(db *sql.DB, propertyRepository *PropertyRepository) *PropertyTypeRepository {
|
||||
return &PropertyTypeRepository{
|
||||
db: db,
|
||||
pr: propertyRepository,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type ValueRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewValueRepository(db *sql.DB) *ValueRepository {
|
||||
return &ValueRepository{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/repositories"
|
||||
)
|
||||
|
||||
type Import_Service struct {
|
||||
importRepository *repositories.ImportRepository
|
||||
}
|
||||
|
||||
func NewImportService(importRepository *repositories.ImportRepository) *Import_Service {
|
||||
return &Import_Service{
|
||||
importRepository: importRepository,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/repositories"
|
||||
)
|
||||
|
||||
type PropertyTypeService struct {
|
||||
// Add any dependencies or fields needed for the service here
|
||||
PropertyTypes_Repository *repositories.PropertyTypeRepository
|
||||
PropertyTypeGroups_Repository *repositories.PropertyTypeGroupRepository
|
||||
}
|
||||
|
||||
func NewPropertyTypeService(propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository) *PropertyTypeService {
|
||||
return &PropertyTypeService{
|
||||
PropertyTypes_Repository: propertyTypesRepo,
|
||||
PropertyTypeGroups_Repository: propertyTypesGroupsRepo,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user