Skip to content

Commit

Permalink
[SELC-5621] feat: add field categoryCode in getInstitutionById API (#490
Browse files Browse the repository at this point in the history
)
  • Loading branch information
giulia-tremolada authored Oct 10, 2024
1 parent 002cd82 commit 0de770a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,11 @@
},
"category" : {
"type" : "string",
"description" : "Institution's category"
"description" : "Institution's category description"
},
"categoryCode" : {
"type" : "string",
"description" : "Institution's category code"
},
"city" : {
"type" : "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.pagopa.selfcare.dashboard.web.model;

import io.swagger.annotations.ApiModelProperty;
import it.pagopa.selfcare.onboarding.common.InstitutionType;
import lombok.Data;

import java.util.List;
Expand Down Expand Up @@ -30,6 +29,9 @@ public class InstitutionResource {
@ApiModelProperty(value = "${swagger.dashboard.institutions.model.category}")
private String category;

@ApiModelProperty(value = "${swagger.dashboard.institutions.model.categoryCode}")
private String categoryCode;

@ApiModelProperty(value = "${swagger.dashboard.institutions.model.fiscalCode}")
private String fiscalCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public interface InstitutionResourceMapper {
@Mapping(target = "products", source = "onboarding")
@Mapping(target = "parentDescription", source = "rootParent.description")
@Mapping(target = "category", expression = "java(retrieveCategory(model.getAttributes()))")
@Mapping(target = "categoryCode", expression = "java(retrieveCategoryCode(model.getAttributes()))")
InstitutionResource toResource(Institution model);

UpdateInstitutionResource toUpdateResource(UpdateInstitutionDto dto);
Expand All @@ -55,6 +56,14 @@ default String retrieveCategory(List<Attribute> attributes){
return null;
}

@Named("retrieveCategoryCode")
default String retrieveCategoryCode(List<Attribute> attributes){
if(!CollectionUtils.isEmpty(attributes)){
return attributes.get(0).getCode();
}
return null;
}

@Named("toUserRole")
default String toUserRole(String institutionId, RelationshipState status) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Expand Down
3 changes: 2 additions & 1 deletion web/src/main/resources/swagger/swagger_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ swagger.dashboard.institutions.model.institutionType=Institution's type
swagger.dashboard.institutions.model.logo=Institution's logo
swagger.dashboard.institutions.model.imageUrl=Institution's depict image
swagger.dashboard.institutions.model.name=Institution's name
swagger.dashboard.institutions.model.category=Institution's category
swagger.dashboard.institutions.model.category=Institution's category description
swagger.dashboard.institutions.model.categoryCode=Institution's category code
swagger.dashboard.institutions.model.fiscalCode=Fiscal code corresponding to the institution
swagger.dashboard.institutions.model.mailAddress=Institution's email address
swagger.dashboard.institutions.model.status=Institution's status
Expand Down
1 change: 1 addition & 0 deletions web/src/test/resources/json/InstitutionResource.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"institutionType": "SCP",
"name": "A description",
"category": "description1",
"categoryCode": "code1",
"fiscalCode": "tax123",
"mailAddress": "[email protected]",
"address": "123 Street",
Expand Down

0 comments on commit 0de770a

Please sign in to comment.