camper/pkg/database/funcs.go

95 lines
4.3 KiB
Go

/*
* SPDX-FileCopyrightText: 2023 jordi fita mas <jfita@peritasoft.com>
* SPDX-License-Identifier: AGPL-3.0-only
*/
package database
import (
"context"
"golang.org/x/text/language"
)
func (tx *Tx) AddCampsiteType(ctx context.Context, companyID int, mediaID int, name string, spiel string, info string, facilities string, description string, maxCampers int, dogsAllowed bool) (string, error) {
return tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9)", companyID, mediaID, name, spiel, info, facilities, description, maxCampers, dogsAllowed)
}
func (tx *Tx) EditCampsiteType(ctx context.Context, slug string, mediaID int, name string, spiel string, info string, facilities string, description string, maxCampers int, dogsAllowed bool, active bool) (string, error) {
return tx.GetText(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", slug, mediaID, name, spiel, info, facilities, description, maxCampers, dogsAllowed, active)
}
func (c *Conn) OrderCampsiteTypes(ctx context.Context, slugs []string) error {
_, err := c.Exec(ctx, "select order_campsite_types($1)", slugs)
return err
}
func (c *Conn) TranslateCampsiteType(ctx context.Context, slug string, langTag language.Tag, name string, spiel string, info string, facilities string, description string) error {
_, err := c.Exec(ctx, "select translate_campsite_type($1, $2, $3, $4, $5, $6, $7)", slug, langTag, name, spiel, info, facilities, description)
return err
}
func (tx *Tx) SetCampsiteTypeCost(ctx context.Context, slug string, seasonID int, minNights int, costPerNight string) error {
_, err := tx.Exec(ctx, "select set_campsite_type_cost($1, $2, $3, $4)", slug, seasonID, minNights, costPerNight)
return err
}
func (tx *Tx) AddCampsiteTypeOption(ctx context.Context, typeSlug string, name string, min int, max int) (int, error) {
return tx.GetInt(ctx, "select add_campsite_type_option($1, $2, $3, $4)", typeSlug, name, min, max)
}
func (tx *Tx) EditCampsiteTypeOption(ctx context.Context, id int, name string, min int, max int) (int, error) {
return tx.GetInt(ctx, "select edit_campsite_type_option($1, $2, $3, $4)", id, name, min, max)
}
func (tx *Tx) SetCampsiteTypeOptionCost(ctx context.Context, id int, seasonID int, pricePerNight string) error {
_, err := tx.Exec(ctx, "select set_campsite_type_option_cost($1, $2, $3)", id, seasonID, pricePerNight)
return err
}
func (c *Conn) TranslateCampsiteTypeOption(ctx context.Context, id int, langTag language.Tag, name string) error {
_, err := c.Exec(ctx, "select translate_campsite_type_option($1, $2, $3)", id, langTag, name)
return err
}
func (c *Conn) OrderCampsiteTypeOptions(ctx context.Context, ids []int) error {
_, err := c.Exec(ctx, "select order_campsite_type_options($1)", ids)
return err
}
func (c *Conn) OrderCampsiteTypeCarousel(ctx context.Context, typeSlug string, media_ids []int) error {
_, err := c.Exec(ctx, "select order_campsite_type_carousel($1, $2)", typeSlug, media_ids)
return err
}
func (c *Conn) AddCampsiteTypeFeature(ctx context.Context, typeSlug string, iconName string, name string) (int, error) {
return c.GetInt(ctx, "select add_campsite_type_feature($1, $2, $3)", typeSlug, iconName, name)
}
func (c *Conn) EditCampsiteTypeFeature(ctx context.Context, id int, iconName string, name string) (int, error) {
return c.GetInt(ctx, "select edit_campsite_type_feature($1, $2, $3)", id, iconName, name)
}
func (c *Conn) TranslateCampsiteTypeFeature(ctx context.Context, id int, langTag language.Tag, name string) error {
_, err := c.Exec(ctx, "select translate_campsite_type_feature($1, $2, $3)", id, langTag, name)
return err
}
func (c *Conn) OrderCampsiteTypeFeatures(ctx context.Context, ids []int) error {
_, err := c.Exec(ctx, "select order_campsite_type_features($1)", ids)
return err
}
func (c *Conn) SetupRedsys(ctx context.Context, companyID int, merchantCode string, terminalNumber int, environment string, integration string, encryptKey string) error {
var encryptKeyParam interface{}
if encryptKey != "" {
encryptKeyParam = encryptKey
}
_, err := c.Exec(ctx, "select setup_redsys($1, $2, $3, $4, $5, $6)", companyID, merchantCode, terminalNumber, environment, integration, encryptKeyParam)
return err
}
func (c *Conn) OrderSeasons(ctx context.Context, slugs []string) error {
_, err := c.Exec(ctx, "select order_seasons($1)", slugs)
return err
}