Contractor country (#33)

This commit is contained in:
Kostya 2021-05-18 14:02:18 +03:00 committed by GitHub
parent 7ab771c883
commit d5c88c8ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 4 deletions

View File

@ -6,7 +6,7 @@
<parent>
<groupId>com.rbkmoney</groupId>
<artifactId>service-parent-pom</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
</parent>
<artifactId>claim-management</artifactId>

View File

@ -1,8 +1,8 @@
package com.rbkmoney.cm.converter;
import com.rbkmoney.cm.model.InternationalBankDetailsModel;
import com.rbkmoney.damsel.domain.CountryCode;
import com.rbkmoney.damsel.domain.InternationalBankDetails;
import com.rbkmoney.damsel.domain.Residence;
import org.springframework.stereotype.Component;
import java.util.Optional;
@ -20,7 +20,7 @@ public class InternationalBankDetailsModelToInternationalBankDetailsConverter
.setName(internationalBankDetailsModel.getName())
.setCountry(
Optional.ofNullable(internationalBankDetailsModel.getCountryCode())
.map(Residence::findByValue)
.map(CountryCode::findByValue)
.orElse(null)
);
}

View File

@ -1,8 +1,11 @@
package com.rbkmoney.cm.converter;
import com.rbkmoney.cm.model.InternationalLegalEntityModel;
import com.rbkmoney.damsel.domain.CountryCode;
import com.rbkmoney.damsel.domain.CountryRef;
import com.rbkmoney.damsel.domain.InternationalLegalEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Component
public class InternationalLegalEntityModelToInternationalLegalEntityConverter
@ -15,7 +18,10 @@ public class InternationalLegalEntityModelToInternationalLegalEntityConverter
.setTradingName(internationalLegalEntityModel.getTradingName())
.setActualAddress(internationalLegalEntityModel.getActualAddress())
.setRegisteredNumber(internationalLegalEntityModel.getRegisteredNumber())
.setRegisteredAddress(internationalLegalEntityModel.getRegisteredAddress());
.setRegisteredAddress(internationalLegalEntityModel.getRegisteredAddress())
.setCountry(StringUtils.hasLength(internationalLegalEntityModel.getCountryCode())
? new CountryRef(CountryCode.valueOf(internationalLegalEntityModel.getCountryCode()))
: null);
}
}

View File

@ -7,6 +7,7 @@ import org.springframework.stereotype.Component;
@Component
public class InternationalLegalEntityToInternationalLegalEntityModelConverter
implements ClaimConverter<InternationalLegalEntity, InternationalLegalEntityModel> {
@Override
public InternationalLegalEntityModel convert(InternationalLegalEntity internationalLegalEntity) {
InternationalLegalEntityModel internationalLegalEntityModel = new InternationalLegalEntityModel();
@ -15,6 +16,10 @@ public class InternationalLegalEntityToInternationalLegalEntityModelConverter
internationalLegalEntityModel.setRegisteredNumber(internationalLegalEntity.getRegisteredNumber());
internationalLegalEntityModel.setLegalName(internationalLegalEntity.getLegalName());
internationalLegalEntityModel.setTradingName(internationalLegalEntity.getTradingName());
if (internationalLegalEntity.isSetCountry()) {
internationalLegalEntityModel.setCountryCode(internationalLegalEntity.getCountry().getId().name());
}
return internationalLegalEntityModel;
}
}

View File

@ -29,4 +29,6 @@ public class InternationalLegalEntityModel extends LegalEntityModel {
private String registeredNumber;
private String countryCode;
}

View File

@ -0,0 +1,2 @@
ALTER TABLE cm.legal_entity_model
ADD COLUMN country_code character varying;