41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
package de.jottyfan.bico.modules.next;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import de.jottyfan.bico.modules.CommonController;
|
|
|
|
/**
|
|
*
|
|
* @author jotty
|
|
*
|
|
*/
|
|
@Controller
|
|
public class NextController extends CommonController {
|
|
|
|
@Autowired
|
|
private NextService service;
|
|
|
|
@GetMapping("/next")
|
|
public String getNext(@RequestParam(name = "groupname", required = false) String groupname, Model model) {
|
|
model.addAttribute("list", service.getNext(LocalDate.now(), groupname));
|
|
return "/next";
|
|
}
|
|
|
|
@GetMapping("/next/{date}")
|
|
public String getNextForDate(@PathVariable("date") String dateStr,
|
|
@RequestParam(name = "groupname", required = false) String groupname, Model model) {
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
LocalDate date = LocalDate.parse(dateStr, formatter);
|
|
model.addAttribute("list", service.getNext(date, groupname));
|
|
return "/next";
|
|
}
|
|
}
|