diff --git a/buildtime/client/material-editor/src/api/propertyType.api.ts b/buildtime/client/material-editor/src/api/propertyType.api.ts new file mode 100644 index 000000000..8f55b8064 --- /dev/null +++ b/buildtime/client/material-editor/src/api/propertyType.api.ts @@ -0,0 +1,71 @@ +import ky from 'ky' +import type { PropertyType } from '../data/propertyType' + +const API_BASE_URL = 'http://localhost:8088' + +type ApiResponse = { + message: string; + data: T; +} + +type BackendPropertyType = { + id: number; + label: string; + description: string; + propertyTypeGroupId: number; +} + +function toBackendPropertyType(propertyType: PropertyType): BackendPropertyType { + return { + id: propertyType.id, + label: propertyType.label, + description: propertyType.description, + propertyTypeGroupId: propertyType.propertyGroupId, + } +} + +function toClientPropertyType(propertyType: BackendPropertyType): PropertyType { + return { + id: propertyType.id, + label: propertyType.label, + description: propertyType.description, + propertyGroupId: propertyType.propertyTypeGroupId, + } +} + +export async function createPropertyType(propertyType: PropertyType): Promise { + const response = await ky + .post(`${API_BASE_URL}/createPropertyType`, { json: toBackendPropertyType(propertyType) }) + .json>() + + return toClientPropertyType(response.data) +} + +export async function updatePropertyType(propertyType: PropertyType): Promise { + const response = await ky + .put(`${API_BASE_URL}/updatePropertyType`, { json: toBackendPropertyType(propertyType) }) + .json>() + + return toClientPropertyType(response.data) +} + +export async function deletePropertyType(id: number): Promise { + await ky.delete(`${API_BASE_URL}/deletePropertyType/${id}`) +} + +export async function getPropertyType(id: number): Promise { + const response = await ky + .get(`${API_BASE_URL}/getPropertyType/${id}`) + .json>() + + return toClientPropertyType(response.data) +} + +export async function getPropertyTypesByGroupId(groupId: number): Promise { + const response = await ky + .get(`${API_BASE_URL}/getPropertyTypesByGroupId/${groupId}`) + .json>() + + return response.data.map(toClientPropertyType) +} + diff --git a/buildtime/client/material-editor/src/api/value.api.ts b/buildtime/client/material-editor/src/api/value.api.ts new file mode 100644 index 000000000..f200b9258 --- /dev/null +++ b/buildtime/client/material-editor/src/api/value.api.ts @@ -0,0 +1,53 @@ +import ky from 'ky' +import type { Value } from '../data/value' + +const API_BASE_URL = 'http://localhost:8088' + +type ApiResponse = { + message: string; + data: T; +} + +export async function createValueForPropertyTypeId(propertyTypeId: number, value: Value): Promise { + const response = await ky + .post(`${API_BASE_URL}/createValueForPropertyTypeId/${propertyTypeId}`, { json: value }) + .json>() + + return response.data +} + +export async function deleteValueFromPropertyTypeId(propertyTypeId: number): Promise { + await ky.delete(`${API_BASE_URL}/deleteValueFromPropertyTypeId/${propertyTypeId}`) +} + +export async function getValuesFromPropertyTypeId(propertyTypeId: number): Promise { + const response = await ky + .get(`${API_BASE_URL}/getValuesFromPropertyTypeId/${propertyTypeId}`) + .json>() + + return response.data +} + +export async function getValuesFromPropertyId(propertyId: number): Promise { + const response = await ky + .get(`${API_BASE_URL}/getValuesFromPropertyId/${propertyId}`) + .json>() + + return response.data +} + +export async function deleteValueFromPropertyId(valueId: number, propertyId: number): Promise { + await ky.delete(`${API_BASE_URL}/deleteValueFromPropertyId/${valueId}/${propertyId}`) +} + +export async function getValue(id: number): Promise { + const response = await ky + .get(`${API_BASE_URL}/getValue/${id}`) + .json>() + + return response.data +} + +export async function setTerminalValueForProperty(propertyId: number, value: string): Promise { + await ky.post(`${API_BASE_URL}/SetTerminalValueForProperty/${propertyId}/${value}`) +} diff --git a/buildtime/client/material-editor/src/data/value.ts b/buildtime/client/material-editor/src/data/value.ts new file mode 100644 index 000000000..ba24b4651 --- /dev/null +++ b/buildtime/client/material-editor/src/data/value.ts @@ -0,0 +1,6 @@ +export type Value = { + id: number; + label: string; + description: string; + propertyId: number; +}; diff --git a/buildtime/database/20260819.tsindt.backup b/buildtime/database/20260819.tsindt.backup new file mode 100644 index 000000000..0f4bf8418 Binary files /dev/null and b/buildtime/database/20260819.tsindt.backup differ diff --git a/buildtime/database/backup.sql b/buildtime/database/backup.sql new file mode 100644 index 000000000..55bd80aff --- /dev/null +++ b/buildtime/database/backup.sql @@ -0,0 +1,296 @@ +-- +-- PostgreSQL database dump +-- + +\restrict tr7G1QPNTTXLQIe4Aor0iXBst7bCIMG3YrRi4W0ctLjYNYkTNMzg0a7p1PBiCQw + +-- Dumped from database version 18.4 (Debian 18.4-1.pgdg13+1) +-- Dumped by pg_dump version 18.4 (Debian 18.4-1.pgdg13+1) + +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; + +-- +-- Name: global_id_seq; Type: SEQUENCE; Schema: public; Owner: tsindt +-- + +CREATE SEQUENCE public.global_id_seq + START WITH 1000000 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.global_id_seq OWNER TO tsindt; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: media; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.media ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + description text, + media text, + mediatype text, + externalid bigint +); + + +ALTER TABLE public.media OWNER TO tsindt; + +-- +-- Name: productgroups; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.productgroups ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + description text, + parentgroupid bigint +); + + +ALTER TABLE public.productgroups OWNER TO tsindt; + +-- +-- Name: products; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.products ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + externalid text, + description text, + productgroupid bigint +); + + +ALTER TABLE public.products OWNER TO tsindt; + +-- +-- Name: properties; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.properties ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) CONSTRAINT propertys_id_not_null NOT NULL, + label text, + description text, + propertytypeid bigint, + productid bigint, + productgroupid bigint +); + + +ALTER TABLE public.properties OWNER TO tsindt; + +-- +-- Name: propertytypegroups; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.propertytypegroups ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + description text, + parentgroupid bigint +); + + +ALTER TABLE public.propertytypegroups OWNER TO tsindt; + +-- +-- Name: propertytypes; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public.propertytypes ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + description text, + propertytypegroupid bigint +); + + +ALTER TABLE public.propertytypes OWNER TO tsindt; + +-- +-- Name: values; Type: TABLE; Schema: public; Owner: tsindt +-- + +CREATE TABLE public."values" ( + id bigint DEFAULT nextval('public.global_id_seq'::regclass) NOT NULL, + label text, + description text, + propertyid bigint +); + + +ALTER TABLE public."values" OWNER TO tsindt; + +-- +-- Data for Name: media; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.media (id, label, description, media, mediatype, externalid) FROM stdin; +\. + + +-- +-- Data for Name: productgroups; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.productgroups (id, label, description, parentgroupid) FROM stdin; +1000007 Simply CPQ Product catalog root 0 +1000008 Catalog Product catalog 1000007 +1000009 Components Components catalog 1000007 +1000028 Radio Radios for Home Stereo 1000008 +\. + + +-- +-- Data for Name: products; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.products (id, label, externalid, description, productgroupid) FROM stdin; +\. + + +-- +-- Data for Name: properties; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.properties (id, label, description, propertytypeid, productid, productgroupid) FROM stdin; +1000024 Colour System wide colors 1000003 0 1000008 +1000029 Colour System wide colors 1000003 0 1000028 +1000033 voltage Voltage for home usage 1000010 0 1000028 +\. + + +-- +-- Data for Name: propertytypegroups; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.propertytypegroups (id, label, description, parentgroupid) FROM stdin; +1000000 Simply CPQ Root Gruppe für den Merkmalspool 0 +1000001 System Property Types Systemweite Property-Typen werden hier abgelegt 1000000 +1000002 Product Property Types Produkt-relevante Property-Typen werden hier abgelegt 1000000 +\. + + +-- +-- Data for Name: propertytypes; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public.propertytypes (id, label, description, propertytypegroupid) FROM stdin; +1000003 Colour System wide colors 1000002 +1000010 voltage Voltage for home usage 1000002 +\. + + +-- +-- Data for Name: values; Type: TABLE DATA; Schema: public; Owner: tsindt +-- + +COPY public."values" (id, label, description, propertyid) FROM stdin; +1000004 Red Color Red 1000003 +1000005 Green Color Green 1000003 +1000006 Blue Color Blue 1000003 +1000011 12 V 1000010 +1000012 24 V 1000010 +1000013 110 V 1000010 +1000014 240 V 1000010 +1000015 440 V 1000010 +1000025 Red Color Red 1000024 +1000026 Green Color Green 1000024 +1000027 Blue Color Blue 1000024 +1000030 Red Color Red 1000029 +1000031 Green Color Green 1000029 +1000032 Blue Color Blue 1000029 +1000034 12 V 1000033 +1000035 24 V 1000033 +1000037 240 V 1000033 +\. + + +-- +-- Name: global_id_seq; Type: SEQUENCE SET; Schema: public; Owner: tsindt +-- + +SELECT pg_catalog.setval('public.global_id_seq', 1000038, true); + + +-- +-- Name: media media_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.media + ADD CONSTRAINT media_pkey PRIMARY KEY (id); + + +-- +-- Name: productgroups productgroups_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.productgroups + ADD CONSTRAINT productgroups_pkey PRIMARY KEY (id); + + +-- +-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.products + ADD CONSTRAINT products_pkey PRIMARY KEY (id); + + +-- +-- Name: properties propertys_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.properties + ADD CONSTRAINT propertys_pkey PRIMARY KEY (id); + + +-- +-- Name: propertytypegroups propertytypegroups_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.propertytypegroups + ADD CONSTRAINT propertytypegroups_pkey PRIMARY KEY (id); + + +-- +-- Name: propertytypes propertytypes_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public.propertytypes + ADD CONSTRAINT propertytypes_pkey PRIMARY KEY (id); + + +-- +-- Name: values values_pkey; Type: CONSTRAINT; Schema: public; Owner: tsindt +-- + +ALTER TABLE ONLY public."values" + ADD CONSTRAINT values_pkey PRIMARY KEY (id); + + +-- +-- PostgreSQL database dump complete +-- + +\unrestrict tr7G1QPNTTXLQIe4Aor0iXBst7bCIMG3YrRi4W0ctLjYNYkTNMzg0a7p1PBiCQw + diff --git a/buildtime/server/config.toml b/buildtime/server/config.toml index 0d6464fa7..762f9fbf0 100644 --- a/buildtime/server/config.toml +++ b/buildtime/server/config.toml @@ -4,7 +4,8 @@ # password= dbname= [database] -connection_string = "host=192.168.178.50 port=5432 user=tsindt password=XD14ko8d dbname=simply_cpq_master_data sslmode=disable" +## connection_string = "host=192.168.178.50 port=5432 user=tsindt password=XD14ko8d dbname=simply_cpq_master_data sslmode=disable" +connection_string = "host=localhost port=5432 user=tsindt password=XD14ko8d dbname=simply_cpq_master_data sslmode=disable" driver_name = "postgres" ################################################################