Browse Source

Cosetes!!!

master
Cristobal Bernal Mayordomo 1 year ago
parent
commit
cc5e20b66d
7 changed files with 71 additions and 16 deletions
  1. +0
    -0
      README.md
  2. +9
    -9
      src/main/java/com/cristobalbernal/foro/Entidades/Foro.java
  3. +5
    -5
      src/main/java/com/cristobalbernal/foro/Entidades/RespuestasEntity.java
  4. +4
    -1
      src/main/java/com/cristobalbernal/foro/controlador/Controlador.java
  5. +50
    -0
      src/main/java/com/cristobalbernal/foro/controlador/ControladorAPI.java
  6. +1
    -1
      src/main/resources/templates/footer/footer.html
  7. +2
    -0
      src/main/resources/templates/index.html

+ 0
- 0
README.md View File


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

@ -21,9 +21,9 @@ public class Foro {
@Basic
@Column(name = "fechaYHora", nullable = true)
private Timestamp fechaYHora;
@Basic
@Column(name = "imagen", nullable = false)
private int imagen;
@ManyToOne
@JoinColumn(name = "Usuarios", nullable = false)
private UsersEntity usuarios;
@Basic
@Column(name = "categoria_foro_id", nullable = true)
private int categoriaForoId;
@ -63,12 +63,12 @@ public class Foro {
this.fechaYHora = fechaYHora;
}
public int getImagen() {
return imagen;
public UsersEntity getUsuarios() {
return usuarios;
}
public void setImagen(int imagen) {
this.imagen = imagen;
public void setUsuarios(UsersEntity usuarios) {
this.usuarios = usuarios;
}
public int getCategoriaForoId() {
@ -84,11 +84,11 @@ public class Foro {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Foro foro = (Foro) o;
return id == foro.id && imagen == foro.imagen && Objects.equals(titulo, foro.titulo) && Objects.equals(descripcion, foro.descripcion) && Objects.equals(fechaYHora, foro.fechaYHora) && Objects.equals(categoriaForoId, foro.categoriaForoId);
return id == foro.id && usuarios == foro.usuarios && Objects.equals(titulo, foro.titulo) && Objects.equals(descripcion, foro.descripcion) && Objects.equals(fechaYHora, foro.fechaYHora) && Objects.equals(categoriaForoId, foro.categoriaForoId);
}
@Override
public int hashCode() {
return Objects.hash(id, titulo, descripcion, fechaYHora, imagen, categoriaForoId);
return Objects.hash(id, titulo, descripcion, fechaYHora, usuarios, categoriaForoId);
}
}

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

@ -19,9 +19,9 @@ public class RespuestasEntity {
@Basic
@Column(name = "fechaYHora", nullable = true)
private Timestamp fechaYHora;
@ManyToOne
@JoinColumn(name = "Respuestas_id", nullable = true)
private RespuestasEntity respuestasId;
@Basic
@Column(name = "Respuestas_id", nullable = true)
private int respuestasId;
@Basic
@Column(name = "users_id", nullable = false)
private int usersId;
@ -53,11 +53,11 @@ public class RespuestasEntity {
this.fechaYHora = fechaYHora;
}
public RespuestasEntity getRespuestasId() {
public int getRespuestasId() {
return respuestasId;
}
public void setRespuestasId(RespuestasEntity respuestasId) {
public void setRespuestasId(int respuestasId) {
this.respuestasId = respuestasId;
}


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

@ -61,7 +61,10 @@ public class Controlador {
}
@PostMapping("ask_question/add/submit")
public String addForo(@ModelAttribute("foro") Foro foro){
UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UsersEntity users = iUsers.findByEmail(userDetails.getUsername());
foro.setCategoriaForoId(1);
foro.setUsuarios(users);
servicioForo.add(foro);
return "redirect:/home";
}
@ -69,7 +72,7 @@ public class Controlador {
@PostMapping("/postdetall/add/submit/{id}")
public String addRespuesta(@ModelAttribute("respuesta") RespuestasEntity respuestas, @PathVariable int id){
respuestas.setForoId(id);
respuestas.setRespuestasId(respuestas);
respuestas.setRespuestasId(1);
respuestas.setUsersId(1);
servicioRespuestas.save(respuestas);
return "redirect:/postdetall/" + id;


+ 50
- 0
src/main/java/com/cristobalbernal/foro/controlador/ControladorAPI.java View File

@ -0,0 +1,50 @@
package com.cristobalbernal.foro.controlador;
import com.cristobalbernal.foro.Entidades.CategoriaForoEntity;
import com.cristobalbernal.foro.Entidades.Foro;
import com.cristobalbernal.foro.Entidades.RespuestasEntity;
import com.cristobalbernal.foro.Entidades.UsersEntity;
import com.cristobalbernal.foro.Respositorios.IUsers;
import com.cristobalbernal.foro.Servicios.ServicioCategoria;
import com.cristobalbernal.foro.Servicios.ServicioForo;
import com.cristobalbernal.foro.Servicios.ServicioRespuestas;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@RequestMapping("/api")
@Controller
public class ControladorAPI {
@Autowired
private IUsers iUsers;
@Autowired
private ServicioRespuestas servicioRespuestas;
@Autowired
private ServicioCategoria servicioCategoria;
@Autowired
private ServicioForo servicioForo;
@GetMapping("/users")
public @ResponseBody List<UsersEntity> getAllUsers(){
return iUsers.findAll();
}
@GetMapping("/respuestas")
public @ResponseBody List<RespuestasEntity> getAllRespuestas(){
return servicioRespuestas.findAll();
}
@GetMapping("/categorias")
public @ResponseBody List<CategoriaForoEntity> getAllCategorias(){
return servicioCategoria.findAll();
}
@GetMapping("/foro")
public @ResponseBody List<Foro> getAllForo(){
return servicioForo.init();
}
}

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

@ -19,7 +19,7 @@
<h4>Where We Are ?</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi adipiscing gravida odio, sit amet suscipit risus ultrices eu.</p>
<h4>Address :</h4>
<p>Ask Me Network, 33 Street, syada
<p>Ask Network, 33 Street, syada
<br> Zeinab, Cairo, Egypt.</p>
<h4>Support :</h4>
<p>Support Telephone No : (+2)01111011110</p>


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

@ -58,6 +58,8 @@
</div>
<hr>
<div class="text-muted"><p class="fa fa-clock-o"></p> <span aria-hidden="true" th:text="${Foro.fechaYHora}"></span> </div>
<div class="text-muted"><p class="fa fa-user"></p> <span aria-hidden="true" th:text="${Foro.usuarios.username}"></span> </div>
</div>
</div>
</div>


Loading…
Cancel
Save