Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
679a8a0a3e | ||
|
|
c65f36dc40 | ||
|
|
7bfea738af | ||
|
|
6628d8a06c | ||
|
|
e0aafd0734 | ||
|
|
12d5c96dcb | ||
|
|
0d2f5a1412 | ||
|
|
8a0be322d2 | ||
|
|
56064d672f | ||
|
|
a631b31341 |
@@ -49,3 +49,80 @@ Als Quelltext-Editor / IDE kommt VSCode zum Einsatz.
|
||||
|
||||
### DBeaver
|
||||
Ist der Datenbank-Editor
|
||||
|
||||
## Technische Dokumentation
|
||||
|
||||
### 20.09.2026 Grundsätzliche technische Entscheidungen
|
||||
#### Systeme:
|
||||
- Programmiersprache : - GO
|
||||
- Javascript
|
||||
- SQL
|
||||
- Datenbank: Postgresql
|
||||
- Webtechnologie: HTMX
|
||||
|
||||
#### Grundlegende technische Entscheidungen
|
||||
- Jedes relevante Objekt (z.B. Produkte) hat eine Darstellung als:
|
||||
- Node (Raumdarstellung)
|
||||
- Form (Darstellung des Objektes und Editiermöglichkeit) - List (Listen /Tabellensicht
|
||||
- Alle Objekte werden in der API über ihre eindeutige ID angesprochen. Über die ID kann ich den Typ des Objektes herausfinden
|
||||
- Objekte werden nur bei Bedarf aus der Datenbank geladen.
|
||||
- Objekte werden nach dem Laden oder Anlegen gechached!
|
||||
- Weboberflächen zur Pflege der Daten aber auch die Seiten zur Nutzung des CPQ müssen responsive sein!
|
||||
- Nutzung des 12- Spalten loyouts!
|
||||
- Alle Images haben einen Alternativen Text
|
||||
- Struktur der Oberfläche und die Darstellung werden strikt getrennt (HTML + CSS)
|
||||
- Die Entwicklung erfolgt über die Definition von Tickets
|
||||
- Jedes Ticket verursacht ein Brauch und einen Merge!
|
||||
|
||||
### Open Source - Pakete
|
||||
|
||||
#### Go:
|
||||
|
||||
##### Viper
|
||||
|
||||
Viper dient zum Laden uns Auswerten von Config-Dateien. In diesem Case werden die HTTP-Servereinstellungen und die Datenbankverbindung ausgewertet.
|
||||
|
||||
````
|
||||
go get github.com/spf13/viper
|
||||
````
|
||||
|
||||
##### PostgreSQL
|
||||
|
||||
Die Datenbank des Systems ist in dem Datenbankmanagementsystem PostgreSQL abgelegt. Zum einen braucht es eine Installation des Systems, auf dem die Software Zugriff hat und zum anderen benötigt das System die entsprechenden PostgreSQL Treiber für Go.
|
||||
|
||||
````
|
||||
go get github.com/lib/pq
|
||||
````
|
||||
|
||||
##### Gin Gonic
|
||||
|
||||
Webserver Library zum Routing der API.
|
||||
|
||||
````
|
||||
go get -u github.com/gin-gonic/gin
|
||||
go get github.com/gin-contrib/cors
|
||||
go get github.com/gin-contrib/sessions
|
||||
````
|
||||
|
||||
##### Go Air
|
||||
|
||||
Go Air ist ein Live-Reload-Tool für Go-Anwendungen, das die Entwicklungsproduktivität erhöht.
|
||||
|
||||
````
|
||||
go install github.com/air-verse/air@latest
|
||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
````
|
||||
|
||||
Den Export ggf. in der .bashrc oder .zshrc hinzufügen.
|
||||
|
||||
#### HTML Erweiterungen
|
||||
|
||||
ggf. später lokal runter laden ...
|
||||
|
||||
##### HTMX
|
||||
|
||||
HTMX ist eine JavaScript-Bibliothek, die es ermöglicht, HTML direkt über AJAX-Anfragen zu aktualisieren.
|
||||
|
||||
````
|
||||
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
|
||||
````
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Starting XCPQ Editor Service")
|
||||
log.Println("Starting SimplyCPQ Editor Services")
|
||||
log.Println("Reading configuration")
|
||||
config := config.InitConfig("config")
|
||||
log.Println("Initializing database")
|
||||
@@ -19,5 +19,5 @@ func main() {
|
||||
httpServer := server.InitHttpServer(config, dbHandler)
|
||||
httpServer.Start()
|
||||
|
||||
log.Println("XCPQ Editor Service Stopped")
|
||||
log.Println("SimplyCPQ Editor Services Stopped")
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func InitHttpServer(config *viper.Viper, dbHandler *sql.DB) HttpServer {
|
||||
// static content
|
||||
router.Static("/static", "../static")
|
||||
router.GET("/", mainHandler.Home)
|
||||
router.GET("/properties/rootnodes", propertyTypeHandler.GetRootPropertyTypeGroups)
|
||||
router.GET("/properties/:id/childs", propertyTypeHandler.GetPropertyTypeGroupContentById)
|
||||
|
||||
//router.GET("/properties", handler.PropertiesHandler)
|
||||
/* old routes
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
\restrict iW2a413pT5zeXKomXxEgRQTiRNeAak9Q02Hycl1aipdPB0heQsWpdaKpyL4HOzT
|
||||
|
||||
-- Dumped from database version 18.4 (Debian 18.4-1.pgdg13+1)
|
||||
-- Dumped by pg_dump version 18.4
|
||||
|
||||
-- Started on 2026-09-26 09:01:38
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET transaction_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 6 (class 2615 OID 20689)
|
||||
-- Name: properties; Type: SCHEMA; Schema: -; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE SCHEMA properties;
|
||||
|
||||
|
||||
ALTER SCHEMA properties OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3481 (class 0 OID 0)
|
||||
-- Dependencies: 6
|
||||
-- Name: SCHEMA properties; Type: COMMENT; Schema: -; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON SCHEMA properties IS 'Alle Tabellen, die mit Properties und Values zu tun haben.';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 220 (class 1259 OID 20691)
|
||||
-- Name: properties_id_seq; Type: SEQUENCE; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE SEQUENCE properties.properties_id_seq
|
||||
START WITH 1000000
|
||||
INCREMENT BY 1
|
||||
MINVALUE 1000000
|
||||
MAXVALUE 4999999
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER SEQUENCE properties.properties_id_seq OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3482 (class 0 OID 0)
|
||||
-- Dependencies: 220
|
||||
-- Name: SEQUENCE properties_id_seq; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON SEQUENCE properties.properties_id_seq IS 'Zähler für property und value IDs ';
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- TOC entry 223 (class 1259 OID 20722)
|
||||
-- Name: properties; Type: TABLE; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE TABLE properties.properties (
|
||||
id bigint DEFAULT nextval('properties.properties_id_seq'::regclass) NOT NULL,
|
||||
name text,
|
||||
description text,
|
||||
parent_property_id bigint DEFAULT 0 NOT NULL,
|
||||
property_type_id bigint NOT NULL,
|
||||
products_groups_id bigint DEFAULT 0 NOT NULL,
|
||||
products_id bigint DEFAULT 0 NOT NULL,
|
||||
image_url text DEFAULT 'https://www.thomas-sindt.de/img/properties_group.svg'::text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE properties.properties OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3483 (class 0 OID 0)
|
||||
-- Dependencies: 223
|
||||
-- Name: TABLE properties; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON TABLE properties.properties IS 'Eigenschaften, die Listen von Werten enthalten und eine Information, von welchem property sich dieses Property ableitet. Ist parent_property_id = 0, dann ist dieses ein Root-Property zu dem referenzierten PropertyType.';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3484 (class 0 OID 0)
|
||||
-- Dependencies: 223
|
||||
-- Name: COLUMN properties.name; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON COLUMN properties.properties.name IS 'Der Name sollte derselbe sein, wie der referenzierte Property Type.';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3485 (class 0 OID 0)
|
||||
-- Dependencies: 223
|
||||
-- Name: COLUMN properties.products_groups_id; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON COLUMN properties.properties.products_groups_id IS 'Referenziert auf dieProduktgruppe, zu dem dieses Property gehört. Wenn es zu keiner Produktgruppe gehört ist diese referenz = 0';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3486 (class 0 OID 0)
|
||||
-- Dependencies: 223
|
||||
-- Name: COLUMN properties.products_id; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON COLUMN properties.properties.products_id IS 'Referenziert auf das Produkt, zu dem dieses Property gehört. Wenn es zu keinem Produkt gehört ist diese referenz = 0';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 222 (class 1259 OID 20707)
|
||||
-- Name: property_types; Type: TABLE; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE TABLE properties.property_types (
|
||||
id bigint DEFAULT nextval('properties.properties_id_seq'::regclass) NOT NULL,
|
||||
name text,
|
||||
description text,
|
||||
property_types_groups_id bigint NOT NULL,
|
||||
image_url text DEFAULT 'https://www.thomas-sindt.de/img/category.svg'::text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE properties.property_types OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3487 (class 0 OID 0)
|
||||
-- Dependencies: 222
|
||||
-- Name: TABLE property_types; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON TABLE properties.property_types IS 'Definition von properties';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 221 (class 1259 OID 20698)
|
||||
-- Name: property_types_groups; Type: TABLE; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE TABLE properties.property_types_groups (
|
||||
id bigint DEFAULT nextval('properties.properties_id_seq'::regclass) CONSTRAINT property_types_group_id_not_null NOT NULL,
|
||||
name text,
|
||||
description text,
|
||||
parent_property_type_group_id bigint,
|
||||
image_url text DEFAULT 'https://thomas-sindt/img/category.svg'::text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE properties.property_types_groups OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3488 (class 0 OID 0)
|
||||
-- Dependencies: 221
|
||||
-- Name: TABLE property_types_groups; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON TABLE properties.property_types_groups IS 'Baumstruktur zur Organisation von Property types
|
||||
Wenn parent_property_types_group = 0, dann ist diese Gruppe eine Rootgruppe.';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 224 (class 1259 OID 20743)
|
||||
-- Name: values; Type: TABLE; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
CREATE TABLE properties."values" (
|
||||
id bigint DEFAULT nextval('properties.properties_id_seq'::regclass) NOT NULL,
|
||||
value text,
|
||||
properties_id bigint NOT NULL,
|
||||
image_url text DEFAULT 'https://www.thomas-sindt.de/img/property.svg'::text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE properties."values" OWNER TO tsindt;
|
||||
|
||||
--
|
||||
-- TOC entry 3474 (class 0 OID 20722)
|
||||
-- Dependencies: 223
|
||||
-- Data for Name: properties; Type: TABLE DATA; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COPY properties.properties (id, name, description, parent_property_id, property_type_id, products_groups_id, products_id, image_url) FROM stdin;
|
||||
1000095 Spannungsversorgung (V) Spannungsversorgung (V) 0 1000094 0 0
|
||||
1000099 Leistung (W) Leistung 0 1000098 0 0
|
||||
1000117 Eingangsimpedanz (Ω) Wiederstand der Eingangsimpedanz 0 1000116 0 0
|
||||
1000120 Frequenzbereich (Hz‑kHz) Frequenzbereich (Hz‑kHz) 0 1000119 0 0
|
||||
1000123 Signal‑Rausch‑Verhältnis (dB) Signal‑Rausch‑Verhältnis (dB) 0 1000122 0 0
|
||||
1000131 Anschlüsse Anschlüsse 0 1000130 0 0
|
||||
1000142 Ausgangsimpedanz (Ω) Ausgangsimpedanz (Ω) 0 1000141 0 0
|
||||
1000146 Gewicht (kg) All mechanical properties 0 1000145 0 0
|
||||
1000152 Kapazität (kg) All mechanical properties 0 1000151 0 0
|
||||
1000155 Programms/Features All mechanical properties 0 1000154 0 0
|
||||
1000157 Wasserverbrauch pro Zyklus (L) All mechanical properties 0 1000156 0 0
|
||||
1000159 Material Innenraum All mechanical properties 0 1000158 0 0
|
||||
1000161 Kapazität/Volumen (L) All mechanical properties 0 1000160 0 0
|
||||
1000163 Schleuderdrehzahl (U/min) All mechanical properties 0 1000162 0 0
|
||||
1000166 Preis (USD) All other properties 0 1000165 0 0
|
||||
1000168 Zusatzfunktionen All other properties 0 1000167 0 0
|
||||
1000170 Bedienungsart All other properties 0 1000169 0 0
|
||||
1000172 Energieeffizienzklasse All other properties 0 1000171 0 0
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3473 (class 0 OID 20707)
|
||||
-- Dependencies: 222
|
||||
-- Data for Name: property_types; Type: TABLE DATA; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COPY properties.property_types (id, name, description, property_types_groups_id, image_url) FROM stdin;
|
||||
1000094 Spannungsversorgung (V) Spannungsversorgung (V) 1000093
|
||||
1000098 Leistung (W) Leistung 1000093
|
||||
1000116 Eingangsimpedanz (Ω) Wiederstand der Eingangsimpedanz 1000093
|
||||
1000119 Frequenzbereich (Hz‑kHz) Frequenzbereich (Hz‑kHz) 1000093
|
||||
1000122 Signal‑Rausch‑Verhältnis (dB) Signal‑Rausch‑Verhältnis (dB) 1000093
|
||||
1000130 Anschlüsse Anschlüsse 1000093
|
||||
1000141 Ausgangsimpedanz (Ω) Ausgangsimpedanz (Ω) 1000093
|
||||
1000145 Abmessungen (mm) All mechanical properties 1000144
|
||||
1000151 Kapazität (kg) All mechanical properties 1000144
|
||||
1000154 Programms/Features All mechanical properties 1000144
|
||||
1000156 Wasserverbrauch pro Zyklus (L) All mechanical properties 1000144
|
||||
1000158 Material Innenraum All mechanical properties 1000144
|
||||
1000160 Kapazität/Volumen (L) All mechanical properties 1000144
|
||||
1000162 Schleuderdrehzahl (U/min) All mechanical properties 1000144
|
||||
1000165 Preis (USD) All other properties 1000164
|
||||
1000167 Zusatzfunktionen All other properties 1000164
|
||||
1000169 Bedienungsart All other properties 1000164
|
||||
1000171 Energieeffizienzklasse All other properties 1000164
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3472 (class 0 OID 20698)
|
||||
-- Dependencies: 221
|
||||
-- Data for Name: property_types_groups; Type: TABLE DATA; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COPY properties.property_types_groups (id, name, description, parent_property_type_group_id, image_url) FROM stdin;
|
||||
1000092 X-CPQ Property Type Group for X-CPQ 0
|
||||
1000093 electrical All electrical property types 1000092
|
||||
1000144 mechanical All mechanical properties 1000092
|
||||
1000164 other All other properties 1000092
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3475 (class 0 OID 20743)
|
||||
-- Dependencies: 224
|
||||
-- Data for Name: values; Type: TABLE DATA; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COPY properties."values" (id, value, properties_id, image_url) FROM stdin;
|
||||
1000096 220 1000095
|
||||
1000097 230 1000095
|
||||
1000100 0 1000099
|
||||
1000101 140 1000099
|
||||
1000102 130 1000099
|
||||
1000103 120 1000099
|
||||
1000104 110 1000099
|
||||
1000105 100 1000099
|
||||
1000106 90 1000099
|
||||
1000107 80 1000099
|
||||
1000108 70 1000099
|
||||
1000109 60 1000099
|
||||
1000110 50 1000099
|
||||
1000111 28 1000099
|
||||
1000112 26 1000099
|
||||
1000113 24 1000099
|
||||
1000114 22 1000099
|
||||
1000115 20 1000099
|
||||
1000118 10 1000117
|
||||
1000121 87‑108 1000120
|
||||
1000124 48 1000123
|
||||
1000125 46 1000123
|
||||
1000126 47 1000123
|
||||
1000127 45 1000123
|
||||
1000128 49 1000123
|
||||
1000129 44 1000123
|
||||
1000132 UKW+Bluetooth+DL 1000131
|
||||
1000133 UKW+Wi‑Fi+DL 1000131
|
||||
1000134 UKW+DL+Bluetooth 1000131
|
||||
1000135 UKW+Bluetooth+Wi‑Fi 1000131
|
||||
1000136 UKW+Wi‑Fi+DL 1000131
|
||||
1000137 UKW+Wi‑Fi 1000131
|
||||
1000138 UKW+Bluetooth 1000131
|
||||
1000139 UKW+DL 1000131
|
||||
1000140 UKW 1000131
|
||||
1000143 75 1000142
|
||||
1000147 3 1000146
|
||||
1000148 6 1000146
|
||||
1000149 4 1000146
|
||||
1000150 2 1000146
|
||||
1000153 0 1000152
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3489 (class 0 OID 0)
|
||||
-- Dependencies: 220
|
||||
-- Name: properties_id_seq; Type: SEQUENCE SET; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('properties.properties_id_seq', 1000172, true);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3318 (class 2606 OID 20733)
|
||||
-- Name: properties properties_pkey; Type: CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties.properties
|
||||
ADD CONSTRAINT properties_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3314 (class 2606 OID 20706)
|
||||
-- Name: property_types_groups property_types_group_pkey; Type: CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties.property_types_groups
|
||||
ADD CONSTRAINT property_types_group_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3316 (class 2606 OID 20716)
|
||||
-- Name: property_types property_types_pkey; Type: CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties.property_types
|
||||
ADD CONSTRAINT property_types_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3320 (class 2606 OID 20752)
|
||||
-- Name: values values_pkey; Type: CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties."values"
|
||||
ADD CONSTRAINT values_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3322 (class 2606 OID 20734)
|
||||
-- Name: properties parent_property_type_id_fk; Type: FK CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties.properties
|
||||
ADD CONSTRAINT parent_property_type_id_fk FOREIGN KEY (property_type_id) REFERENCES properties.property_types(id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3490 (class 0 OID 0)
|
||||
-- Dependencies: 3322
|
||||
-- Name: CONSTRAINT parent_property_type_id_fk ON properties; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT parent_property_type_id_fk ON properties.properties IS 'Verweißt auf den Property Type dieses Properties';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3323 (class 2606 OID 20753)
|
||||
-- Name: values properties_id_fk; Type: FK CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties."values"
|
||||
ADD CONSTRAINT properties_id_fk FOREIGN KEY (properties_id) REFERENCES properties.properties(id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3321 (class 2606 OID 20717)
|
||||
-- Name: property_types property_types_groups_id_fk; Type: FK CONSTRAINT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY properties.property_types
|
||||
ADD CONSTRAINT property_types_groups_id_fk FOREIGN KEY (property_types_groups_id) REFERENCES properties.property_types_groups(id);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 3491 (class 0 OID 0)
|
||||
-- Dependencies: 3321
|
||||
-- Name: CONSTRAINT property_types_groups_id_fk ON property_types; Type: COMMENT; Schema: properties; Owner: tsindt
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT property_types_groups_id_fk ON properties.property_types IS 'Referenz auf die Property Type Gruppe, zu der dieser Property Type gehört.';
|
||||
|
||||
|
||||
-- Completed on 2026-09-26 09:01:39
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
\unrestrict iW2a413pT5zeXKomXxEgRQTiRNeAak9Q02Hycl1aipdPB0heQsWpdaKpyL4HOzT
|
||||
|
||||
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/services"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -16,6 +17,40 @@ func NewPropertyTypeHandler(propertyTypeService *services.PropertyTypeService) *
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy Methode
|
||||
func (h *PropertyTypeHandler) GetRootPropertyTypeGroups(ctx *gin.Context) {
|
||||
// Implement the logic to get root property types groups here
|
||||
}
|
||||
|
||||
func (h *PropertyTypeHandler) GetPropertyTypeGroupContentById(ctx *gin.Context) {
|
||||
idParam := ctx.Param("id")
|
||||
// Convert idParam to an integer
|
||||
id, err := strconv.Atoi(idParam)
|
||||
if err != nil {
|
||||
ctx.JSON(400, gin.H{"error": "Invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
// get property type groups by parent ID
|
||||
ptgs, err := h.propertyTypeService.GetPropertyTypeGroupsByParentId(id)
|
||||
if err != nil {
|
||||
ctx.JSON(500, gin.H{"error": "Failed to get property type group content"})
|
||||
return
|
||||
}
|
||||
|
||||
// get property types by parent ID
|
||||
pts, err := h.propertyTypeService.GetPropertyTypesByGroupId(id)
|
||||
if err != nil {
|
||||
ctx.JSON(500, gin.H{"error": "Failed to get property types"})
|
||||
return
|
||||
}
|
||||
|
||||
// template for response
|
||||
|
||||
ctx.JSON(200, gin.H{
|
||||
"propertyTypeGroups": ptgs,
|
||||
"propertyTypes": pts,
|
||||
})
|
||||
|
||||
// Implement the logic to get property type group content by ID here using idParam
|
||||
}
|
||||
|
||||
@@ -1,13 +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"`
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
PropertyTypeId int `json:"property_type_id,omitempty"`
|
||||
ParentPropertyId int `json:"parent_property_id,omitempty"`
|
||||
ProductGroupId int `json:"product_group_id,omitempty"`
|
||||
ProductId int `json:"product_id,omitempty"`
|
||||
Values []Value `json:"values,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,9 +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"`
|
||||
type PropertyType struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"image_url,omitempty"`
|
||||
PropertyTypesGroupsId int `json:"property_types_groups_id,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
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"`
|
||||
Id int `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
ParentPropertyTypeGroupId int `json:"parent_property_type_group_id,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package models
|
||||
|
||||
type Value struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
Value string `json:"value"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
Id int `json:"id,omitempty"`
|
||||
Value string `json:"value"`
|
||||
ImageURL string `json:"ImageURL,omitempty"`
|
||||
PropertiesId int `json:"properties_id,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,17 +1,159 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/models"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyRepository struct {
|
||||
db *sql.DB
|
||||
vr *ValueRepository
|
||||
db *sql.DB
|
||||
vr *ValueRepository
|
||||
cache map[int]models.Property
|
||||
}
|
||||
|
||||
func NewPropertyRepository(db *sql.DB, valueRepository *ValueRepository) *PropertyRepository {
|
||||
return &PropertyRepository{
|
||||
db: db,
|
||||
vr: valueRepository,
|
||||
db: db,
|
||||
vr: valueRepository,
|
||||
cache: make(map[int]models.Property),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) createProperty(property models.Property) (models.Property, error) {
|
||||
result, err := r.db.Exec("INSERT INTO properties (name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id) VALUES (?, ?, ?, ?, ?, ?, ?)", property.Name, property.Description, property.ImageURL, property.ParentPropertyId, property.PropertyTypeId, property.ProductGroupId, property.ProductId)
|
||||
if err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
property.Id = int(id)
|
||||
r.cache[property.Id] = property
|
||||
return property, nil
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) GetPropertyByID(id int) (models.Property, error) {
|
||||
if property, ok := r.cache[id]; ok {
|
||||
return property, nil
|
||||
}
|
||||
|
||||
var property models.Property
|
||||
err := r.db.QueryRow("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE id = ?", id).Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||
if err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
r.cache[property.Id] = property
|
||||
return property, nil
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) GetPropertiesByProductGroupID(pid int) ([]models.Property, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE product_groups_id = ?", pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var properties []models.Property
|
||||
for rows.Next() {
|
||||
var property models.Property
|
||||
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cachedProperty, ok := r.cache[property.Id]; ok {
|
||||
properties = append(properties, cachedProperty)
|
||||
} else {
|
||||
r.cache[property.Id] = property
|
||||
properties = append(properties, property)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return properties, nil
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) GetPropertiesByProductID(pid int) ([]models.Property, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE products_id = ?", pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var properties []models.Property
|
||||
for rows.Next() {
|
||||
var property models.Property
|
||||
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cachedProperty, ok := r.cache[property.Id]; ok {
|
||||
properties = append(properties, cachedProperty)
|
||||
} else {
|
||||
r.cache[property.Id] = property
|
||||
properties = append(properties, property)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return properties, nil
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) GetPropertiesByParentPropertyID(pid int) ([]models.Property, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE parent_property_id = ?", pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var properties []models.Property
|
||||
for rows.Next() {
|
||||
var property models.Property
|
||||
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cachedProperty, ok := r.cache[property.Id]; ok {
|
||||
properties = append(properties, cachedProperty)
|
||||
} else {
|
||||
r.cache[property.Id] = property
|
||||
properties = append(properties, property)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return properties, nil
|
||||
}
|
||||
|
||||
func (r *PropertyRepository) GetPropertyByPropertyTypeID(pid int) (models.Property, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE property_type_id = ?", pid)
|
||||
if err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var properties []models.Property
|
||||
for rows.Next() {
|
||||
var property models.Property
|
||||
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||
if err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
if cachedProperty, ok := r.cache[property.Id]; ok {
|
||||
properties = append(properties, cachedProperty)
|
||||
} else {
|
||||
r.cache[property.Id] = property
|
||||
properties = append(properties, property)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return models.Property{}, err
|
||||
}
|
||||
if len(properties) == 0 {
|
||||
return models.Property{}, nil
|
||||
}
|
||||
return properties[0], nil
|
||||
}
|
||||
|
||||
@@ -1,17 +1,74 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/models"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyTypeGroupRepository struct {
|
||||
db *sql.DB
|
||||
PropertyTypeRepository *PropertyTypeRepository
|
||||
cache map[int]models.PropertyTypeGroup
|
||||
}
|
||||
|
||||
func NewPropertyTypesGroupRepository(db *sql.DB, PropertyTypeRepository *PropertyTypeRepository) *PropertyTypeGroupRepository {
|
||||
return &PropertyTypeGroupRepository{
|
||||
db: db,
|
||||
PropertyTypeRepository: PropertyTypeRepository,
|
||||
cache: make(map[int]models.PropertyTypeGroup),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PropertyTypeGroupRepository) GetPropertyTypeGroupByID(id int) (models.PropertyTypeGroup, error) {
|
||||
if value, ok := r.cache[id]; ok {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
var value models.PropertyTypeGroup
|
||||
err := r.db.QueryRow("SELECT id, name, description, parenz_property_typw_goup_id, image_url FROM property_type_groups WHERE id = ?", id).Scan(&value.Id, &value.Name, &value.Description, &value.ParentPropertyTypeGroupId, &value.ImageURL)
|
||||
if err != nil {
|
||||
return models.PropertyTypeGroup{}, err
|
||||
}
|
||||
r.cache[id] = value
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (r *PropertyTypeGroupRepository) GetPropertyTypesByGroupId(gid int) ([]models.PropertyTypeGroup, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, parenz_property_typw_goup_id, image_url FROM property_type_groups WHERE parenz_property_typw_goup_id = ?", gid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var groups []models.PropertyTypeGroup
|
||||
for rows.Next() {
|
||||
var value models.PropertyTypeGroup
|
||||
err := rows.Scan(&value.Id, &value.Name, &value.Description, &value.ParentPropertyTypeGroupId, &value.ImageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, ok := r.cache[value.Id]; !ok {
|
||||
r.cache[value.Id] = value
|
||||
}
|
||||
|
||||
groups = append(groups, value)
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
func (r *PropertyTypeGroupRepository) CreatePropertyTypeGroup(value models.PropertyTypeGroup) (models.PropertyTypeGroup, error) {
|
||||
result, err := r.db.Exec("INSERT INTO property_type_groups (name) VALUES (?)", value.Name)
|
||||
if err != nil {
|
||||
return models.PropertyTypeGroup{}, err
|
||||
}
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return models.PropertyTypeGroup{}, err
|
||||
}
|
||||
value.Id = int(id)
|
||||
r.cache[value.Id] = value
|
||||
return value, nil
|
||||
}
|
||||
|
||||
@@ -1,17 +1,74 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/models"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type PropertyTypeRepository struct {
|
||||
db *sql.DB
|
||||
pr *PropertyRepository
|
||||
db *sql.DB
|
||||
pr *PropertyRepository
|
||||
cache map[int]models.PropertyType
|
||||
}
|
||||
|
||||
func NewPropertyTypeRepository(db *sql.DB, propertyRepository *PropertyRepository) *PropertyTypeRepository {
|
||||
return &PropertyTypeRepository{
|
||||
db: db,
|
||||
pr: propertyRepository,
|
||||
db: db,
|
||||
pr: propertyRepository,
|
||||
cache: make(map[int]models.PropertyType),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PropertyTypeRepository) GetPropertyTypeByID(id int) (models.PropertyType, error) {
|
||||
if propertyType, ok := r.cache[id]; ok {
|
||||
return propertyType, nil
|
||||
}
|
||||
var propertyType models.PropertyType
|
||||
err := r.db.QueryRow("SELECT id, name, description, image_url, property_types_groups_id FROM property_types WHERE id = ?", id).Scan(&propertyType.Id, &propertyType.Name, &propertyType.Description, &propertyType.ImageURL, &propertyType.PropertyTypesGroupsId)
|
||||
if err != nil {
|
||||
return models.PropertyType{}, err
|
||||
}
|
||||
r.cache[id] = propertyType
|
||||
return propertyType, nil
|
||||
}
|
||||
|
||||
func (r *PropertyTypeRepository) GetPropertyTypesByGroupID(pid int) ([]models.PropertyType, error) {
|
||||
rows, err := r.db.Query("SELECT id, name, description, image_url, property_types_groups_id FROM property_types WHERE property_types_groups_id = ?", pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var propertyTypes []models.PropertyType
|
||||
for rows.Next() {
|
||||
var propertyType models.PropertyType
|
||||
err := rows.Scan(&propertyType.Id, &propertyType.Name, &propertyType.Description, &propertyType.ImageURL, &propertyType.PropertyTypesGroupsId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cachedPropertyType, ok := r.cache[propertyType.Id]; ok {
|
||||
propertyTypes = append(propertyTypes, cachedPropertyType)
|
||||
} else {
|
||||
r.cache[propertyType.Id] = propertyType
|
||||
propertyTypes = append(propertyTypes, propertyType)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return propertyTypes, nil
|
||||
}
|
||||
|
||||
func (r *PropertyTypeRepository) createPropertyType(propertyType models.PropertyType) (models.PropertyType, error) {
|
||||
result, err := r.db.Exec("INSERT INTO property_types (name, description, image_url, property_types_groups_id) VALUES (?, ?, ?, ?)", propertyType.Name, propertyType.Description, propertyType.ImageURL, propertyType.PropertyTypesGroupsId)
|
||||
if err != nil {
|
||||
return models.PropertyType{}, err
|
||||
}
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return models.PropertyType{}, err
|
||||
}
|
||||
propertyType.Id = int(id)
|
||||
r.cache[propertyType.Id] = propertyType
|
||||
return propertyType, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/models"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type ValueRepository struct {
|
||||
db *sql.DB
|
||||
cache map[int]models.Value
|
||||
}
|
||||
|
||||
func NewValueRepository(db *sql.DB) *ValueRepository {
|
||||
return &ValueRepository{
|
||||
db: db,
|
||||
cache: make(map[int]models.Value),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ValueRepository) GetValueByID(id int) (models.Value, error) {
|
||||
if value, ok := r.cache[id]; ok {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
var value models.Value
|
||||
err := r.db.QueryRow("SELECT id, value, image_url FROM values WHERE id = ?", id).Scan(&value.Id, &value.Value, &value.ImageURL)
|
||||
if err != nil {
|
||||
return models.Value{}, err
|
||||
}
|
||||
r.cache[id] = value
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (r *ValueRepository) GetValuesByPropertyId(pid int) ([]models.Value, error) {
|
||||
rows, err := r.db.Query("SELECT id, value, image_url, properties_id FROM values WHERE properties_id = ?", pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var values []models.Value
|
||||
for rows.Next() {
|
||||
var value models.Value
|
||||
err := rows.Scan(&value.Id, &value.Value, &value.ImageURL, &value.PropertiesId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cachedValue, ok := r.cache[value.Id]; ok {
|
||||
values = append(values, cachedValue)
|
||||
} else {
|
||||
r.cache[value.Id] = value
|
||||
values = append(values, value)
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func (r *ValueRepository) CreateValue(value models.Value) (models.Value, error) {
|
||||
result, err := r.db.Exec("INSERT INTO values (value, image_url, properties_id) VALUES (?, ?, ?)", value.Value, value.ImageURL, value.PropertiesId)
|
||||
if err != nil {
|
||||
return models.Value{}, err
|
||||
}
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return models.Value{}, err
|
||||
}
|
||||
value.Id = int(id)
|
||||
r.cache[value.Id] = value
|
||||
return value, nil
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type ValueRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewValueRepository(db *sql.DB) *ValueRepository {
|
||||
return &ValueRepository{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,41 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"SimplyCPQ2/internal/models"
|
||||
"SimplyCPQ2/internal/repositories"
|
||||
)
|
||||
|
||||
type PropertyTypeService struct {
|
||||
// Add any dependencies or fields needed for the service here
|
||||
values_Repository *repositories.ValueRepository
|
||||
Property_Repository *repositories.PropertyRepository
|
||||
PropertyTypes_Repository *repositories.PropertyTypeRepository
|
||||
PropertyTypeGroups_Repository *repositories.PropertyTypeGroupRepository
|
||||
}
|
||||
|
||||
func NewPropertyTypeService(propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository) *PropertyTypeService {
|
||||
func NewPropertyTypeService(propertyRepo *repositories.PropertyRepository, propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository, valuesRepo *repositories.ValueRepository) *PropertyTypeService {
|
||||
return &PropertyTypeService{
|
||||
Property_Repository: propertyRepo,
|
||||
PropertyTypes_Repository: propertyTypesRepo,
|
||||
PropertyTypeGroups_Repository: propertyTypesGroupsRepo,
|
||||
values_Repository: valuesRepo,
|
||||
}
|
||||
}
|
||||
|
||||
// Getter functions
|
||||
|
||||
func (service *PropertyTypeService) GetPropertyTypeGroupsByParentId(parentId int) ([]models.PropertyTypeGroup, error) {
|
||||
return service.PropertyTypeGroups_Repository.GetPropertyTypesByGroupId(parentId)
|
||||
}
|
||||
|
||||
func (service *PropertyTypeService) GetPropertyTypesByGroupId(id int) ([]models.PropertyType, error) {
|
||||
return service.PropertyTypes_Repository.GetPropertyTypesByGroupID(id)
|
||||
}
|
||||
|
||||
func (service *PropertyTypeService) GetPropertyByTypeId(id int) (models.Property, error) {
|
||||
return service.Property_Repository.GetPropertyByPropertyTypeID(id)
|
||||
}
|
||||
|
||||
func (service *PropertyTypeService) GetValuesByPropertyId(id int) ([]models.Value, error) {
|
||||
return service.values_Repository.GetValuesByPropertyId(id)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/static/css/scpq_global.css">
|
||||
<link rel="stylesheet" href="/static/css/scpq_header.css">
|
||||
<link rel="stylesheet" href="/static/css/scpq_footer.css">
|
||||
<link rel="stylesheet" href="/static/css/scpq_content.css">
|
||||
<title>Simply CPQ Material Editor V2</title>
|
||||
</head>
|
||||
<body>
|
||||
<header class="row">
|
||||
<div class="col-8 col-s-12">
|
||||
<h1>Simply CPQ Material Editor V2</h1>
|
||||
</div>
|
||||
</header>
|
||||
<div class="row">
|
||||
<nav class="col-2 col-s-12">
|
||||
<ul>
|
||||
<li>
|
||||
<ul>
|
||||
<details closed>
|
||||
<summary>
|
||||
Eigenschaften
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul>
|
||||
<details closed>
|
||||
<summary>
|
||||
Produkte
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul>
|
||||
<details closed>
|
||||
<summary>
|
||||
Regeln
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul>
|
||||
<details closed>
|
||||
<summary>
|
||||
Preiskalkulation
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul>
|
||||
<details closed>
|
||||
<summary>
|
||||
Übersetzungen
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="col-6 col-s-6">
|
||||
<h3>Property-Type Group </h3>
|
||||
<section class="editor-view">
|
||||
<section id="PropertyTypeGroupData">
|
||||
<form class="cform" method="post" action="/updatePropertyTypeGroup">
|
||||
<label for="propertyTypeGroupID">ID:</label>
|
||||
<input type="text" id="propertyTypeGroupID" name="propertyTypeGroupID" value="{PropertyTypeGroupID}" disabled>
|
||||
<label for="propertyTypeGroupName">Name:</label>
|
||||
<input type="text" id="propertyTypeGroupName" name="propertyTypeGroupName" value="{PropertyTypeGroupName}">
|
||||
<label for="propertyTypeGroupDescription">Beschreibung:</label>
|
||||
<textarea id="propertyTypeGroupDescription" name="propertyTypeGroupDescription">{PropertyTypeGroupDescription}</textarea>
|
||||
<div class="button_row">
|
||||
<button type="submit">Speichern</button>
|
||||
<button type="submit">Neu</button>
|
||||
<button type="submit">Löschen</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<div class="col-6 col-s-12">
|
||||
<div class="aside">
|
||||
<h3>Values für {PropertyTypeName}</h3>
|
||||
<section class="editor-view">
|
||||
<section id="ValueData">
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Value</th>
|
||||
<th>Description</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Value 1</td>
|
||||
<td>Description 1</td>
|
||||
<td>
|
||||
<div class="button_row">
|
||||
<button type="button">Edit</button>
|
||||
<button type="button">Delete</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>Value 2</td>
|
||||
<td>Description 2</td>
|
||||
<td>
|
||||
<div class="button_row">
|
||||
<button type="button">Edit</button>
|
||||
<button type="button">Delete</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div> <!-- Closing the initial row div -->
|
||||
<footer class="row">
|
||||
<div class="col-12 col-s-12">
|
||||
<h6>© 2026 Simply CPQ - All rights reserved - contact: <a href="mailto:Thomas.Sindt@gmx.de">Thomas.Sindt@gmx.de</a></h6>
|
||||
</div>
|
||||
</footer> <!-- Closing the footer row div -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,6 +7,7 @@
|
||||
<link rel="stylesheet" href="/static/css/scpq_header.css">
|
||||
<link rel="stylesheet" href="/static/css/scpq_footer.css">
|
||||
<link rel="stylesheet" href="/static/css/scpq_content.css">
|
||||
<script src="/static/js/htmx.js"></script>
|
||||
<title>Simply CPQ Material Editor V2</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -19,15 +20,13 @@
|
||||
<nav class="col-2 col-s-12">
|
||||
<ul>
|
||||
<li>
|
||||
<ul>
|
||||
<ul class="node" hx-get="/properties/0/childs" hx-trigger="click" hx-target="#node-0" hx-swap="outerHTML">
|
||||
<details closed>
|
||||
<summary>
|
||||
Eigenschaften
|
||||
</summary>
|
||||
<ul class="node">
|
||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||
</ul>
|
||||
<div id="node-0">Keine Informationen vorhanden
|
||||
</div>
|
||||
</details>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{{define "ptg_treeNode"}}
|
||||
{{- range .}}
|
||||
<ul class="node" hx-get="/properties/{{.Id}}/childs" hx-trigger="click" hx-target="#node-{{.Id}}" hx-swap="outerHTML">
|
||||
<details closed>
|
||||
<summary>
|
||||
{{.Name}}
|
||||
</summary>
|
||||
<div id="node-{{.Id}}">Keine Informationen vorhanden
|
||||
</div>
|
||||
<ul class="node">
|
||||
{{range .Property_Types}}
|
||||
<li>{{.Name}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
{{- end}}
|
||||
{{end}}
|
||||
@@ -0,0 +1,20 @@
|
||||
# Use postgres/example user/password credentials
|
||||
|
||||
services:
|
||||
|
||||
db:
|
||||
image: postgres
|
||||
restart: always
|
||||
# set shared memory limit when using docker compose
|
||||
shm_size: 128mb
|
||||
# or set shared memory limit when deploy via swarm stack
|
||||
#volumes:
|
||||
# - type: tmpfs
|
||||
# target: /dev/shm
|
||||
# tmpfs:
|
||||
# size: 134217728 # 128*2^20 bytes = 128Mb
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_USER: tsindt
|
||||
POSTGRES_PASSWORD: XD14ko8d
|
||||
Reference in New Issue
Block a user