@ -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; | |||
} | |||
} |
@ -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; | |||
} | |||
} |
@ -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; | |||
} | |||
} |
@ -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; | |||
} | |||
} | |||
@ -0,0 +1,4 @@ | |||
package com.cristobalbernal.foro.Respositorios; | |||
public interface ICategoriaForo { | |||
} |
@ -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> { | |||
} |
@ -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> { | |||
} |
@ -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> { | |||
} |
@ -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); | |||
} | |||
} |
@ -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"); | |||
*/ | |||
} | |||
} |
@ -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 |