-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#237 | Implement the Admin User Registration Application List Endpoint (
#260)
- Loading branch information
1 parent
75eb266
commit 92c6694
Showing
12 changed files
with
567 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...in/java/com/ays/admin_user/model/dto/request/AdminUserRegisterApplicationListRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.ays.admin_user.model.dto.request; | ||
|
||
import com.ays.admin_user.model.enums.AdminUserRegisterApplicationStatus; | ||
import com.ays.common.model.AysFiltering; | ||
import com.ays.common.model.dto.request.AysFilteringRequest; | ||
import com.ays.common.model.dto.request.AysPagingRequest; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.AssertTrue; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Represents a request object for fetching a list of admin user registration applications with pagination,sorting | ||
* and filtering options. This class extends the {@link AysPagingRequest} class and adds additional validation rules for sorting. | ||
*/ | ||
@Getter | ||
@Setter | ||
public class AdminUserRegisterApplicationListRequest extends AysPagingRequest implements AysFilteringRequest { | ||
|
||
@Valid | ||
private Filter filter; | ||
|
||
/** | ||
* Represents a filtering configuration for admin user registration applications based on the class fields. | ||
*/ | ||
@Getter | ||
@Setter | ||
public static class Filter implements AysFiltering { | ||
|
||
|
||
/** | ||
* List of admin user registration application's statuses used for filtering. | ||
*/ | ||
private List<AdminUserRegisterApplicationStatus> statuses; | ||
|
||
} | ||
|
||
/** | ||
* Overrides the {@link AysPagingRequest#isSortPropertyAccepted()} method to validate sorting options | ||
* and ensures that no unsupported sorting property is used in the request. | ||
* | ||
* @return true if the sorting property is accepted, false otherwise. | ||
*/ | ||
@JsonIgnore | ||
@AssertTrue | ||
@Override | ||
public boolean isSortPropertyAccepted() { | ||
final Set<String> acceptedFilterFields = Set.of("createdAt"); | ||
return this.isPropertyAccepted(acceptedFilterFields); | ||
} | ||
|
||
/** | ||
* Converts the request into a JPA Specification that filters registration applications based on the specified | ||
* statuses, if they are provided. | ||
* | ||
* @param clazz the class type of the specification. | ||
* @return the generated JPA Specification based on the request filters. | ||
*/ | ||
@Override | ||
public <C> Specification<C> toSpecification(Class<C> clazz) { | ||
|
||
if (this.filter == null) { | ||
return Specification.allOf(); | ||
} | ||
|
||
Specification<C> specification = Specification.where(null); | ||
|
||
if (!CollectionUtils.isEmpty(this.filter.getStatuses())) { | ||
Specification<C> statusSpecification = this.filter.statuses.stream().map(status -> | ||
(Specification<C>) (root, query, criteriaBuilder) -> | ||
criteriaBuilder.equal(root.get("status"), status)) | ||
.reduce(Specification::or).orElse(null); | ||
|
||
specification = specification.and(statusSpecification); | ||
} | ||
|
||
return specification; | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ain/java/com/ays/admin_user/model/dto/response/AdminUserRegisterApplicationsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.ays.admin_user.model.dto.response; | ||
|
||
import com.ays.admin_user.model.enums.AdminUserRegisterApplicationStatus; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* A DTO (Data Transfer Object) representing a list of admin user register applications in a paginated response. | ||
*/ | ||
@Getter | ||
@Setter | ||
public class AdminUserRegisterApplicationsResponse { | ||
|
||
private String id; | ||
private String reason; | ||
private AdminUserRegisterApplicationStatus status; | ||
private Institution institution; | ||
private AdminUser adminUser; | ||
private String createdUser; | ||
private LocalDateTime createdAt; | ||
|
||
|
||
/** | ||
* A DTO (Data Transfer Object) representing an admin users in an admin user register application of paginated response. | ||
*/ | ||
@Getter | ||
@Setter | ||
public static class AdminUser { | ||
private String id; | ||
private String firstName; | ||
private String lastName; | ||
} | ||
|
||
/** | ||
* A DTO (Data Transfer Object) representing an institution in an admin user register application of paginated response. | ||
*/ | ||
@Getter | ||
@Setter | ||
public static class Institution { | ||
private String id; | ||
private String name; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...del/mapper/AdminUserRegisterApplicationToAdminUserRegisterApplicationsResponseMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.ays.admin_user.model.mapper; | ||
|
||
import com.ays.admin_user.model.AdminUserRegisterApplication; | ||
import com.ays.admin_user.model.dto.response.AdminUserRegisterApplicationsResponse; | ||
import com.ays.common.model.mapper.BaseMapper; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
|
||
/** | ||
* AdminUserRegisterApplicationToAdminUserRegisterApplicationsResponse is an interface that defines the mapping between an {@link AdminUserRegisterApplication} and an {@link AdminUserRegisterApplicationsResponse}. | ||
* This interface uses the MapStruct annotation @Mapper to generate an implementation of this interface at compile-time. | ||
* <p>The class provides a static method {@code initialize()} that returns an instance of the generated mapper implementation. | ||
* <p>The interface extends the MapStruct interface {@link BaseMapper}, which defines basic mapping methods. | ||
* The interface adds no additional mapping methods, but simply defines the types to be used in the mapping process. | ||
*/ | ||
@Mapper | ||
public interface AdminUserRegisterApplicationToAdminUserRegisterApplicationsResponseMapper extends BaseMapper<AdminUserRegisterApplication, AdminUserRegisterApplicationsResponse> { | ||
|
||
/** | ||
* Initializes the mapper. | ||
* | ||
* @return the initialized mapper object. | ||
*/ | ||
static AdminUserRegisterApplicationToAdminUserRegisterApplicationsResponseMapper initialize() { | ||
return Mappers.getMapper(AdminUserRegisterApplicationToAdminUserRegisterApplicationsResponseMapper.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/ays/admin_user/service/AdminUserRegisterApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
package com.ays.admin_user.service; | ||
|
||
import com.ays.admin_user.model.AdminUserRegisterApplication; | ||
import com.ays.admin_user.model.dto.request.AdminUserRegisterApplicationListRequest; | ||
import com.ays.common.model.AysPage; | ||
|
||
/** | ||
* Admin Users Verification application service, which holds the verification information regarding the system user. | ||
*/ | ||
public interface AdminUserRegisterApplicationService { | ||
|
||
/** | ||
* Get registration applications based on the specified filters in the {@link AdminUserRegisterApplicationListRequest} | ||
* | ||
* @param listRequest covering page and pageSize | ||
* @return Admin User Registration Application list | ||
*/ | ||
AysPage<AdminUserRegisterApplication> getRegistrationApplications(AdminUserRegisterApplicationListRequest listRequest); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.