Browse Source

ya se puede añadir y responder!!!

master
Cristobal Bernal Mayordomo 1 year ago
parent
commit
c2fa655f43
8 changed files with 24 additions and 21 deletions
  1. +6
    -5
      src/main/java/com/cristobalbernal/foro/Entidades/Foro.java
  2. +1
    -1
      src/main/java/com/cristobalbernal/foro/Entidades/RespuestasEntity.java
  3. +4
    -0
      src/main/java/com/cristobalbernal/foro/Servicios/ServicioForo.java
  4. +7
    -1
      src/main/java/com/cristobalbernal/foro/controlador/Controlador.java
  5. +1
    -1
      src/main/resources/application.properties
  6. +2
    -9
      src/main/resources/templates/Ask_Question/ask_question.html
  7. +2
    -3
      src/main/resources/templates/index.html
  8. +1
    -1
      src/main/resources/templates/menu/menu.html

+ 6
- 5
src/main/java/com/cristobalbernal/foro/Entidades/Foro.java View File

@ -17,15 +17,16 @@ public class Foro {
@Basic @Basic
@Column(name = "descripcion", nullable = true, length = 150) @Column(name = "descripcion", nullable = true, length = 150)
private String descripcion; private String descripcion;
@Version
@Basic @Basic
@Column(name = "fechaYHora", nullable = true) @Column(name = "fechaYHora", nullable = true)
private Timestamp fechaYHora; private Timestamp fechaYHora;
@Basic @Basic
@Column(name = "imagen", nullable = false) @Column(name = "imagen", nullable = false)
private int imagen; private int imagen;
@ManyToOne
@JoinColumn(name = "categoria_foro_id", nullable = false)
private CategoriaForoEntity categoriaForoId;
@Basic
@Column(name = "categoria_foro_id", nullable = false)
private int categoriaForoId;
public Foro() { public Foro() {
} }
@ -70,11 +71,11 @@ public class Foro {
this.imagen = imagen; this.imagen = imagen;
} }
public CategoriaForoEntity getCategoriaForoId() {
public int getCategoriaForoId() {
return categoriaForoId; return categoriaForoId;
} }
public void setCategoriaForoId(CategoriaForoEntity categoriaForoId) {
public void setCategoriaForoId(int categoriaForoId) {
this.categoriaForoId = categoriaForoId; this.categoriaForoId = categoriaForoId;
} }


+ 1
- 1
src/main/java/com/cristobalbernal/foro/Entidades/RespuestasEntity.java View File

@ -20,7 +20,7 @@ public class RespuestasEntity {
@Column(name = "fechaYHora", nullable = true) @Column(name = "fechaYHora", nullable = true)
private Timestamp fechaYHora; private Timestamp fechaYHora;
@ManyToOne @ManyToOne
@JoinColumn(name = "Respuestas_id", nullable = false)
@JoinColumn(name = "Respuestas_id", nullable = true)
private RespuestasEntity respuestasId; private RespuestasEntity respuestasId;
@Basic @Basic
@Column(name = "users_id", nullable = false) @Column(name = "users_id", nullable = false)


+ 4
- 0
src/main/java/com/cristobalbernal/foro/Servicios/ServicioForo.java View File

@ -19,4 +19,8 @@ public class ServicioForo {
public Foro findById(long id){ public Foro findById(long id){
return iForo.findById((int) id).orElse(null); return iForo.findById((int) id).orElse(null);
} }
public void add(Foro foro) {
iForo.save(foro);
}
} }

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

@ -53,9 +53,15 @@ public class Controlador {
} }
@GetMapping("/crearPregunta") @GetMapping("/crearPregunta")
public String pregunta(Model model){ public String pregunta(Model model){
model.addAttribute("listaCategoria",servicioCategoria.findAll());
model.addAttribute("foro",new Foro());
return "Ask_Question/ask_question"; return "Ask_Question/ask_question";
} }
@PostMapping("ask_question/add/submit")
public String addForo(@ModelAttribute("foro") Foro foro){
foro.setCategoriaForoId(1);
servicioForo.add(foro);
return "redirect:/home";
}
@PostMapping("/postdetall/add/submit/{id}") @PostMapping("/postdetall/add/submit/{id}")
public String addRespuesta(@ModelAttribute("respuesta") RespuestasEntity respuestas, @PathVariable int id){ public String addRespuesta(@ModelAttribute("respuesta") RespuestasEntity respuestas, @PathVariable int id){


+ 1
- 1
src/main/resources/application.properties View File

@ -2,7 +2,7 @@ server.port=9000
spring.thymeleaf.cache=false spring.thymeleaf.cache=false
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mariadb://localhost:3306/forogruas
spring.datasource.url=jdbc:mariadb://localhost:3306/foro
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password= spring.datasource.password=
spring.jpa.properties.hibernate.jdbc.time_zone=UTC spring.jpa.properties.hibernate.jdbc.time_zone=UTC


+ 2
- 9
src/main/resources/templates/Ask_Question/ask_question.html View File

@ -25,22 +25,15 @@
<div class="col-md-9"> <div class="col-md-9">
<div class="ask-question-input-part032"> <div class="ask-question-input-part032">
<h4>Ask Question</h4> <h4>Ask Question</h4>
<form action="#" th:action="@{ask_question/add/submit}" th:object="${categoria}" method="post">
<form action="#" th:action="@{ask_question/add/submit}" th:object="${foro}" method="post">
<div class="question-title39"> <div class="question-title39">
<span class="form-description433">Question-Title*</span><input th:field="*{titulo}" type="text" name="fname" class="question-ttile32" placeholder="Escribe tu titulo!!!"> <span class="form-description433">Question-Title*</span><input th:field="*{titulo}" type="text" name="fname" class="question-ttile32" placeholder="Escribe tu titulo!!!">
</div> </div>
<div class="question-title39"> <div class="question-title39">
<span class="form-description433">Respuesta *</span><input th:field="*{descripcion}" type="text" name="fname" class="question-ttile32" placeholder="Escribe tu respues!!!"> <span class="form-description433">Respuesta *</span><input th:field="*{descripcion}" type="text" name="fname" class="question-ttile32" placeholder="Escribe tu respues!!!">
</div> </div>
<fieldset>
<legend>Seleciona Categoria:</legend>
<div th:each="Categoria: ${listaCategoria}">
<input type="checkbox" id="scales" name="scales" checked>
<label for="scales" th:text="${Categoria.name}">Scales</label>
</div>
</fieldset>
<div class="publish-button2389"> <div class="publish-button2389">
<button type="button" class="publis1291">Publish your Question</button>
<button type="submit" class="publis1291">Publish your Question</button>
</div> </div>
</form> </form>


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

@ -25,8 +25,7 @@
<div class="container"> <div class="container">
<div class="welcome-demop102 text-center"> <div class="welcome-demop102 text-center">
<h2>Welcome to FOROGRUAS, Awesome Questions & Answer Template</h2> <h2>Welcome to FOROGRUAS, Awesome Questions & Answer Template</h2>
<p>Duis dapibus aliquam mi, eget euismod sem scelerisque ut. Vivamus at elit quis urna adipiscing iaculis. Curabitur vitae velit in neque dictum blandit. Proin in iaculis neque. Pellentesque
<br> habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur vitae velit in neque dictum blandit</p>
<p>Bienvenido a ForoGruas un foro donde podes hacer preguntas de todo tipo.</p>
</div> </div>
</div> </div>
</section> </section>
@ -58,7 +57,7 @@
While we don’t recommend having a canned response for every interview question (in fact, please don’t), we do recommend spending some time getting comfortable with what you might be asked, what hiring managers are really looking for in your responses, and what it takes to show that you’re the right person for the job.</p> While we don’t recommend having a canned response for every interview question (in fact, please don’t), we do recommend spending some time getting comfortable with what you might be asked, what hiring managers are really looking for in your responses, and what it takes to show that you’re the right person for the job.</p>
</div> </div>
<hr> <hr>
<div class="ques-icon-info3293"> <a href="#"></i> </a> <a href="#"><i class="fa fa-user" aria-hidden="true">Pepito</i></a> <a href="#"><i class="fa fa-clock-o" aria-hidden="true"> 4 min ago</i></a> <a href="#"></a> <a href="#"></a> </div>
<div class="text-muted"><p class="fa fa-clock-o"></p> <span aria-hidden="true" th:text="${Foro.fechaYHora}"></span> </div>
</div> </div>
</div> </div>
</div> </div>


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

@ -14,7 +14,7 @@
<li><a href="/home">Home</a></li> <li><a href="/home">Home</a></li>
<li><a href="/crearPregunta">Ask Question</a></li> <li><a href="/crearPregunta">Ask Question</a></li>
<li><a href="/miperfil">Acceder</a></li> <li><a href="/miperfil">Acceder</a></li>
<!--<span sec:authentication="name">Sin autenticar</span> -->
<!--<h1 class="user-name" th:text="${nombre.getUsername()}">Sin autenticar</h1> -->
</ul> </ul>
</div> </div>
<!-- /.navbar-collapse --> <!-- /.navbar-collapse -->


Loading…
Cancel
Save