mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
The Unpopular Decision
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.example.demo.service.RecipeService;
|
||||
import com.example.demo.dto.RecipeDto;
|
||||
import com.example.demo.entity.Recipe;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Controller
|
||||
public class SiteController {
|
||||
|
||||
private final RecipeService recipeService;
|
||||
|
||||
public SiteController(RecipeService recipeService) {
|
||||
this.recipeService = recipeService;
|
||||
}
|
||||
@GetMapping("/")
|
||||
public String viewHomePage(Model model) {
|
||||
//model.addAttribute("allemplist", employeeServiceImpl.getAllEmployee());
|
||||
List<RecipeDto> recipes = recipeService.getAllRecipes();
|
||||
model.addAttribute("recipes", recipes);
|
||||
return "home";
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
public String viewLoginPage(Model model) {
|
||||
return "login";
|
||||
}
|
||||
|
||||
@GetMapping("/register")
|
||||
public String viewRegisterPage(Model model) {
|
||||
return "create-account";
|
||||
}
|
||||
|
||||
@GetMapping("/create")
|
||||
public String viewCreatePage(Model model) {
|
||||
return "create-recipe";
|
||||
}
|
||||
|
||||
@GetMapping("/recipes/{id}")
|
||||
public String viewRecipe(@PathVariable Integer id, Model model) {
|
||||
RecipeDto recipe = recipeService.getRecipeById(id);
|
||||
model.addAttribute("recipe", recipe);
|
||||
return "view-recipe";
|
||||
}
|
||||
|
||||
@GetMapping("/explore")
|
||||
public String viewExplorePage(Model model) {
|
||||
//model.addAttribute("allemplist", employeeServiceImpl.getAllEmployee());
|
||||
List<RecipeDto> recipes = recipeService.getAllRecipes();
|
||||
model.addAttribute("recipes", recipes);
|
||||
return "explore";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user