| @ -0,0 +1,41 @@ | |||||
| package es.fp.edu.conecta2; | |||||
| import org.springframework.core.env.Environment; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |||||
| import org.springframework.jdbc.datasource.DriverManagerDataSource; | |||||
| import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | |||||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | |||||
| import javax.sql.DataSource; | |||||
| @Configuration | |||||
| @EnableTransactionManagement | |||||
| @EnableJpaRepositories ( | |||||
| entityManagerFactoryRef = "userEntityManagerFactory", | |||||
| transactionManagerRef = "userTransactionManger", | |||||
| basePackages = {"es.fp.edu.conecta2.repo.user"}) | |||||
| public class BDConfig { | |||||
| @Autowired | |||||
| private Environment env; | |||||
| @Bean(name="userDataSource") | |||||
| public DataSource userDatasource() { | |||||
| DriverManagerDataSource dataSource = new DriverManagerDataSource(); | |||||
| dataSource.setUrl(env.getProperty("persistente.datasource.url")); | |||||
| dataSource.setUsername(env.getProperty("persistente.datasource.username")); | |||||
| dataSource.setPassword(env.getProperty("persistente.datasource.password")); | |||||
| dataSource.setDriverClassName(env.getProperty("persistente.datasource.driver-class-name")); | |||||
| return dataSource; | |||||
| } | |||||
| @Bean(name="userEntityManagerFactory") | |||||
| public LocalContainerEntityManagerFactoryBean entityManagerFactory(){ | |||||
| // TODO: 27/01/2023 | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,12 @@ | |||||
| package es.fp.edu.conecta2.controladores; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| @RestController | |||||
| public class Controlador01 { | |||||
| @GetMapping ("/") | |||||
| public String prueba() { | |||||
| return "Esto es una prueba"; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| package es.fp.edu.conecta2.modelo.admin; | |||||
| import jakarta.persistence.Column; | |||||
| import jakarta.persistence.Entity; | |||||
| import jakarta.persistence.Id; | |||||
| import jakarta.persistence.Table; | |||||
| @Entity | |||||
| @Table(name ="tbl_admin") | |||||
| public class Admin { | |||||
| public Integer getIdAdmin() { | |||||
| return idAdmin; | |||||
| } | |||||
| public void setIdAdmin(Integer idAdmin) { | |||||
| this.idAdmin = idAdmin; | |||||
| } | |||||
| public String getNombres() { | |||||
| return nombres; | |||||
| } | |||||
| public void setNombres(String nombres) { | |||||
| this.nombres = nombres; | |||||
| } | |||||
| @Id | |||||
| private Integer idAdmin; | |||||
| @Column(name="nombres") | |||||
| private String nombres; | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| package es.fp.edu.conecta2.modelo.user; | |||||
| import jakarta.persistence.Column; | |||||
| import jakarta.persistence.Entity; | |||||
| import jakarta.persistence.Id; | |||||
| import jakarta.persistence.Table; | |||||
| @Entity | |||||
| @Table(name="tbl_user") | |||||
| public class User { | |||||
| public Integer getIdUsuario() { | |||||
| return idUsuario; | |||||
| } | |||||
| public void setIdUsuario(Integer idUsuario) { | |||||
| this.idUsuario = idUsuario; | |||||
| } | |||||
| public String getNombres() { | |||||
| return nombres; | |||||
| } | |||||
| public void setNombres(String nombres) { | |||||
| this.nombres = nombres; | |||||
| } | |||||
| @Id | |||||
| private Integer idUsuario; | |||||
| @Column(name="nombres") | |||||
| private String nombres; | |||||
| } | |||||
| @ -0,0 +1,8 @@ | |||||
| package es.fp.edu.conecta2.repo.admin; | |||||
| import es.fp.edu.conecta2.modelo.admin.Admin; | |||||
| import org.springframework.data.jpa.repository.JpaRepository; | |||||
| public interface IAdminRepo extends JpaRepository <Admin, Integer> { | |||||
| } | |||||
| @ -0,0 +1,7 @@ | |||||
| package es.fp.edu.conecta2.repo.user; | |||||
| import es.fp.edu.conecta2.modelo.user.User; | |||||
| import org.springframework.data.jpa.repository.JpaRepository; | |||||
| public interface IUserRepo extends JpaRepository<User,Integer> { | |||||
| } | |||||