Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
4
Indexable
Never
 //pkydonakis
package gr.codelearn.app.controller;

import gr.codelearn.app.service.VisitService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@Controller
public class StatsController {

    private VisitService visitService;

    public StatsController() {
        this.visitService = new VisitService();
    }

    @GetMapping("/viewStatistics")
    public String viewStatistics(Model model) {
        model.addAttribute("allVisitResults", visitService.getAllVisitResults());
        return "viewStatistics";
    }

   
    @GetMapping("/resetStatistics")
    public String resetStatistics(Model model) {
        return "resetStatistics";
    }

    @PostMapping("/doResetStatistics")
    public String doResetStatistics(Model model) {
        visitService.resetStatistics();
        return "redirect:/viewStatistics";
    }
}