ddangelorb
3 years ago
20 changed files with 608 additions and 117 deletions
-
29db/ddl.sql
-
5src/main/java/org/waterproofingdata/wpdauth/WpdauthApplication.java
-
32src/main/java/org/waterproofingdata/wpdauth/controller/ForgotPasswordsController.java
-
13src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java
-
135src/main/java/org/waterproofingdata/wpdauth/dto/UsersRequestDTO.java
-
167src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java
-
3src/main/java/org/waterproofingdata/wpdauth/model/EduCemadenOrganizations.java
-
2src/main/java/org/waterproofingdata/wpdauth/model/ForgotPasswordsKeys.java
-
41src/main/java/org/waterproofingdata/wpdauth/model/Users.java
-
33src/main/java/org/waterproofingdata/wpdauth/model/UsersEducemadenOrganizations.java
-
7src/main/java/org/waterproofingdata/wpdauth/model/UsersProviderActivationKey.java
-
2src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java
-
4src/main/java/org/waterproofingdata/wpdauth/repository/ForgotPasswordsKeysRepository.java
-
13src/main/java/org/waterproofingdata/wpdauth/repository/UsersEducemadenOrganizationsRepository.java
-
10src/main/java/org/waterproofingdata/wpdauth/repository/UsersProviderActivationKeyRepository.java
-
5src/main/java/org/waterproofingdata/wpdauth/repository/UsersRepository.java
-
10src/main/java/org/waterproofingdata/wpdauth/repository/UsersRolesproviderActivationKeyRepository.java
-
39src/main/java/org/waterproofingdata/wpdauth/service/ForgotPasswordsService.java
-
159src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java
-
6src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java
@ -1,30 +1,177 @@ |
|||
package org.waterproofingdata.wpdauth.dto; |
|||
|
|||
import java.util.List; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import java.sql.Date; |
|||
|
|||
import org.waterproofingdata.wpdauth.model.EduCemadenOrganizations; |
|||
import org.waterproofingdata.wpdauth.model.Roles; |
|||
import org.waterproofingdata.wpdauth.model.UsersRolesproviderActivationKey; |
|||
import org.waterproofingdata.wpdauth.model.UsersProviderActivationKey; |
|||
|
|||
@Getter |
|||
@Setter |
|||
public class UsersResponseDTO { |
|||
@ApiModelProperty(position = 0) |
|||
@ApiModelProperty( |
|||
position = 0, |
|||
name = "id", |
|||
dataType = "Integer", |
|||
value = "id of the user.", |
|||
example = "This is a SERIAL and Primary Key field.", |
|||
required = true |
|||
) |
|||
private Integer id; |
|||
|
|||
@ApiModelProperty(position = 1) |
|||
@ApiModelProperty( |
|||
position = 1, |
|||
name = "username", |
|||
dataType = "String", |
|||
value = "username of the user.", |
|||
example = "This is an unique field, and consumers should be aware of it. By convention, WP6 should send the user phone number (i.e. (99)99999-9999).", |
|||
required = true |
|||
) |
|||
private String username; |
|||
|
|||
@ApiModelProperty(position = 2) |
|||
List<Roles> roles; |
|||
@ApiModelProperty( |
|||
position = 2, |
|||
name = "nickname", |
|||
dataType = "String", |
|||
value = "nickname of the user.", |
|||
example = "i.e. beth2021. This is an unique field, and consumers should be aware of it.", |
|||
required = true |
|||
) |
|||
private String nickname; |
|||
|
|||
@ApiModelProperty( |
|||
position = 3, |
|||
name = "dateofborn", |
|||
dataType = "String", |
|||
value = "Date of Born of the user.", |
|||
example = "i.e. 01/12/1978. Format should be dd/MM/yyyy.", |
|||
required = false |
|||
) |
|||
private Date dateofborn; |
|||
|
|||
@ApiModelProperty( |
|||
position = 4, |
|||
name = "gender", |
|||
dataType = "String", |
|||
value = "Gender of the user.", |
|||
example = "i.e. M. 'M' stands for Male, 'F' Female, 'N' Not Informed", |
|||
allowableValues = "{@code M, F, N}", |
|||
required = false |
|||
) |
|||
private String gender; |
|||
|
|||
@ApiModelProperty( |
|||
position = 5, |
|||
name = "state", |
|||
dataType = "String", |
|||
value = "state of the user.", |
|||
example = "i.e. SP. State should be 2 characteres (UF)", |
|||
required = true |
|||
) |
|||
private String state; |
|||
|
|||
@ApiModelProperty( |
|||
position = 6, |
|||
name = "city", |
|||
dataType = "String", |
|||
value = "city of the user.", |
|||
example = "i.e. 'Governador Valadares'.", |
|||
required = true |
|||
) |
|||
private String city; |
|||
|
|||
@ApiModelProperty( |
|||
position = 7, |
|||
name = "institutiontype", |
|||
dataType = "String", |
|||
value = "institution type of the user.", |
|||
example = "i.e. 'E'. E stands for 'School', D 'Civil Defense', N 'No governamental', O 'others'", |
|||
allowableValues = "{@code E, D, N, O}", |
|||
required = false |
|||
) |
|||
private String institutiontype; |
|||
|
|||
@ApiModelProperty( |
|||
position = 8, |
|||
name = "institution", |
|||
dataType = "String", |
|||
value = "institution of the user.", |
|||
example = "i.e. 'Colegio Imaginario'.", |
|||
required = false |
|||
) |
|||
private String institution; |
|||
|
|||
@ApiModelProperty( |
|||
position = 9, |
|||
name = "securityquestion", |
|||
dataType = "String", |
|||
value = "security question of the user.", |
|||
example = "i.e. 'What is my favorite color?'.", |
|||
required = false |
|||
) |
|||
private String securityquestion; |
|||
|
|||
@ApiModelProperty( |
|||
position = 10, |
|||
name = "securityanswer", |
|||
dataType = "String", |
|||
value = "security answer of the user.", |
|||
example = "i.e. 'Blue'.", |
|||
required = false |
|||
) |
|||
private String securityanswer; |
|||
|
|||
@ApiModelProperty( |
|||
position = 11, |
|||
name = "termsofusage", |
|||
dataType = "String", |
|||
value = "terms of usage of the user.", |
|||
example = "i.e. true.", |
|||
required = true |
|||
) |
|||
private boolean termsofusage; |
|||
|
|||
@ApiModelProperty( |
|||
position = 12, |
|||
name = "active", |
|||
dataType = "Integer", |
|||
value = "whether user is active or not.", |
|||
example = "i.e. true.", |
|||
required = true |
|||
) |
|||
private Integer active; |
|||
|
|||
|
|||
@ApiModelProperty( |
|||
position = 13, |
|||
name = "institutiontype", |
|||
dataType = "String", |
|||
value = "institution type of the user.", |
|||
example = "i.e. 'ROLE_ADMIN' means system administrator, 'ROLE_INSTITUTION' means institution administrator, 'ROLE_CLIENT' means regular users", |
|||
allowableValues = "{@code ROLE_ADMIN, ROLE_INSTITUTION, ROLE_CLIENT}", |
|||
required = false |
|||
) |
|||
Roles role; |
|||
|
|||
@ApiModelProperty(position = 3) |
|||
@ApiModelProperty( |
|||
position = 14, |
|||
name = "eduCemadenOrganization", |
|||
dataType = "EduCemadenOrganizations", |
|||
value = "which Educational Cemaden Organization the user belongs.", |
|||
required = false |
|||
) |
|||
EduCemadenOrganizations eduCemadenOrganization; |
|||
|
|||
@ApiModelProperty(position = 4) |
|||
List<UsersRolesproviderActivationKey> rolesProviderActivationKeys; |
|||
@ApiModelProperty( |
|||
position = 15, |
|||
name = "providerActivationKey", |
|||
dataType = "UsersProviderActivationKey", |
|||
value = "If this user can provide an activation key for other users ('ROLE_INSTITUTION'), this field will store the values.", |
|||
required = false |
|||
) |
|||
UsersProviderActivationKey providerActivationKey; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package org.waterproofingdata.wpdauth.model; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
@Entity(name = "users_educemaden_organizations") |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class UsersEducemadenOrganizations { |
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.IDENTITY) |
|||
private Integer id; |
|||
|
|||
@Column(nullable = false, name="users_id") |
|||
private Integer usersid; |
|||
|
|||
@Column(nullable = false, name="educemaden_organizations_id") |
|||
private Integer educemadenorganizationsid; |
|||
|
|||
@Column(nullable = false) |
|||
private String activationkey; |
|||
|
|||
@Column(nullable = false) |
|||
private Integer active; |
|||
} |
@ -0,0 +1,13 @@ |
|||
package org.waterproofingdata.wpdauth.repository; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
import org.waterproofingdata.wpdauth.model.UsersEducemadenOrganizations; |
|||
|
|||
public interface UsersEducemadenOrganizationsRepository extends JpaRepository<UsersEducemadenOrganizations, Integer> { |
|||
|
|||
UsersEducemadenOrganizations findByActivationkey(String activationkey); |
|||
|
|||
@Query(value = "SELECT * FROM auth.users_educemaden_organizations WHERE users_id = ?1 AND active = 1", nativeQuery = true) |
|||
UsersEducemadenOrganizations findByUserIdAndActivated(Integer userid); |
|||
} |
@ -0,0 +1,10 @@ |
|||
package org.waterproofingdata.wpdauth.repository; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.waterproofingdata.wpdauth.model.UsersProviderActivationKey; |
|||
|
|||
public interface UsersProviderActivationKeyRepository extends JpaRepository<UsersProviderActivationKey, Integer> { |
|||
UsersProviderActivationKey findByActivationkey(String activationkey); |
|||
|
|||
UsersProviderActivationKey findByUsersid(Integer usersid); |
|||
} |
@ -1,10 +0,0 @@ |
|||
package org.waterproofingdata.wpdauth.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.waterproofingdata.wpdauth.model.UsersRolesproviderActivationKey; |
|||
|
|||
public interface UsersRolesproviderActivationKeyRepository extends JpaRepository<UsersRolesproviderActivationKey, Integer> { |
|||
List<UsersRolesproviderActivationKey> findByUsersid(Integer usersid); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue