Browse Source

commit

master
Cristobal Bernal Mayordomo 1 year ago
parent
commit
331a6a5f7b
15 changed files with 418 additions and 78 deletions
  1. +19
    -1
      pom.xml
  2. +64
    -0
      src/main/java/com/cristobalbernal/foro/Entidades/CategoriaForoEntity.java
  3. +105
    -0
      src/main/java/com/cristobalbernal/foro/Entidades/RespuestasEntity.java
  4. +143
    -0
      src/main/java/com/cristobalbernal/foro/Entidades/UsersEntity.java
  5. +0
    -44
      src/main/java/com/cristobalbernal/foro/Modelo/Respuestas.java
  6. +4
    -0
      src/main/java/com/cristobalbernal/foro/Respositorios/ICategoriaForo.java
  7. +8
    -0
      src/main/java/com/cristobalbernal/foro/Respositorios/IForo.java
  8. +8
    -0
      src/main/java/com/cristobalbernal/foro/Respositorios/IRespuestas.java
  9. +8
    -0
      src/main/java/com/cristobalbernal/foro/Respositorios/IUsers.java
  10. +21
    -0
      src/main/java/com/cristobalbernal/foro/Servicios/ServicioForo.java
  11. +8
    -20
      src/main/java/com/cristobalbernal/foro/Servicios/ServicioRespuestas.java
  12. +20
    -9
      src/main/java/com/cristobalbernal/foro/controlador/Controlador.java
  13. +0
    -1
      src/main/java/com/cristobalbernal/foro/seguridad/MvcConfig.java
  14. +7
    -0
      src/main/resources/application.properties
  15. +3
    -3
      src/main/resources/templates/index.html

+ 19
- 1
pom.xml View File

@ -27,7 +27,25 @@
<artifactId>spring-boot-starter-web</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>3.1.5</version>


+ 64
- 0
src/main/java/com/cristobalbernal/foro/Entidades/CategoriaForoEntity.java View File

@ -0,0 +1,64 @@
package com.cristobalbernal.foro.Entidades;
import jakarta.persistence.*;
@Entity
@Table(name = "categoria_foro", schema = "forogruas", catalog = "")
public class CategoriaForoEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private int id;
@Basic
@Column(name = "name", nullable = true, length = 45)
private String name;
@Basic
@Column(name = "descripcion", nullable = true, length = 45)
private String descripcion;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CategoriaForoEntity that = (CategoriaForoEntity) o;
if (id != that.id) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0);
return result;
}
}

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

@ -0,0 +1,105 @@
package com.cristobalbernal.foro.Entidades;
import jakarta.persistence.*;
import java.sql.Timestamp;
@Entity
@Table(name = "respuestas", schema = "forogruas", catalog = "")
public class RespuestasEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private int id;
@Basic
@Column(name = "Post", nullable = true, length = 45)
private String post;
@Basic
@Column(name = "fechaYHora", nullable = true)
private Timestamp fechaYHora;
@Basic
@Column(name = "Respuestas_id", nullable = false)
private int respuestasId;
@Basic
@Column(name = "users_id", nullable = false)
private int usersId;
@Basic
@Column(name = "Foro_id", nullable = false)
private int foroId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPost() {
return post;
}
public void setPost(String post) {
this.post = post;
}
public Timestamp getFechaYHora() {
return fechaYHora;
}
public void setFechaYHora(Timestamp fechaYHora) {
this.fechaYHora = fechaYHora;
}
public int getRespuestasId() {
return respuestasId;
}
public void setRespuestasId(int respuestasId) {
this.respuestasId = respuestasId;
}
public int getUsersId() {
return usersId;
}
public void setUsersId(int usersId) {
this.usersId = usersId;
}
public int getForoId() {
return foroId;
}
public void setForoId(int foroId) {
this.foroId = foroId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RespuestasEntity that = (RespuestasEntity) o;
if (id != that.id) return false;
if (respuestasId != that.respuestasId) return false;
if (usersId != that.usersId) return false;
if (foroId != that.foroId) return false;
if (post != null ? !post.equals(that.post) : that.post != null) return false;
if (fechaYHora != null ? !fechaYHora.equals(that.fechaYHora) : that.fechaYHora != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (post != null ? post.hashCode() : 0);
result = 31 * result + (fechaYHora != null ? fechaYHora.hashCode() : 0);
result = 31 * result + respuestasId;
result = 31 * result + usersId;
result = 31 * result + foroId;
return result;
}
}

+ 143
- 0
src/main/java/com/cristobalbernal/foro/Entidades/UsersEntity.java View File

@ -0,0 +1,143 @@
package com.cristobalbernal.foro.Entidades;
import jakarta.persistence.*;
@Entity
@Table(name = "users", schema = "forogruas", catalog = "")
public class UsersEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private int id;
@Basic
@Column(name = "name", nullable = true, length = 45)
private String name;
@Basic
@Column(name = "firstname", nullable = true, length = 45)
private String firstname;
@Basic
@Column(name = "secondname", nullable = true, length = 45)
private String secondname;
@Basic
@Column(name = "password", nullable = true, length = 45)
private String password;
@Basic
@Column(name = "email", nullable = true, length = 45)
private String email;
@Basic
@Column(name = "username", nullable = true, length = 45)
private String username;
@Basic
@Column(name = "Imgen", nullable = true, length = 150)
private String imgen;
@Basic
@Column(name = "tipoPrivilegios", nullable = true)
private Byte tipoPrivilegios;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getSecondname() {
return secondname;
}
public void setSecondname(String secondname) {
this.secondname = secondname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getImgen() {
return imgen;
}
public void setImgen(String imgen) {
this.imgen = imgen;
}
public Byte getTipoPrivilegios() {
return tipoPrivilegios;
}
public void setTipoPrivilegios(Byte tipoPrivilegios) {
this.tipoPrivilegios = tipoPrivilegios;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UsersEntity that = (UsersEntity) o;
if (id != that.id) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (firstname != null ? !firstname.equals(that.firstname) : that.firstname != null) return false;
if (secondname != null ? !secondname.equals(that.secondname) : that.secondname != null) return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
if (email != null ? !email.equals(that.email) : that.email != null) return false;
if (username != null ? !username.equals(that.username) : that.username != null) return false;
if (imgen != null ? !imgen.equals(that.imgen) : that.imgen != null) return false;
if (tipoPrivilegios != null ? !tipoPrivilegios.equals(that.tipoPrivilegios) : that.tipoPrivilegios != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
result = 31 * result + (secondname != null ? secondname.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (imgen != null ? imgen.hashCode() : 0);
result = 31 * result + (tipoPrivilegios != null ? tipoPrivilegios.hashCode() : 0);
return result;
}
}

+ 0
- 44
src/main/java/com/cristobalbernal/foro/Modelo/Respuestas.java View File

@ -1,44 +0,0 @@
package com.cristobalbernal.foro.Modelo;
import java.util.ArrayList;
public class Respuestas {
private int id;
private String titulos;
private String descripcion;
private ArrayList<Respuestas> respuestasInternas;
public Respuestas(int id, String titulos, String descripcion) {
this.id = id;
this.titulos = titulos;
this.descripcion = descripcion;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitulos() {
return titulos;
}
public void setTitulos(String titulos) {
this.titulos = titulos;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public ArrayList<Respuestas> getRespuestas() {
return respuestasInternas;
}
}

+ 4
- 0
src/main/java/com/cristobalbernal/foro/Respositorios/ICategoriaForo.java View File

@ -0,0 +1,4 @@
package com.cristobalbernal.foro.Respositorios;
public interface ICategoriaForo {
}

+ 8
- 0
src/main/java/com/cristobalbernal/foro/Respositorios/IForo.java View File

@ -0,0 +1,8 @@
package com.cristobalbernal.foro.Respositorios;
import com.cristobalbernal.foro.Entidades.Foro;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IForo extends JpaRepository<Foro,Integer> {
}

+ 8
- 0
src/main/java/com/cristobalbernal/foro/Respositorios/IRespuestas.java View File

@ -0,0 +1,8 @@
package com.cristobalbernal.foro.Respositorios;
import com.cristobalbernal.foro.Entidades.RespuestasEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IRespuestas extends JpaRepository<RespuestasEntity,Integer> {
}

+ 8
- 0
src/main/java/com/cristobalbernal/foro/Respositorios/IUsers.java View File

@ -0,0 +1,8 @@
package com.cristobalbernal.foro.Respositorios;
import com.cristobalbernal.foro.Entidades.UsersEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IUsers extends JpaRepository<UsersEntity,Integer> {
}

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

@ -0,0 +1,21 @@
package com.cristobalbernal.foro.Servicios;
import com.cristobalbernal.foro.Entidades.Foro;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Service;
@Service
public class ServicioForo {
private Foro[] foro;
public ServicioForo(){
}
public Foro[] findAll(){
return foro;
}
@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);
}
}

+ 8
- 20
src/main/java/com/cristobalbernal/foro/Servicios/ServicioRespuestas.java View File

@ -1,39 +1,27 @@
package com.cristobalbernal.foro.Servicios;
import com.cristobalbernal.foro.Modelo.Respuestas;
import com.cristobalbernal.foro.Entidades.RespuestasEntity;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Service;
@Service
public class ServicioRespuestas {
private Respuestas[] respuestas;
private RespuestasEntity[] respuestas;
public ServicioRespuestas() {
}
public Respuestas[] findAll(){
public RespuestasEntity[] findAll(){
return respuestas;
}
@PostConstruct
public void init(){
respuestas = new Respuestas[6];
respuestas[0] = new Respuestas(0, "TITULO 1", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
respuestas[1] = new Respuestas(1, "TITULO 2", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
respuestas[2] = new Respuestas(2, "TITULO 3", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
respuestas[3] = new Respuestas(3, "TITULO 4", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
respuestas[4] = new Respuestas(4, "TITULO 5", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
respuestas[5] = new Respuestas(5, "TITULO 6", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
/*
respuestas = new RespuestasEntity[6];
respuestas[0] = new RespuestasEntity(0, "TITULO 1", "aslkjbdakjdbkajwdbjakwdbkawjdbawkd.bawdawd" +
"adaw,dbakwjdbawkjd,abjwkd,awk,dad" +
"awda,wbjdwakjdawkjdawdblaw");
*/
}
}

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

@ -1,19 +1,27 @@
package com.cristobalbernal.foro.controlador;
import com.cristobalbernal.foro.Modelo.Respuestas;
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.ServicioForo;
import com.cristobalbernal.foro.Servicios.ServicioRespuestas;
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.net.MalformedURLException;
import java.util.List;
@Controller
public class Controlador {
@Autowired
private IUsers iUsers;
@Autowired
private ServicioRespuestas servicioRespuestas;
@Autowired
private ServicioForo servicioForo;
@GetMapping("/miperfil")
public String miPerfil(){
@ -21,7 +29,7 @@ public class Controlador {
}
@GetMapping({"","/home","/"})
public String indice(Model model){
model.addAttribute("listaRespuestas",servicioRespuestas.findAll());
model.addAttribute("listaForo",servicioForo.findAll());
return "index";
}
@GetMapping("/login")
@ -36,14 +44,17 @@ public class Controlador {
public String pregunta(){
return "Ask_Question/ask_question";
}
@GetMapping("/postdetall")
public String postDetall(Model model){
Respuestas[] respuestas = servicioRespuestas.findAll();
model.addAttribute("titulo", respuestas[0].getTitulos());
model.addAttribute("cuerpo", respuestas[0].getDescripcion());
Foro[] foro = servicioForo.findAll();
model.addAttribute("titulo", foro[0].getTitulo());
model.addAttribute("cuerpo", foro[0].getDescripcion());
return "Respuestas/post-detall";
}
@GetMapping("/all")
public @ResponseBody List<UsersEntity> getAllUsers(){
return iUsers.findAll();
}
}

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

@ -1,7 +1,6 @@
package com.cristobalbernal.foro.seguridad;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


+ 7
- 0
src/main/resources/application.properties View File

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

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

@ -45,14 +45,14 @@
<input id="tab5">
<section id="content1">
<!--Recent Question Content Section -->
<div class="question-type2033" th:each="respuesta : ${listaRespuestas}">
<div class="question-type2033" th:each="Foro: ${listaForo}">
<div class="row">
<div class="col-md-5">
<div class="right-description893">
<div id="que-hedder2983">
<h3><a href="/postdetall" target="_blank" th:text="${respuesta.titulos}">How Did You Hear About This Position?</a></h3> </div>
<h3><a href="/postdetall" target="_blank" th:text="${Foro.titulo}">How Did You Hear About This Position?</a></h3> </div>
<div class="ques-details10018">
<p th:text="${respuesta.descripcion}">Wouldn’t it be great if you knew exactly what questions a hiring manager would be asking you in your next job interview?
<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.
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>


Loading…
Cancel
Save