diff --git a/src/main/java/org/waterproofingdata/wpdauth/model/EduCemadenOrganizations.java b/src/main/java/org/waterproofingdata/wpdauth/model/EduCemadenOrganizations.java new file mode 100644 index 0000000..90e4f40 --- /dev/null +++ b/src/main/java/org/waterproofingdata/wpdauth/model/EduCemadenOrganizations.java @@ -0,0 +1,48 @@ +package org.waterproofingdata.wpdauth.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Entity(name = "educemaden_organizations") +@Getter +@Setter +@NoArgsConstructor +public class EduCemadenOrganizations { + @Id + private Integer id; + + @Column(nullable = true) + private String active; + + @Column(nullable = false) + private String name; + + @Column(nullable = true) + private String creation_date; + + @Column(nullable = true) + private String inep_code; + + @Column(unique = true, nullable = false) + private String phone; + + @Column(nullable = true) + private String type; + + @Column(nullable = true) + private String website; + + @Column(nullable = true) + private String login; + + @Column(nullable = true) + private String address; + + @Column(nullable = true) + private String responsible; +} diff --git a/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java b/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java new file mode 100644 index 0000000..3100e34 --- /dev/null +++ b/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java @@ -0,0 +1,8 @@ +package org.waterproofingdata.wpdauth.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.waterproofingdata.wpdauth.model.EduCemadenOrganizations; + +public interface EduCemadenOrganizationsRepository extends JpaRepository { + EduCemadenOrganizations findByPhone(String phone); +} diff --git a/src/main/java/org/waterproofingdata/wpdauth/repository/UsersRepository.java b/src/main/java/org/waterproofingdata/wpdauth/repository/UsersRepository.java index a735179..9aa98c8 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/repository/UsersRepository.java +++ b/src/main/java/org/waterproofingdata/wpdauth/repository/UsersRepository.java @@ -1,8 +1,10 @@ package org.waterproofingdata.wpdauth.repository; -import org.waterproofingdata.wpdauth.model.Users; import javax.transaction.Transactional; + import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.waterproofingdata.wpdauth.model.Users; public interface UsersRepository extends JpaRepository { @@ -10,8 +12,15 @@ public interface UsersRepository extends JpaRepository { Users findByUsername(String username); - //@Transactional - //void activateByUsername(String username, String activationkey); - //PostGreSQL -> SELECT uuid_generate_v4(); + @Transactional + @Query(value = "UPDATE users SET active = ?2 WHERE username = ?1", nativeQuery = true) + void activateByUsername(String username, Integer active); + + @Transactional + @Query(value = "INSERT INTO users_rolesprovider_activationkey(users_id, roles_id, activationkey) VALUES VALUES (?1, ?2, ?3);", nativeQuery = true) + void insertUsersRolesProvider(Integer idUser, Integer idRoles, String activationkey); + @Transactional + @Query(value = "INSERT INTO users_educemaden_organizations(users_id, educemaden_organizations_id, activationkey) VALUES (?1, ?2, ?3);", nativeQuery = true) + void insertUsersEduCemadenOrganizations(Integer idUser, Integer idEduCemadenOrganizations, String activationkey); }