mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
modified site controller and home.html so recipeDto's work and appear
This commit is contained in:
@@ -1,15 +1,28 @@
|
|||||||
package com.example.demo.controller;
|
package com.example.demo.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SiteController {
|
public class SiteController {
|
||||||
|
|
||||||
|
private final RecipeService recipeService;
|
||||||
|
|
||||||
|
public SiteController(RecipeService recipeService) {
|
||||||
|
this.recipeService = recipeService;
|
||||||
|
}
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String viewHomePage(Model model) {
|
public String viewHomePage(Model model) {
|
||||||
//model.addAttribute("allemplist", employeeServiceImpl.getAllEmployee());
|
//model.addAttribute("allemplist", employeeServiceImpl.getAllEmployee());
|
||||||
|
List<RecipeDto> recipes = recipeService.getAllRecipes();
|
||||||
|
model.addAttribute("recipes", recipes);
|
||||||
return "home";
|
return "home";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class RecipeServiceImpl implements RecipeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public RecipeDto saveRecipe(RecipeDto dto) {
|
public RecipeDto saveRecipe(RecipeDto dto) {
|
||||||
|
|
||||||
User user = userRepository.findById(dto.getUserDto().getId())
|
User user = userRepository.findById(dto.getUserDto().getId())
|
||||||
|
|||||||
@@ -44,8 +44,9 @@
|
|||||||
<p th:text="${recipe.description}"></p>
|
<p th:text="${recipe.description}"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-right">
|
<div class="card-right">
|
||||||
<img th:src="@{${recipe.imageUrl}}" alt="${recipe.imageAltText}">
|
<div th:each="img : ${recipe.images}">
|
||||||
<p th:text="${recipe.cost}"></p>
|
<img th:src="${img.imageUrl}" alt="Recipe Image"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user