-
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: list contact type codes (#330)
* feat: list contact type codes * fix test * Updated code to use ClientNameCodeDto * fix: fixing action param name * ci: adding test on main branch this is to update the coverage info for main branch on each sonar project and use it as a base for branch comparison. * chore: renaming endpoint and swagger data * feat(fe:autocomplete): adding useFetch function (#331) * feat(fe:autocomplete): adding useFetch function * feat(fe:autocomplete): adding autocomplete component * feat(fe:autocomplete): adding component and fetch - added component FormAutoComplete - hardcoded fetch for required field (for now) - added fetch example on FormSections * fix: changing country endpoint name * chore: adding content type response * chore: changing response format to match format changed dto to use a simpler one. * fix: fixing small client configuration issue * chore: fixing swagger * chore: updating response to be uniform changing response to activeClientType endpoint to be the same dto used in other endpoints * chore: updating schema info --------- Co-authored-by: Paulo Gomes da Cruz Junior <[email protected]>
- Loading branch information
1 parent
831d507
commit 9d8fd2f
Showing
11 changed files
with
340 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,64 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
tests-backend: | ||
name: Backend Unit Tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
commands: | | ||
mvn -B verify -P all-tests checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml | ||
dir: backend | ||
java-cache: maven | ||
java-distribution: temurin | ||
java-version: "17" | ||
sonar_args: > | ||
-Dsonar.organization=bcgov-sonarcloud | ||
-Dsonar.projectKey=forest-client-backend | ||
sonar_project_token: ${{ secrets.SONAR_TOKEN_BACKEND }} | ||
|
||
tests-legacy: | ||
name: Legacy Unit Tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
commands: | | ||
mvn -B verify -P all-tests checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml | ||
dir: legacy | ||
java-cache: maven | ||
java-distribution: temurin | ||
java-version: "17" | ||
sonar_args: > | ||
-Dsonar.organization=bcgov-sonarcloud | ||
-Dsonar.projectKey=forest-client-legacy | ||
sonar_project_token: ${{ secrets.SONAR_TOKEN_LEGACY }} | ||
|
||
tests-frontend: | ||
name: Frontend Unit Tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
commands: | | ||
npm ci | ||
npm run test | ||
dir: frontend | ||
sonar_args: > | ||
-Dsonar.exclusions=**/coverage/**,**/examples/**,**/pages/** | ||
-Dsonar.organization=bcgov-sonarcloud | ||
-Dsonar.projectKey=forest-client-frontend | ||
-Dsonar.tests=src/tests | ||
sonar_project_token: ${{ secrets.SONAR_TOKEN_FRONTEND }} | ||
|
||
codeql: | ||
name: Semantic Code Analysis | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- tests-backend | ||
- tests-legacy | ||
- tests-frontend | ||
permissions: | ||
actions: read | ||
contents: read | ||
|
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
20 changes: 19 additions & 1 deletion
20
backend/src/main/java/ca/bc/gov/app/dto/client/ClientNameCodeDto.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,4 +1,22 @@ | ||
package ca.bc.gov.app.dto.client; | ||
|
||
public record ClientNameCodeDto(String code, String name) { | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema( | ||
description = "A simple name and code object", | ||
title = "NameCode", | ||
example = """ | ||
{ | ||
"code": "00000002", | ||
"name": "BAXTER" | ||
}""" | ||
) | ||
public record ClientNameCodeDto( | ||
|
||
@Schema(description = "The code for that specific object", example = "00000002") | ||
String code, | ||
|
||
@Schema(description = "The name information for that specific object", example = "BAXTER") | ||
String name | ||
) { | ||
} |
50 changes: 50 additions & 0 deletions
50
backend/src/main/java/ca/bc/gov/app/entity/client/ContactTypeCodeEntity.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,50 @@ | ||
package ca.bc.gov.app.entity.client; | ||
|
||
import ca.bc.gov.app.ApplicationConstant; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
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; | ||
|
||
@Table(name = "contact_type_code", schema = ApplicationConstant.POSTGRES_ATTRIBUTE_SCHEMA) | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@With | ||
public class ContactTypeCodeEntity { | ||
@Id | ||
@Column("contact_type_code") | ||
private String contactTypeCode; | ||
|
||
@NotNull | ||
@Column("description") | ||
private String description; | ||
|
||
@NotNull | ||
@Column("effective_date") | ||
private LocalDate effectiveAt; | ||
|
||
@NotNull | ||
@Column("expiry_date") | ||
private LocalDate expiredAt; | ||
|
||
@Column("create_timestamp") | ||
private LocalDateTime createdAt; | ||
|
||
@Column("update_timestamp") | ||
private LocalDateTime updatedAt; | ||
|
||
@Column("create_user") | ||
private String createdBy; | ||
|
||
@Column("update_user") | ||
private String updatedBy; | ||
} |
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
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
105 changes: 105 additions & 0 deletions
105
backend/src/main/java/ca/bc/gov/app/handlers/client/ContactTypeCodeHandler.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,105 @@ | ||
package ca.bc.gov.app.handlers.client; | ||
|
||
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.requestbody.Builder.requestBodyBuilder; | ||
import static org.springdoc.core.fn.builders.schema.Builder.schemaBuilder; | ||
|
||
import ca.bc.gov.app.dto.client.ClientNameCodeDto; | ||
import ca.bc.gov.app.handlers.BaseHandler; | ||
import ca.bc.gov.app.service.client.ClientService; | ||
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 | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class ContactTypeCodeHandler implements BaseHandler { | ||
|
||
private final ClientService clientService; | ||
|
||
|
||
@Override | ||
public Mono<ServerResponse> handle(ServerRequest serverRequest) { | ||
return | ||
ServerResponse | ||
.ok() | ||
.body( | ||
clientService | ||
.listClientContactTypeCodes( | ||
serverRequest | ||
.queryParam("page") | ||
.map(Integer::parseInt) | ||
.orElse(0), | ||
serverRequest | ||
.queryParam("size") | ||
.map(Integer::parseInt) | ||
.orElse(5) | ||
), | ||
ContactTypeCodeHandler.class | ||
) | ||
.doOnError(ResponseStatusException.class, HandlerUtil.handleStatusResponse()) | ||
.doOnError(HandlerUtil.handleError()); | ||
} | ||
|
||
@Override | ||
public Consumer<Builder> documentation(String tag) { | ||
return ops -> ops | ||
.tag(tag) | ||
.description("List contact type codes") | ||
.beanClass(ContactTypeCodeHandler.class) | ||
.beanMethod("handle") | ||
.operationId("handle") | ||
.requestBody(requestBodyBuilder()) | ||
.parameter( | ||
parameterBuilder() | ||
.in(ParameterIn.QUERY) | ||
.name("page") | ||
.description(""" | ||
0 index page number, for example: | ||
0 for the first page, 4 for the fifth page. | ||
Defaults to 0 (first page)""") | ||
.allowEmptyValue(true) | ||
.schema(schemaBuilder().implementation(String.class)) | ||
.example("4") | ||
) | ||
.parameter( | ||
parameterBuilder() | ||
.in(ParameterIn.QUERY) | ||
.name("size") | ||
.description("Amount of entries per page,default to 5") | ||
.allowEmptyValue(true) | ||
.schema(schemaBuilder().implementation(String.class)) | ||
.example("5") | ||
) | ||
.response( | ||
responseBuilder() | ||
.responseCode("200") | ||
.description("OK - List a page of contact type codes") | ||
.content( | ||
contentBuilder() | ||
.array( | ||
arraySchemaBuilder() | ||
.schema( | ||
schemaBuilder() | ||
.name("NameCode") | ||
.implementation(ClientNameCodeDto.class) | ||
) | ||
) | ||
.mediaType(MediaType.APPLICATION_JSON_VALUE) | ||
) | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/ca/bc/gov/app/repository/client/ContactTypeCodeRepository.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,16 @@ | ||
package ca.bc.gov.app.repository.client; | ||
|
||
import ca.bc.gov.app.entity.client.ContactTypeCodeEntity; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.repository.reactive.ReactiveCrudRepository; | ||
import org.springframework.data.repository.reactive.ReactiveSortingRepository; | ||
import org.springframework.stereotype.Repository; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Repository | ||
public interface ContactTypeCodeRepository | ||
extends ReactiveCrudRepository<ContactTypeCodeEntity, String>, | ||
ReactiveSortingRepository<ContactTypeCodeEntity, String> { | ||
|
||
Flux<ContactTypeCodeEntity> findBy(Pageable pageable); | ||
} |
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.