9022961762
Ersetzt das Hello-World-Gerüst durch die vollständige Anwendung (com.example.mindflux: 64 Klassen, Thymeleaf-Templates, Static-Assets, Flyway V1–V6). Deploy-Infrastruktur (.gitea, Dockerfile) bleibt erhalten. - pom: volle Abhängigkeiten (Security, Thymeleaf, JPA, Flyway), Spring Boot 3.4.4 / Java 17 - docker-compose: SPRING_DATASOURCE_* unverändert; App lauscht auf 8080 (nginx -> mindflux:8080); Uploads-Volume; Admin-Passwörter via Gitea-Secrets - Workflow: Deploy-Step injiziert MINDFLUX_ADMIN*_PASSWORD aus Secrets - .dockerignore ergänzt; Hello-World (com.mindflux) und Test-Datei 'main' entfernt Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
846 B
Java
32 lines
846 B
Java
package com.example.mindflux.controller;
|
|
|
|
import com.example.mindflux.model.User;
|
|
import com.example.mindflux.repository.UserRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@Controller
|
|
@RequestMapping("/users")
|
|
public class UserViewController {
|
|
|
|
@Autowired
|
|
private UserRepository userRepository;
|
|
|
|
// Formular anzeigen
|
|
@GetMapping("/form")
|
|
public String showForm(Model model) {
|
|
model.addAttribute("user", new User());
|
|
return "user-form";
|
|
}
|
|
|
|
// Benutzer speichern
|
|
@PostMapping("/save")
|
|
public String saveUser(@ModelAttribute User user) {
|
|
userRepository.save(user);
|
|
return "user-success"; // statt redirect
|
|
}
|
|
|
|
}
|