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;
|
||||
|
||||
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;
|
||||
|
||||
@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";
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public class RecipeServiceImpl implements RecipeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public RecipeDto saveRecipe(RecipeDto dto) {
|
||||
|
||||
User user = userRepository.findById(dto.getUserDto().getId())
|
||||
|
||||
@@ -44,8 +44,9 @@
|
||||
<p th:text="${recipe.description}"></p>
|
||||
</div>
|
||||
<div class="card-right">
|
||||
<img th:src="@{${recipe.imageUrl}}" alt="${recipe.imageAltText}">
|
||||
<p th:text="${recipe.cost}"></p>
|
||||
<div th:each="img : ${recipe.images}">
|
||||
<img th:src="${img.imageUrl}" alt="Recipe Image"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user