-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(be:FSADT1-500): adding some other apis
- adding first nation band validation - adding client doing business list it still requires some code to be extracted from here and backend and moved to an external library, but it will be dealt with in the future
- Loading branch information
Paulo Gomes da Cruz Junior
committed
Jan 12, 2023
1 parent
90fb838
commit ed6dbac
Showing
9 changed files
with
462 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
28 changes: 28 additions & 0 deletions
28
legacy/src/main/java/ca/bc/gov/app/dto/OrgBookNameDto.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 ca.bc.gov.app.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(name = "NamedResult") | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record OrgBookNameDto( | ||
@Schema( | ||
name = "value", | ||
title = "Name of the entity being searched", | ||
example = "U3 POWER CORP", | ||
requiredMode = Schema.RequiredMode.REQUIRED | ||
) | ||
String value, | ||
|
||
@Schema( | ||
name = "topic_source_id", | ||
title = "The incorporation ID", | ||
example = "BC0772006", | ||
requiredMode = Schema.RequiredMode.REQUIRED | ||
) | ||
@JsonProperty("topic_source_id") | ||
String topicSourceId | ||
) { | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
legacy/src/main/java/ca/bc/gov/app/dto/OrgBookResultListResponse.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,18 @@ | ||
package ca.bc.gov.app.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
|
||
@Schema(name = "NameListResponse", description = "A list of name results") | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record OrgBookResultListResponse( | ||
@Schema(description = "The total amount of entries on all pages", example = "75") | ||
int total, | ||
@Schema(description = "The zero-index current page number", example = "3") | ||
Integer page, | ||
|
||
@Schema(description = "The list of named results") | ||
List<OrgBookNameDto> results | ||
) { | ||
} |
49 changes: 49 additions & 0 deletions
49
legacy/src/main/java/ca/bc/gov/app/entity/ClientStatusCodeEntity.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,49 @@ | ||
package ca.bc.gov.app.entity; | ||
|
||
import ca.bc.gov.app.ApplicationConstants; | ||
import java.time.LocalDate; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.relational.core.mapping.Column; | ||
import org.springframework.data.relational.core.mapping.Table; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Data | ||
@Builder | ||
@With | ||
@Table(name = "CLIENT_STATUS_CODE", schema = ApplicationConstants.ORACLE_ATTRIBUTE_SCHEMA) | ||
public class ClientStatusCodeEntity { | ||
|
||
public static final String ACTIVE = "ACT"; //TODO: move to enum | ||
|
||
@Id | ||
@Column("CLIENT_STATUS_CODE") | ||
private String clientStatusCode; | ||
|
||
@Column("DESCRIPTION") | ||
private String description; | ||
|
||
@Column("EFFECTIVE_DATE") | ||
private LocalDate effectiveDate; | ||
|
||
@Column("EXPIRY_DATE") | ||
private LocalDate expiryDate; | ||
|
||
@Column("CREATE_TIMESTAMP") | ||
private LocalDate createTimestamp; | ||
|
||
@Column("UPDATE_TIMESTAMP") | ||
private LocalDate updateTimestamp; | ||
|
||
@Column("CREATE_USER") | ||
private String createUser; | ||
|
||
@Column("UPDATE_USER") | ||
private String updateUser; | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
legacy/src/main/java/ca/bc/gov/app/handlers/ForestClientBandsHandler.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,63 @@ | ||
package ca.bc.gov.app.handlers; | ||
|
||
import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; | ||
import static org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder; | ||
import static org.springdoc.core.fn.builders.content.Builder.contentBuilder; | ||
import static org.springdoc.core.fn.builders.schema.Builder.schemaBuilder; | ||
|
||
import ca.bc.gov.app.dto.FirstNationBandVidationDto; | ||
import ca.bc.gov.app.service.ForestClientService; | ||
import ca.bc.gov.app.util.HandlerUtil; | ||
import java.util.function.Consumer; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springdoc.core.fn.builders.operation.Builder; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.server.ServerRequest; | ||
import org.springframework.web.reactive.function.server.ServerResponse; | ||
import org.springframework.web.server.ResponseStatusException; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ForestClientBandsHandler implements BaseHandler { | ||
|
||
private final ForestClientService service; | ||
|
||
@Override | ||
public Mono<ServerResponse> handle(ServerRequest serverRequest) { | ||
return ServerResponse | ||
.ok() | ||
.body(service.getFirstNationBandInfo(), FirstNationBandVidationDto.class) | ||
.doOnError(ResponseStatusException.class, HandlerUtil.handleStatusResponse()) | ||
.doOnError(HandlerUtil.handleError()); | ||
} | ||
|
||
@Override | ||
public Consumer<Builder> documentation(String tag) { | ||
return ops -> ops.tag(tag) | ||
.description("List First nation band validation information") | ||
.beanClass(ForestClientBandsHandler.class) | ||
.beanMethod("handle") | ||
.operationId("handle") | ||
.response( | ||
responseBuilder() | ||
.responseCode("200") | ||
.description("Found") | ||
.content( | ||
contentBuilder() | ||
.array( | ||
arraySchemaBuilder() | ||
.schema( | ||
schemaBuilder() | ||
.name("FirstNationBand") | ||
.implementation(FirstNationBandVidationDto.class) | ||
) | ||
) | ||
.mediaType(MediaType.APPLICATION_JSON_VALUE) | ||
) | ||
); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
legacy/src/main/java/ca/bc/gov/app/handlers/ForestClientBusinessHandler.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,68 @@ | ||
package ca.bc.gov.app.handlers; | ||
|
||
import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; | ||
import static org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder; | ||
import static org.springdoc.core.fn.builders.content.Builder.contentBuilder; | ||
import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; | ||
import static org.springdoc.core.fn.builders.schema.Builder.schemaBuilder; | ||
|
||
import ca.bc.gov.app.ApplicationConstants; | ||
import ca.bc.gov.app.dto.ClientPublicViewDto; | ||
import ca.bc.gov.app.dto.ForestClientDto; | ||
import ca.bc.gov.app.service.ForestClientService; | ||
import ca.bc.gov.app.util.HandlerUtil; | ||
import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||
import java.util.function.Consumer; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springdoc.core.fn.builders.operation.Builder; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.server.ServerRequest; | ||
import org.springframework.web.reactive.function.server.ServerResponse; | ||
import org.springframework.web.server.ResponseStatusException; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ForestClientBusinessHandler implements BaseHandler { | ||
|
||
private final ForestClientService service; | ||
|
||
@Override | ||
public Mono<ServerResponse> handle(ServerRequest serverRequest) { | ||
return ServerResponse | ||
.ok() | ||
.body(service.getClientDoingBusiness(), ClientPublicViewDto.class) | ||
.doOnError(ResponseStatusException.class, HandlerUtil.handleStatusResponse()) | ||
.doOnError(HandlerUtil.handleError()); | ||
} | ||
|
||
@Override | ||
public Consumer<Builder> documentation(String tag) { | ||
return ops -> ops.tag(tag) | ||
.description("List all clients we are doing business with") | ||
.beanClass(ForestClientBusinessHandler.class) | ||
.beanMethod("handle") | ||
.operationId("handle") | ||
.response( | ||
responseBuilder() | ||
.responseCode("200") | ||
.description("Found") | ||
.content( | ||
contentBuilder() | ||
.array( | ||
arraySchemaBuilder() | ||
.schema( | ||
schemaBuilder() | ||
.name("ClientInformation") | ||
.implementation(ClientPublicViewDto.class) | ||
) | ||
) | ||
.mediaType(MediaType.APPLICATION_JSON_VALUE) | ||
) | ||
); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.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,39 @@ | ||
package ca.bc.gov.app.repository; | ||
|
||
import ca.bc.gov.app.entity.ForestClientEntity; | ||
import java.time.LocalDate; | ||
import org.springframework.data.r2dbc.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.repository.reactive.ReactiveCrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Repository | ||
public interface ForestClientRepository extends ReactiveCrudRepository<ForestClientEntity, String> { | ||
|
||
@Query(""" | ||
select * from FOREST_CLIENT x | ||
where x.CLIENT_TYPE_CODE = 'B' | ||
and x.CLIENT_STATUS_CODE = 'ACT'""") | ||
Flux<ForestClientEntity> findAllFirstNationBandClients(); | ||
|
||
@Query(""" | ||
select * from FOREST_CLIENT x | ||
where (x.REGISTRY_COMPANY_TYPE_CODE || x.CORP_REGN_NMBR) = :incorporationNumber | ||
or x.CLIENT_NAME = :companyName""") | ||
Flux<ForestClientEntity> findClientByIncorporationOrName( | ||
@Param("incorporationNumber") String incorporationNumber, | ||
@Param("companyName") String companyName | ||
); | ||
|
||
@Query(""" | ||
select * from FOREST_CLIENT x | ||
where lower(x.LEGAL_FIRST_NAME) = lower(:firstName) | ||
and lower(x.CLIENT_NAME) = lower(:lastName) | ||
and x.BIRTHDATE = :birthdate""") | ||
Flux<ForestClientEntity> findClientByNameAndBirthdate( | ||
@Param("firstName") String firstName, | ||
@Param("lastName") String lastName, | ||
@Param("birthdate") LocalDate birthdate | ||
); | ||
} |
68 changes: 68 additions & 0 deletions
68
legacy/src/main/java/ca/bc/gov/app/routes/ForestClientRouter.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,68 @@ | ||
package ca.bc.gov.app.routes; | ||
|
||
import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; | ||
import static org.springframework.web.reactive.function.server.RequestPredicates.accept; | ||
import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; | ||
|
||
import ca.bc.gov.app.handlers.ForestClientBandsHandler; | ||
import ca.bc.gov.app.handlers.ForestClientBusinessHandler; | ||
import ca.bc.gov.app.handlers.ForestClientUnregisteredHandler; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.server.RouterFunction; | ||
import org.springframework.web.reactive.function.server.ServerResponse; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ForestClientRouter implements BaseRouter { | ||
|
||
private final ForestClientBusinessHandler businessHandler; | ||
private final ForestClientBandsHandler bandsHandler; | ||
|
||
private final ForestClientUnregisteredHandler unregisteredHandler; | ||
|
||
@Override | ||
public String basePath() { | ||
return "/client"; | ||
} | ||
|
||
@Override | ||
public String routeTagName() { | ||
return "Forest Client"; | ||
} | ||
|
||
@Override | ||
public String routeTagDescription() { | ||
return "Aggregation and other reports for forest clients"; | ||
} | ||
|
||
@Override | ||
public RouterFunction<ServerResponse> routerRoute() { | ||
return route() | ||
.GET( | ||
"/bands", | ||
accept(MediaType.ALL) | ||
.and(contentType(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON)), | ||
bandsHandler::handle, | ||
bandsHandler.documentation(routeTagName()) | ||
) | ||
.GET( | ||
"/business", | ||
accept(MediaType.ALL) | ||
.and(contentType(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON)), | ||
businessHandler::handle, | ||
businessHandler.documentation(routeTagName()) | ||
) | ||
.GET( | ||
"/unregistered", | ||
accept(MediaType.ALL) | ||
.and(contentType(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON)), | ||
unregisteredHandler::handle, | ||
unregisteredHandler.documentation(routeTagName()) | ||
) | ||
.build(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.