Skip to content
Snippets Groups Projects
Commit 6a819f6c authored by Hoai Viet Nguyen's avatar Hoai Viet Nguyen
Browse files

fix redirect issue in nginx

parent 8d7460c7
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ server {
location / {
proxy_pass http://springboot:8080;
proxy_set_header Host $http_host;
}
}
\ No newline at end of file
package de.thk.gm.gdw.todolist.controllers
import de.thk.gm.gdw.todolist.dtos.TaskDto
import de.thk.gm.gdw.todolist.services.TasksService
import de.thk.gm.gdw.todolist.services.UsersService
import jakarta.validation.Valid
......@@ -26,12 +25,9 @@ class TasksController (private val tasksRestController: TasksRestController, pri
}
@PostMapping("/tasks")
fun saveTask(@Valid taskDto: TaskDto, bindingResult: BindingResult, redirectAttributes: RedirectAttributes, @PathVariable userId: UUID): String {
if (bindingResult.hasErrors()) {
redirectAttributes.addFlashAttribute("errors", bindingResult)
} else {
tasksRestController.saveTask(taskDto, userId)
}
fun saveTask(name: String, @PathVariable userId: UUID): String {
tasksRestController.saveTask(name, userId)
return "redirect:/users/$userId/tasks"
}
......@@ -44,15 +40,12 @@ class TasksController (private val tasksRestController: TasksRestController, pri
}
@PutMapping("/tasks/{id}")
fun updateTask(@PathVariable userId: UUID, @PathVariable id: UUID,@Valid taskDto: TaskDto,bindingResult: BindingResult, redirectAttributes: RedirectAttributes): String {
if(bindingResult.hasErrors()) {
redirectAttributes.addFlashAttribute("errors", bindingResult)
} else {
fun updateTask(@PathVariable userId: UUID, @PathVariable id: UUID, name: String, open: Boolean): String {
var task = tasksRestController.getTaskById(id, userId)
task.name = taskDto.name
task.open = taskDto.open
task.name = name
task.open = open
tasksService.save(task)
}
return "redirect:/users/$userId/tasks/${id}"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment