2023-10-13 10:45:54 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
)
|
|
|
|
|
2024-01-22 19:19:19 +00:00
|
|
|
func (tx *Tx) AddCampsiteType(ctx context.Context, companyID int, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string, maxCampers int, dogsAllowed bool) (string, error) {
|
|
|
|
return tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)", companyID, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed)
|
2023-10-13 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2024-01-22 19:19:19 +00:00
|
|
|
func (tx *Tx) EditCampsiteType(ctx context.Context, slug string, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut 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, $11, $12, $13)", slug, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed, active)
|
2023-10-13 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 18:52:14 +00:00
|
|
|
func (c *Conn) OrderCampsiteTypes(ctx context.Context, slugs []string) error {
|
|
|
|
_, err := c.Exec(ctx, "select order_campsite_types($1)", slugs)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-01-22 19:19:19 +00:00
|
|
|
func (tx *Tx) TranslateCampsiteType(ctx context.Context, slug string, langTag language.Tag, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", slug, langTag, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut)
|
2023-10-13 10:45:54 +00:00
|
|
|
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
|
|
|
|
}
|
2023-10-13 17:05:17 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:52:49 +00:00
|
|
|
func (tx *Tx) TranslateCampsiteTypeOption(ctx context.Context, id int, langTag language.Tag, name string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_campsite_type_option($1, $2, $3)", id, langTag, name)
|
2023-10-13 17:05:17 +00:00
|
|
|
return err
|
|
|
|
}
|
2023-10-13 18:30:31 +00:00
|
|
|
|
2024-01-22 19:54:03 +00:00
|
|
|
func (c *Conn) RemoveCampsiteTypeOption(ctx context.Context, id int) error {
|
|
|
|
_, err := c.Exec(ctx, "select remove_campsite_type_option($1)", id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-12-20 18:52:14 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:52:49 +00:00
|
|
|
func (tx *Tx) AddCampsiteTypeFeature(ctx context.Context, typeSlug string, iconName string, name string) (int, error) {
|
|
|
|
return tx.GetInt(ctx, "select add_campsite_type_feature($1, $2, $3)", typeSlug, iconName, name)
|
2023-10-13 18:30:31 +00:00
|
|
|
}
|
|
|
|
|
2024-01-10 20:52:49 +00:00
|
|
|
func (tx *Tx) EditCampsiteTypeFeature(ctx context.Context, id int, iconName string, name string) (int, error) {
|
|
|
|
return tx.GetInt(ctx, "select edit_campsite_type_feature($1, $2, $3)", id, iconName, name)
|
2023-10-13 18:30:31 +00:00
|
|
|
}
|
|
|
|
|
2024-01-10 20:52:49 +00:00
|
|
|
func (tx *Tx) TranslateCampsiteTypeFeature(ctx context.Context, id int, langTag language.Tag, name string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_campsite_type_feature($1, $2, $3)", id, langTag, name)
|
2023-10-13 18:30:31 +00:00
|
|
|
return err
|
|
|
|
}
|
2023-10-27 14:04:43 +00:00
|
|
|
|
2023-12-21 16:33:01 +00:00
|
|
|
func (c *Conn) OrderCampsiteTypeFeatures(ctx context.Context, ids []int) error {
|
|
|
|
_, err := c.Exec(ctx, "select order_campsite_type_features($1)", ids)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:52:49 +00:00
|
|
|
func (tx *Tx) AddCampsiteTypeCarouselSlide(ctx context.Context, typeSlug string, mediaID int, caption string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select add_campsite_type_carousel_slide($1, $2, $3)", typeSlug, mediaID, caption)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) TranslateCampsiteTypeCarouselSlide(ctx context.Context, typeSlug string, mediaID int, langTag language.Tag, caption string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_campsite_type_carousel_slide($1, $2, $3, $4)", typeSlug, mediaID, langTag, caption)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-01-22 19:56:48 +00:00
|
|
|
func (c *Conn) RemoveCampsiteTypeCarouselSlide(ctx context.Context, typeSlug string, mediaID int) error {
|
|
|
|
_, err := c.Exec(ctx, "select remove_campsite_type_carousel_slide($1, $2)", typeSlug, mediaID)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-27 14:04:43 +00:00
|
|
|
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
|
|
|
|
}
|
2023-12-20 18:52:14 +00:00
|
|
|
|
|
|
|
func (c *Conn) OrderSeasons(ctx context.Context, slugs []string) error {
|
|
|
|
_, err := c.Exec(ctx, "select order_seasons($1)", slugs)
|
|
|
|
return err
|
|
|
|
}
|
2023-12-21 20:17:04 +00:00
|
|
|
|
|
|
|
func (tx *Tx) SetupLocation(ctx context.Context, companyID int, directions string, mapEmbed string, openingHours string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select setup_location($1, $2, $3, $4)", companyID, directions, mapEmbed, openingHours)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) TranslateLocation(ctx context.Context, companyID int, langTag language.Tag, directions string, openingHours string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_location($1, $2, $3, $4)", companyID, langTag, directions, openingHours)
|
|
|
|
return err
|
|
|
|
}
|
2023-12-22 01:23:18 +00:00
|
|
|
|
|
|
|
func (tx *Tx) TranslateLegalText(ctx context.Context, companyID int, slug string, langTag language.Tag, name string, content string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_legal_text($1, $2, $3, $4, $5)", companyID, slug, langTag, name, content)
|
|
|
|
return err
|
|
|
|
}
|
2024-01-12 19:26:45 +00:00
|
|
|
|
|
|
|
func (tx *Tx) AddSeason(ctx context.Context, companyID int, name string, color string) (string, error) {
|
|
|
|
return tx.GetText(ctx, "select add_season($1, $2, $3)", companyID, name, color)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) EditSeason(ctx context.Context, slug string, name string, color string, active bool) error {
|
|
|
|
_, err := tx.Exec(ctx, "select edit_season($1, $2, $3, $4)", slug, name, color, active)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) TranslateSeason(ctx context.Context, slug string, langTag language.Tag, name string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_season($1, $2, $3)", slug, langTag, name)
|
|
|
|
return err
|
|
|
|
}
|
2024-01-12 20:06:12 +00:00
|
|
|
|
|
|
|
func (tx *Tx) AddService(ctx context.Context, companyID int, icon string, name string, description string) (int, error) {
|
|
|
|
return tx.GetInt(ctx, "select add_service($1, $2, $3, $4)", companyID, icon, name, description)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) EditService(ctx context.Context, id int, icon string, name string, description string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select edit_service($1, $2, $3, $4)", id, icon, name, description)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) TranslateService(ctx context.Context, id int, langTag language.Tag, name string, description string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_service($1, $2, $3, $4)", id, langTag, name, description)
|
|
|
|
return err
|
|
|
|
}
|
2024-01-13 00:15:24 +00:00
|
|
|
|
|
|
|
func (c *Conn) OrderServices(ctx context.Context, ids []int) error {
|
|
|
|
_, err := c.Exec(ctx, "select order_services($1)", ids)
|
|
|
|
return err
|
|
|
|
}
|
2024-01-16 00:25:25 +00:00
|
|
|
|
2024-01-16 17:12:38 +00:00
|
|
|
func (c *Conn) RemoveService(ctx context.Context, id int) error {
|
|
|
|
_, err := c.Exec(ctx, "select remove_service($1)", id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-01-16 00:25:25 +00:00
|
|
|
func (tx *Tx) AddSurroundingsHighlight(ctx context.Context, companyID int, mediaID int, name string, description string) (int, error) {
|
|
|
|
return tx.GetInt(ctx, "select add_surroundings_highlight($1, $2, $3, $4)", companyID, mediaID, name, description)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) EditSurroundingsHighlight(ctx context.Context, id int, mediaID int, name string, description string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select edit_surroundings_highlight($1, $2, $3, $4)", id, mediaID, name, description)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tx *Tx) TranslateSurroundingsHighlight(ctx context.Context, id int, langTag language.Tag, name string, description string) error {
|
|
|
|
_, err := tx.Exec(ctx, "select translate_surroundings_highlight($1, $2, $3, $4)", id, langTag, name, description)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) OrderSurroundingsHighlights(ctx context.Context, ids []int) error {
|
|
|
|
_, err := c.Exec(ctx, "select order_surroundings_highlights($1)", ids)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) RemoveSurroundingsHighlight(ctx context.Context, id int) error {
|
|
|
|
_, err := c.Exec(ctx, "select remove_surroundings_highlight($1)", id)
|
|
|
|
return err
|
|
|
|
}
|