Browse Source

Cositas

master
Cristobal Bernal Mayordomo 1 year ago
parent
commit
97218ee2a5
5 changed files with 22 additions and 21 deletions
  1. +12
    -11
      src/main/java/com/cristobalbernal/foro/Servicios/ServicioForo.java
  2. +6
    -6
      src/main/java/com/cristobalbernal/foro/controlador/Controlador.java
  3. +1
    -1
      src/main/java/com/cristobalbernal/foro/seguridad/ConfigSeguridad.java
  4. +2
    -2
      src/main/resources/templates/Respuestas/post-detall.html
  5. +1
    -1
      src/main/resources/templates/index.html

+ 12
- 11
src/main/java/com/cristobalbernal/foro/Servicios/ServicioForo.java View File

@ -1,21 +1,22 @@
package com.cristobalbernal.foro.Servicios;
import com.cristobalbernal.foro.Entidades.Foro;
import com.cristobalbernal.foro.Respositorios.IForo;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ServicioForo {
private Foro[] foro;
public ServicioForo(){
}
public Foro[] findAll(){
return foro;
@Autowired
private IForo iForo;
public List<Foro> init(){
return iForo.findAll();
}
@PostConstruct
public void init(){
foro = new Foro[3];
foro[0] = new Foro(0,"Titular1","Hola",1,1);
foro[1] = new Foro(1,"Titular2","HolaDos",2,2);
foro[2] = new Foro(2,"Titular3","HolaTres",3,3);
public Foro findById(long id){
return iForo.findById((int) id).orElse(null);
}
}

+ 6
- 6
src/main/java/com/cristobalbernal/foro/controlador/Controlador.java View File

@ -10,6 +10,7 @@ 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.ResponseBody;
import java.util.List;
@ -29,7 +30,7 @@ public class Controlador {
}
@GetMapping({"","/home","/"})
public String indice(Model model){
model.addAttribute("listaForo",servicioForo.findAll());
model.addAttribute("listaForo",servicioForo.init());
return "index";
}
@GetMapping("/login")
@ -45,11 +46,10 @@ public class Controlador {
return "Ask_Question/ask_question";
}
@GetMapping("/postdetall")
public String postDetall(Model model){
Foro[] foro = servicioForo.findAll();
model.addAttribute("titulo", foro[0].getTitulo());
model.addAttribute("cuerpo", foro[0].getDescripcion());
@GetMapping("/postdetall/{id}")
public String postDetall(@PathVariable Long id,Model model){
Foro foro = servicioForo.findById(id);
model.addAttribute("Foro",foro);
return "Respuestas/post-detall";
}
@GetMapping("/all")


+ 1
- 1
src/main/java/com/cristobalbernal/foro/seguridad/ConfigSeguridad.java View File

@ -18,7 +18,7 @@ public class ConfigSeguridad {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((requests) -> requests
.requestMatchers("","/home","/","/registrar","/css/**","/image/**","/fonts/**","js/**","/postdetall").permitAll()
.requestMatchers("","/home","/","/registrar","/css/**","/image/**","/fonts/**","js/**","/postdetall/{id}").permitAll()
.anyRequest().authenticated()
)
.formLogin((form) -> form


+ 2
- 2
src/main/resources/templates/Respuestas/post-detall.html View File

@ -29,12 +29,12 @@
<div class="row">
<div class="col-md-8">
<div class="post-title-left129">
<h3 th:text="${titulo}">This Is My first Question</h3> </div>
<h3 th:text="${Foro.titulo}">This Is My first Question</h3> </div>
</div>
</div>
</div>
<div class="post-details-info1982">
<p th:text="${cuerpo}">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi adipiscing gravida odio, sit amet suscipit risus ultrices eu. Fusce viverra neque at purus laoreet consequat. Vivamus vulputate posuere nisl quis consequat. Donec congue commodo mi, sed commodo velit fringilla ac. Fusce placerat venenatis mi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras ornare, dolor a aliquet rutrum, dolor turpis condimentum leo, a semper lacus purus in felis. Quisque blandit posuere turpis, eget auctor felis pharetra eu .</p>
<p th:text="${Foro.descripcion}">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi adipiscing gravida odio, sit amet suscipit risus ultrices eu. Fusce viverra neque at purus laoreet consequat. Vivamus vulputate posuere nisl quis consequat. Donec congue commodo mi, sed commodo velit fringilla ac. Fusce placerat venenatis mi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras ornare, dolor a aliquet rutrum, dolor turpis condimentum leo, a semper lacus purus in felis. Quisque blandit posuere turpis, eget auctor felis pharetra eu .</p>
<hr>
</div>
<button id="boton" onclick="mostrar();">Responder</button>


+ 1
- 1
src/main/resources/templates/index.html View File

@ -50,7 +50,7 @@
<div class="col-md-5">
<div class="right-description893">
<div id="que-hedder2983">
<h3><a href="/postdetall" target="_blank" th:text="${Foro.titulo}">How Did You Hear About This Position?</a></h3> </div>
<h3><a th:href="@{/postdetall/{id}(id=${Foro.id})}" target="_blank" th:text="${Foro.titulo}">How Did You Hear About This Position?</a></h3> </div>
<div class="ques-details10018">
<p th:text="${Foro.descripcion}">Wouldn’t it be great if you knew exactly what questions a hiring manager would be asking you in your next job interview?
We can’t read minds, unfortunately, but we’ll give you the next best thing: a list of more than 40 of the most commonly asked interview questions, along with advice for answering them all.


Loading…
Cancel
Save