diff --git a/backup.sql b/backup.sql index 504ccf1..f7ed05e 100644 --- a/backup.sql +++ b/backup.sql @@ -20,6 +20,42 @@ SET default_tablespace = ''; SET default_table_access_method = heap; +-- +-- Name: gallery_images; Type: TABLE; Schema: public; Owner: tgadmin +-- + +CREATE TABLE public.gallery_images ( + id integer NOT NULL, + image_url text NOT NULL, + title text, + uploaded_at timestamp without time zone DEFAULT now() +); + + +ALTER TABLE public.gallery_images OWNER TO tgadmin; + +-- +-- Name: gallery_images_id_seq; Type: SEQUENCE; Schema: public; Owner: tgadmin +-- + +CREATE SEQUENCE public.gallery_images_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.gallery_images_id_seq OWNER TO tgadmin; + +-- +-- Name: gallery_images_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tgadmin +-- + +ALTER SEQUENCE public.gallery_images_id_seq OWNED BY public.gallery_images.id; + + -- -- Name: news; Type: TABLE; Schema: public; Owner: tgadmin -- @@ -196,6 +232,13 @@ ALTER TABLE public.users_id_seq OWNER TO tgadmin; ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; +-- +-- Name: gallery_images id; Type: DEFAULT; Schema: public; Owner: tgadmin +-- + +ALTER TABLE ONLY public.gallery_images ALTER COLUMN id SET DEFAULT nextval('public.gallery_images_id_seq'::regclass); + + -- -- Name: news id; Type: DEFAULT; Schema: public; Owner: tgadmin -- @@ -224,12 +267,31 @@ ALTER TABLE ONLY public.teams ALTER COLUMN id SET DEFAULT nextval('public.teams_ ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); +-- +-- Data for Name: gallery_images; Type: TABLE DATA; Schema: public; Owner: tgadmin +-- + +COPY public.gallery_images (id, image_url, title, uploaded_at) FROM stdin; +1 /uploads/gallery/1745995571128.jpg \N 2025-04-30 06:46:11.135241 +2 /uploads/gallery/1745995574092.jpg \N 2025-04-30 06:46:14.14359 +3 /uploads/gallery/1745995576651.png \N 2025-04-30 06:46:16.693676 +5 /uploads/gallery/1745995582496.jpg \N 2025-04-30 06:46:22.543915 +7 /uploads/gallery/1745995795079.jpg \N 2025-04-30 06:49:55.087993 +8 /uploads/gallery/1745995797723.jpg \N 2025-04-30 06:49:57.773579 +9 /uploads/gallery/1745995800923.png \N 2025-04-30 06:50:00.973585 +10 /uploads/gallery/1745995804788.jpg \N 2025-04-30 06:50:04.833931 +11 /uploads/gallery/1745995810186.png \N 2025-04-30 06:50:10.23422 +13 /uploads/gallery/1745997000203.png \N 2025-04-30 07:10:00.204411 +14 /uploads/gallery/1745997004338.png \N 2025-04-30 07:10:04.383564 +\. + + -- -- Data for Name: news; Type: TABLE DATA; Schema: public; Owner: tgadmin -- COPY public.news (id, title, description, image_url, team, created_at) FROM stdin; -1 Neue News vorhanden
Diese hat sogar Rich Text Support enabled!
/uploads/news/1745912382857.jpg Herren 1 2025-04-29 07:39:47.266851 +1 Neue News vorhandenDiese hat sogar Rich Text Support enabled!
/uploads/news/1745994332500.jpg Herren 1 2025-04-29 07:39:47.266851 \. @@ -284,6 +346,7 @@ COPY public.teams (id, name, liga, sucht_spieler, social_media, karussell_bilder 5 Damen 2 \N f \N \N \N \N \N \N \N \N \N \N 4 Damen 1 Landesliga t instagram.com/tgl_volleyball {} Sebastian Minden Montags & Freitags 20-22 Uhr Bergstraßenhalle Laudenbach Sebastian Minden sebastian@minden.de Grün Wir sind die Damen 1, eine super Truppe mit viel Zug zum Erfolg! https://www.volleyball-nordbaden.de/cms/home/halle/spielbetrieb/tabellen_vl_ll.xhtml?LeaguePresenter.view=resultTable&LeaguePresenter.matchSeriesId=70120527#samsCmsComponent_68828342 1 Herren 1 Landesliga f www.google.de {} Kahtrin Trübenbach Montags & Freitags, 19:30-22 Uhr Montags: Bergstraßenhalle Laudenbach, Freitags: BIZ Hemsbach Kathrin Trübenbach trübi@bach.de Grün Wir sind die H1 und wir machen Hackfleisch aus dir! https://www.volleyball-nordbaden.de/cms/home/halle/spielbetrieb/tabellen_vl_ll.xhtml?LeaguePresenter.view=resultTable&LeaguePresenter.matchSeriesId=70120580#samsCmsComponent_68828342 +9 Mixed Bezirksklasse t {} Wolf Blecher Freitags: 20-22 Uhr Bergstraßenhalle Laudenbach Wolf Blecher wolf@blech.de Grün Spiel und Spaß für jung und alt! \. @@ -294,10 +357,17 @@ COPY public.teams (id, name, liga, sucht_spieler, social_media, karussell_bilder COPY public.users (id, username, password, role, email, created_at, last_logged) FROM stdin; 2 kennyschrubber $2b$10$mHgcSphPt.WsNrEnYlM.i.wPVCeWnkd4bGCPpn2B50fdTOK9DvhxK user kennyschrubber@web.de 2025-04-23 13:19:15.946587 \N 4 hackerino $2b$10$DYv1lN3kivPCvdDnE4oSxOrXz0Bu.7K5EEz72RnjbgE9iemL3N/yS user hackerino@web.de 2025-04-23 13:29:57.510891 \N -1 marcwieland $2b$10$X0RgZYuVMBpIuGUM2PvGHew.siTgdaiJg0TbJ6sDZd0JPgXZII6IS admin wieland.marc@gmx.de 2025-04-23 12:00:02.440704 2025-04-29 13:39:40.285532 +1 marcwieland $2b$10$X0RgZYuVMBpIuGUM2PvGHew.siTgdaiJg0TbJ6sDZd0JPgXZII6IS admin wieland.marc@gmx.de 2025-04-23 12:00:02.440704 2025-04-30 06:45:53.31351 \. +-- +-- Name: gallery_images_id_seq; Type: SEQUENCE SET; Schema: public; Owner: tgadmin +-- + +SELECT pg_catalog.setval('public.gallery_images_id_seq', 14, true); + + -- -- Name: news_id_seq; Type: SEQUENCE SET; Schema: public; Owner: tgadmin -- @@ -316,7 +386,7 @@ SELECT pg_catalog.setval('public.players_id_seq', 13, true); -- Name: teams_id_seq; Type: SEQUENCE SET; Schema: public; Owner: tgadmin -- -SELECT pg_catalog.setval('public.teams_id_seq', 8, true); +SELECT pg_catalog.setval('public.teams_id_seq', 9, true); -- @@ -326,6 +396,14 @@ SELECT pg_catalog.setval('public.teams_id_seq', 8, true); SELECT pg_catalog.setval('public.users_id_seq', 4, true); +-- +-- Name: gallery_images gallery_images_pkey; Type: CONSTRAINT; Schema: public; Owner: tgadmin +-- + +ALTER TABLE ONLY public.gallery_images + ADD CONSTRAINT gallery_images_pkey PRIMARY KEY (id); + + -- -- Name: news news_pkey; Type: CONSTRAINT; Schema: public; Owner: tgadmin -- diff --git a/index.js b/index.js index 22b84bb..a892477 100644 --- a/index.js +++ b/index.js @@ -847,6 +847,86 @@ app.delete("/api/gallery/:id", async (req, res) => { }); + +//Event laden +app.get("/api/events", async (req, res) => { + const { showPrivate } = req.query; + const query = showPrivate === "true" + ? "SELECT * FROM events ORDER BY created_at DESC" + : "SELECT * FROM events WHERE is_private = FALSE ORDER BY created_at DESC"; + + const result = await db.query(query); + res.json(result.rows); +}); + + +//Event erstellen +app.post("/api/events", async (req, res) => { + const { title, description, max_participants, fee, address, is_private } = req.body; + + const result = await db.query( + `INSERT INTO events (title, description, max_participants, fee, address, is_private) + VALUES ($1, $2, $3, $4, $5, $6) RETURNING *`, + [title, description, max_participants, fee, address, is_private] + ); + + res.status(201).json(result.rows[0]); +}); + + +//Event editieren +app.put("/api/events/:id", async (req, res) => { + const { id } = req.params; + const { title, description, max_participants, fee, address, is_private } = req.body; + + const result = await db.query( + `UPDATE events + SET title = $1, + description = $2, + max_participants = $3, + fee = $4, + address = $5, + is_private = $6 + WHERE id = $7 + RETURNING *`, + [title, description, max_participants, fee, address, is_private, id] + ); + + if (result.rowCount === 0) { + return res.status(404).json({ message: "Event not found" }); + } + + res.json(result.rows[0]); +}); + + +//Event loeschen +app.delete("/api/events/:id", async (req, res) => { + const { id } = req.params; + + const result = await db.query(`DELETE FROM events WHERE id = $1`, [id]); + + if (result.rowCount === 0) { + return res.status(404).json({ message: "Event not found" }); + } + + res.status(204).send(); // No Content +}); + + + + + + + + + + + + + + + // Server starten app.listen(port, () => { const nets = os.networkInterfaces();