Merge pull request #6 from rbkmoney/ft/NEW-9/revision

NEW-9: Added revision to shops, contracts and contractors
This commit is contained in:
Inal Arsanukaev 2018-09-05 12:01:29 +03:00 committed by GitHub
commit 7c006c57f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 312 additions and 26 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>newway</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<packaging>jar</packaging>
<name>newway</name>
@ -209,7 +209,7 @@
<database>
<name>org.jooq.util.postgres.PostgresDatabase</name>
<includes>.*</includes>
<excludes>schema_version</excludes>
<excludes>schema_version|.*func|get_adjustment.*|get_cashflow.*|get_payment.*|get_payout.*|get_refund.*</excludes>
<inputSchema>${db.schema}</inputSchema>
</database>
<target>

View File

@ -21,7 +21,8 @@ public class EventStockConfig {
@Value("${bm.processing.url}") Resource resource,
@Value("${bm.processing.polling.delay}") int pollDelay,
@Value("${bm.processing.polling.retryDelay}") int retryDelay,
@Value("${bm.processing.polling.maxPoolSize}") int maxPoolSize
@Value("${bm.processing.polling.maxPoolSize}") int maxPoolSize,
@Value("${bm.processing.polling.maxQuerySize}") int maxQuerySize
) throws IOException {
return new PollingEventPublisherBuilder()
.withURI(resource.getURI())
@ -29,6 +30,7 @@ public class EventStockConfig {
.withMaxPoolSize(maxPoolSize)
.withEventRetryDelay(retryDelay)
.withPollDelay(pollDelay)
.withMaxQuerySize(maxQuerySize)
.build();
}
@ -38,7 +40,8 @@ public class EventStockConfig {
@Value("${bm.processing.url}") Resource resource,
@Value("${bm.processing.polling.delay}") int pollDelay,
@Value("${bm.processing.polling.retryDelay}") int retryDelay,
@Value("${bm.processing.polling.maxPoolSize}") int maxPoolSize
@Value("${bm.processing.polling.maxPoolSize}") int maxPoolSize,
@Value("${bm.processing.polling.maxQuerySize}") int maxQuerySize
) throws IOException {
return new PollingEventPublisherBuilder()
.withURI(resource.getURI())
@ -46,6 +49,7 @@ public class EventStockConfig {
.withMaxPoolSize(maxPoolSize)
.withEventRetryDelay(retryDelay)
.withPollDelay(pollDelay)
.withMaxQuerySize(maxQuerySize)
.build();
}

View File

@ -4,8 +4,11 @@ import com.rbkmoney.newway.dao.common.iface.GenericDao;
import com.rbkmoney.newway.domain.tables.pojos.Contract;
import com.rbkmoney.newway.exception.DaoException;
import java.util.List;
public interface ContractDao extends GenericDao {
Long save(Contract contract) throws DaoException;
Contract get(String partyId, String contractId) throws DaoException;
void updateNotCurrent(String partyId, String contractId) throws DaoException;
List<Contract> getByPartyId(String partyId);
}

View File

@ -4,8 +4,11 @@ import com.rbkmoney.newway.dao.common.iface.GenericDao;
import com.rbkmoney.newway.domain.tables.pojos.Contractor;
import com.rbkmoney.newway.exception.DaoException;
import java.util.List;
public interface ContractorDao extends GenericDao {
Long save(Contractor contractor) throws DaoException;
Contractor get(String partyId, String contractorId) throws DaoException;
void updateNotCurrent(String partyId, String contractorId) throws DaoException;
List<Contractor> getByPartyId(String partyId);
}

View File

@ -4,8 +4,11 @@ import com.rbkmoney.newway.dao.common.iface.GenericDao;
import com.rbkmoney.newway.domain.tables.pojos.Shop;
import com.rbkmoney.newway.exception.DaoException;
import java.util.List;
public interface ShopDao extends GenericDao {
Long save(Shop shop) throws DaoException;
Shop get(String partyId, String shopId) throws DaoException;
void updateNotCurrent(String partyId, String shopId) throws DaoException;
List<Shop> getByPartyId(String partyId);
}

View File

@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.List;
import static com.rbkmoney.newway.domain.Tables.CONTRACT;
@Component
@ -48,4 +50,11 @@ public class ContractDaoImpl extends AbstractGenericDao implements ContractDao {
.where(CONTRACT.PARTY_ID.eq(partyId).and(CONTRACT.CONTRACT_ID.eq(contractId)).and(CONTRACT.CURRENT));
executeOne(query);
}
@Override
public List<Contract> getByPartyId(String partyId) {
Query query = getDslContext().selectFrom(CONTRACT)
.where(CONTRACT.PARTY_ID.eq(partyId).and(CONTRACT.CURRENT));
return fetch(query, contractRowMapper);
}
}

View File

@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.List;
import static com.rbkmoney.newway.domain.Tables.CONTRACTOR;
@Component
@ -48,4 +50,11 @@ public class ContractorDaoImpl extends AbstractGenericDao implements ContractorD
.where(CONTRACTOR.PARTY_ID.eq(partyId).and(CONTRACTOR.CONTRACTOR_ID.eq(contractId)).and(CONTRACTOR.CURRENT));
executeOne(query);
}
@Override
public List<Contractor> getByPartyId(String partyId) {
Query query = getDslContext().selectFrom(CONTRACTOR)
.where(CONTRACTOR.PARTY_ID.eq(partyId).and(CONTRACTOR.CURRENT));
return fetch(query, contractorRowMapper);
}
}

View File

@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.List;
import static com.rbkmoney.newway.domain.Tables.SHOP;
@Component
@ -48,4 +50,12 @@ public class ShopDaoImpl extends AbstractGenericDao implements ShopDao {
.where(SHOP.PARTY_ID.eq(partyId).and(SHOP.SHOP_ID.eq(shopId)).and(SHOP.CURRENT));
executeOne(query);
}
@Override
public List<Shop> getByPartyId(String partyId) {
Query query = getDslContext().selectFrom(SHOP)
.where(SHOP.PARTY_ID.eq(partyId).and(SHOP.CURRENT));
return fetch(query, shopRowMapper);
}
}

View File

@ -38,7 +38,7 @@ import org.jooq.impl.TableImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Contract extends TableImpl<ContractRecord> {
private static final long serialVersionUID = 658945461;
private static final long serialVersionUID = 1380300695;
/**
* The reference instance of <code>nw.contract</code>
@ -178,6 +178,11 @@ public class Contract extends TableImpl<ContractRecord> {
*/
public final TableField<ContractRecord, Boolean> CURRENT = createField("current", org.jooq.impl.SQLDataType.BOOLEAN.nullable(false).defaultValue(org.jooq.impl.DSL.field("true", org.jooq.impl.SQLDataType.BOOLEAN)), this, "");
/**
* The column <code>nw.contract.revision</code>.
*/
public final TableField<ContractRecord, Long> REVISION = createField("revision", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* Create a <code>nw.contract</code> table reference
*/

View File

@ -39,7 +39,7 @@ import org.jooq.impl.TableImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Contractor extends TableImpl<ContractorRecord> {
private static final long serialVersionUID = 1923765556;
private static final long serialVersionUID = 1046755664;
/**
* The reference instance of <code>nw.contractor</code>
@ -224,6 +224,11 @@ public class Contractor extends TableImpl<ContractorRecord> {
*/
public final TableField<ContractorRecord, Boolean> CURRENT = createField("current", org.jooq.impl.SQLDataType.BOOLEAN.nullable(false).defaultValue(org.jooq.impl.DSL.field("true", org.jooq.impl.SQLDataType.BOOLEAN)), this, "");
/**
* The column <code>nw.contractor.revision</code>.
*/
public final TableField<ContractorRecord, Long> REVISION = createField("revision", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* Create a <code>nw.contractor</code> table reference
*/

View File

@ -38,7 +38,7 @@ import org.jooq.impl.TableImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Shop extends TableImpl<ShopRecord> {
private static final long serialVersionUID = 301888690;
private static final long serialVersionUID = -27984820;
/**
* The reference instance of <code>nw.shop</code>
@ -188,6 +188,11 @@ public class Shop extends TableImpl<ShopRecord> {
*/
public final TableField<ShopRecord, Boolean> CURRENT = createField("current", org.jooq.impl.SQLDataType.BOOLEAN.nullable(false).defaultValue(org.jooq.impl.DSL.field("true", org.jooq.impl.SQLDataType.BOOLEAN)), this, "");
/**
* The column <code>nw.shop.revision</code>.
*/
public final TableField<ShopRecord, Long> REVISION = createField("revision", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* Create a <code>nw.shop</code> table reference
*/

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Contract implements Serializable {
private static final long serialVersionUID = 1026713137;
private static final long serialVersionUID = 1798043522;
private Long id;
private Long eventId;
@ -53,6 +53,7 @@ public class Contract implements Serializable {
private String contractorId;
private LocalDateTime wtime;
private Boolean current;
private Long revision;
public Contract() {}
@ -82,6 +83,7 @@ public class Contract implements Serializable {
this.contractorId = value.contractorId;
this.wtime = value.wtime;
this.current = value.current;
this.revision = value.revision;
}
public Contract(
@ -109,7 +111,8 @@ public class Contract implements Serializable {
LocalDateTime reportActSignerDocPowerOfAttorneyValidUntil,
String contractorId,
LocalDateTime wtime,
Boolean current
Boolean current,
Long revision
) {
this.id = id;
this.eventId = eventId;
@ -136,6 +139,7 @@ public class Contract implements Serializable {
this.contractorId = contractorId;
this.wtime = wtime;
this.current = current;
this.revision = revision;
}
public Long getId() {
@ -338,6 +342,14 @@ public class Contract implements Serializable {
this.current = current;
}
public Long getRevision() {
return this.revision;
}
public void setRevision(Long revision) {
this.revision = revision;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -497,6 +509,12 @@ public class Contract implements Serializable {
}
else if (!current.equals(other.current))
return false;
if (revision == null) {
if (other.revision != null)
return false;
}
else if (!revision.equals(other.revision))
return false;
return true;
}
@ -529,6 +547,7 @@ public class Contract implements Serializable {
result = prime * result + ((this.contractorId == null) ? 0 : this.contractorId.hashCode());
result = prime * result + ((this.wtime == null) ? 0 : this.wtime.hashCode());
result = prime * result + ((this.current == null) ? 0 : this.current.hashCode());
result = prime * result + ((this.revision == null) ? 0 : this.revision.hashCode());
return result;
}
@ -561,6 +580,7 @@ public class Contract implements Serializable {
sb.append(", ").append(contractorId);
sb.append(", ").append(wtime);
sb.append(", ").append(current);
sb.append(", ").append(revision);
sb.append(")");
return sb.toString();

View File

@ -27,7 +27,7 @@ import javax.annotation.Generated;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Contractor implements Serializable {
private static final long serialVersionUID = -278483620;
private static final long serialVersionUID = -1208394577;
private Long id;
private Long eventId;
@ -63,6 +63,7 @@ public class Contractor implements Serializable {
private String russianPrivateEntityEmail;
private LocalDateTime wtime;
private Boolean current;
private Long revision;
public Contractor() {}
@ -101,6 +102,7 @@ public class Contractor implements Serializable {
this.russianPrivateEntityEmail = value.russianPrivateEntityEmail;
this.wtime = value.wtime;
this.current = value.current;
this.revision = value.revision;
}
public Contractor(
@ -137,7 +139,8 @@ public class Contractor implements Serializable {
String russianPrivateEntityPhoneNumber,
String russianPrivateEntityEmail,
LocalDateTime wtime,
Boolean current
Boolean current,
Long revision
) {
this.id = id;
this.eventId = eventId;
@ -173,6 +176,7 @@ public class Contractor implements Serializable {
this.russianPrivateEntityEmail = russianPrivateEntityEmail;
this.wtime = wtime;
this.current = current;
this.revision = revision;
}
public Long getId() {
@ -447,6 +451,14 @@ public class Contractor implements Serializable {
this.current = current;
}
public Long getRevision() {
return this.revision;
}
public void setRevision(Long revision) {
this.revision = revision;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -660,6 +672,12 @@ public class Contractor implements Serializable {
}
else if (!current.equals(other.current))
return false;
if (revision == null) {
if (other.revision != null)
return false;
}
else if (!revision.equals(other.revision))
return false;
return true;
}
@ -701,6 +719,7 @@ public class Contractor implements Serializable {
result = prime * result + ((this.russianPrivateEntityEmail == null) ? 0 : this.russianPrivateEntityEmail.hashCode());
result = prime * result + ((this.wtime == null) ? 0 : this.wtime.hashCode());
result = prime * result + ((this.current == null) ? 0 : this.current.hashCode());
result = prime * result + ((this.revision == null) ? 0 : this.revision.hashCode());
return result;
}
@ -742,6 +761,7 @@ public class Contractor implements Serializable {
sb.append(", ").append(russianPrivateEntityEmail);
sb.append(", ").append(wtime);
sb.append(", ").append(current);
sb.append(", ").append(revision);
sb.append(")");
return sb.toString();

View File

@ -26,7 +26,7 @@ import javax.annotation.Generated;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Shop implements Serializable {
private static final long serialVersionUID = 1604187250;
private static final long serialVersionUID = 1108378929;
private Long id;
private Long eventId;
@ -55,6 +55,7 @@ public class Shop implements Serializable {
private Integer payoutScheduleId;
private LocalDateTime wtime;
private Boolean current;
private Long revision;
public Shop() {}
@ -86,6 +87,7 @@ public class Shop implements Serializable {
this.payoutScheduleId = value.payoutScheduleId;
this.wtime = value.wtime;
this.current = value.current;
this.revision = value.revision;
}
public Shop(
@ -115,7 +117,8 @@ public class Shop implements Serializable {
String payoutToolId,
Integer payoutScheduleId,
LocalDateTime wtime,
Boolean current
Boolean current,
Long revision
) {
this.id = id;
this.eventId = eventId;
@ -144,6 +147,7 @@ public class Shop implements Serializable {
this.payoutScheduleId = payoutScheduleId;
this.wtime = wtime;
this.current = current;
this.revision = revision;
}
public Long getId() {
@ -362,6 +366,14 @@ public class Shop implements Serializable {
this.current = current;
}
public Long getRevision() {
return this.revision;
}
public void setRevision(Long revision) {
this.revision = revision;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -533,6 +545,12 @@ public class Shop implements Serializable {
}
else if (!current.equals(other.current))
return false;
if (revision == null) {
if (other.revision != null)
return false;
}
else if (!revision.equals(other.revision))
return false;
return true;
}
@ -567,6 +585,7 @@ public class Shop implements Serializable {
result = prime * result + ((this.payoutScheduleId == null) ? 0 : this.payoutScheduleId.hashCode());
result = prime * result + ((this.wtime == null) ? 0 : this.wtime.hashCode());
result = prime * result + ((this.current == null) ? 0 : this.current.hashCode());
result = prime * result + ((this.revision == null) ? 0 : this.revision.hashCode());
return result;
}
@ -601,6 +620,7 @@ public class Shop implements Serializable {
sb.append(", ").append(payoutScheduleId);
sb.append(", ").append(wtime);
sb.append(", ").append(current);
sb.append(", ").append(revision);
sb.append(")");
return sb.toString();

View File

@ -29,7 +29,7 @@ import org.jooq.impl.UpdatableRecordImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ContractRecord extends UpdatableRecordImpl<ContractRecord> {
private static final long serialVersionUID = -1754258086;
private static final long serialVersionUID = 655783420;
/**
* Setter for <code>nw.contract.id</code>.
@ -381,6 +381,20 @@ public class ContractRecord extends UpdatableRecordImpl<ContractRecord> {
return (Boolean) get(24);
}
/**
* Setter for <code>nw.contract.revision</code>.
*/
public void setRevision(Long value) {
set(25, value);
}
/**
* Getter for <code>nw.contract.revision</code>.
*/
public Long getRevision() {
return (Long) get(25);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
@ -407,7 +421,7 @@ public class ContractRecord extends UpdatableRecordImpl<ContractRecord> {
/**
* Create a detached, initialised ContractRecord
*/
public ContractRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String contractId, String partyId, Integer paymentInstitutionId, LocalDateTime createdAt, LocalDateTime validSince, LocalDateTime validUntil, ContractStatus status, LocalDateTime statusTerminatedAt, Integer termsId, LocalDateTime legalAgreementSignedAt, String legalAgreementId, LocalDateTime legalAgreementValidUntil, Integer reportActScheduleId, String reportActSignerPosition, String reportActSignerFullName, RepresentativeDocument reportActSignerDocument, LocalDateTime reportActSignerDocPowerOfAttorneySignedAt, String reportActSignerDocPowerOfAttorneyLegalAgreementId, LocalDateTime reportActSignerDocPowerOfAttorneyValidUntil, String contractorId, LocalDateTime wtime, Boolean current) {
public ContractRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String contractId, String partyId, Integer paymentInstitutionId, LocalDateTime createdAt, LocalDateTime validSince, LocalDateTime validUntil, ContractStatus status, LocalDateTime statusTerminatedAt, Integer termsId, LocalDateTime legalAgreementSignedAt, String legalAgreementId, LocalDateTime legalAgreementValidUntil, Integer reportActScheduleId, String reportActSignerPosition, String reportActSignerFullName, RepresentativeDocument reportActSignerDocument, LocalDateTime reportActSignerDocPowerOfAttorneySignedAt, String reportActSignerDocPowerOfAttorneyLegalAgreementId, LocalDateTime reportActSignerDocPowerOfAttorneyValidUntil, String contractorId, LocalDateTime wtime, Boolean current, Long revision) {
super(Contract.CONTRACT);
set(0, id);
@ -435,5 +449,6 @@ public class ContractRecord extends UpdatableRecordImpl<ContractRecord> {
set(22, contractorId);
set(23, wtime);
set(24, current);
set(25, revision);
}
}

View File

@ -30,7 +30,7 @@ import org.jooq.impl.UpdatableRecordImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ContractorRecord extends UpdatableRecordImpl<ContractorRecord> {
private static final long serialVersionUID = -349308071;
private static final long serialVersionUID = -1866866361;
/**
* Setter for <code>nw.contractor.id</code>.
@ -508,6 +508,20 @@ public class ContractorRecord extends UpdatableRecordImpl<ContractorRecord> {
return (Boolean) get(33);
}
/**
* Setter for <code>nw.contractor.revision</code>.
*/
public void setRevision(Long value) {
set(34, value);
}
/**
* Getter for <code>nw.contractor.revision</code>.
*/
public Long getRevision() {
return (Long) get(34);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
@ -534,7 +548,7 @@ public class ContractorRecord extends UpdatableRecordImpl<ContractorRecord> {
/**
* Create a detached, initialised ContractorRecord
*/
public ContractorRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String partyId, String contractorId, ContractorType type, String identificationalLevel, String registeredUserEmail, LegalEntity legalEntity, String russianLegalEntityRegisteredName, String russianLegalEntityRegisteredNumber, String russianLegalEntityInn, String russianLegalEntityActualAddress, String russianLegalEntityPostAddress, String russianLegalEntityRepresentativePosition, String russianLegalEntityRepresentativeFullName, String russianLegalEntityRepresentativeDocument, String russianLegalEntityRussianBankAccount, String russianLegalEntityRussianBankName, String russianLegalEntityRussianBankPostAccount, String russianLegalEntityRussianBankBik, String internationalLegalEntityLegalName, String internationalLegalEntityTradingName, String internationalLegalEntityRegisteredAddress, String internationalLegalEntityActualAddress, String internationalLegalEntityRegisteredNumber, PrivateEntity privateEntity, String russianPrivateEntityFirstName, String russianPrivateEntitySecondName, String russianPrivateEntityMiddleName, String russianPrivateEntityPhoneNumber, String russianPrivateEntityEmail, LocalDateTime wtime, Boolean current) {
public ContractorRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String partyId, String contractorId, ContractorType type, String identificationalLevel, String registeredUserEmail, LegalEntity legalEntity, String russianLegalEntityRegisteredName, String russianLegalEntityRegisteredNumber, String russianLegalEntityInn, String russianLegalEntityActualAddress, String russianLegalEntityPostAddress, String russianLegalEntityRepresentativePosition, String russianLegalEntityRepresentativeFullName, String russianLegalEntityRepresentativeDocument, String russianLegalEntityRussianBankAccount, String russianLegalEntityRussianBankName, String russianLegalEntityRussianBankPostAccount, String russianLegalEntityRussianBankBik, String internationalLegalEntityLegalName, String internationalLegalEntityTradingName, String internationalLegalEntityRegisteredAddress, String internationalLegalEntityActualAddress, String internationalLegalEntityRegisteredNumber, PrivateEntity privateEntity, String russianPrivateEntityFirstName, String russianPrivateEntitySecondName, String russianPrivateEntityMiddleName, String russianPrivateEntityPhoneNumber, String russianPrivateEntityEmail, LocalDateTime wtime, Boolean current, Long revision) {
super(Contractor.CONTRACTOR);
set(0, id);
@ -571,5 +585,6 @@ public class ContractorRecord extends UpdatableRecordImpl<ContractorRecord> {
set(31, russianPrivateEntityEmail);
set(32, wtime);
set(33, current);
set(34, revision);
}
}

View File

@ -29,7 +29,7 @@ import org.jooq.impl.UpdatableRecordImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ShopRecord extends UpdatableRecordImpl<ShopRecord> {
private static final long serialVersionUID = -658750893;
private static final long serialVersionUID = 459902909;
/**
* Setter for <code>nw.shop.id</code>.
@ -409,6 +409,20 @@ public class ShopRecord extends UpdatableRecordImpl<ShopRecord> {
return (Boolean) get(26);
}
/**
* Setter for <code>nw.shop.revision</code>.
*/
public void setRevision(Long value) {
set(27, value);
}
/**
* Getter for <code>nw.shop.revision</code>.
*/
public Long getRevision() {
return (Long) get(27);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
@ -435,7 +449,7 @@ public class ShopRecord extends UpdatableRecordImpl<ShopRecord> {
/**
* Create a detached, initialised ShopRecord
*/
public ShopRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String partyId, String shopId, LocalDateTime createdAt, Blocking blocking, String blockingUnblockedReason, LocalDateTime blockingUnblockedSince, String blockingBlockedReason, LocalDateTime blockingBlockedSince, Suspension suspension, LocalDateTime suspensionActiveSince, LocalDateTime suspensionSuspendedSince, String detailsName, String detailsDescription, String locationUrl, Integer categoryId, String accountCurrencyCode, Long accountSettlement, Long accountGuarantee, Long accountPayout, String contractId, String payoutToolId, Integer payoutScheduleId, LocalDateTime wtime, Boolean current) {
public ShopRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, String partyId, String shopId, LocalDateTime createdAt, Blocking blocking, String blockingUnblockedReason, LocalDateTime blockingUnblockedSince, String blockingBlockedReason, LocalDateTime blockingBlockedSince, Suspension suspension, LocalDateTime suspensionActiveSince, LocalDateTime suspensionSuspendedSince, String detailsName, String detailsDescription, String locationUrl, Integer categoryId, String accountCurrencyCode, Long accountSettlement, Long accountGuarantee, Long accountPayout, String contractId, String payoutToolId, Integer payoutScheduleId, LocalDateTime wtime, Boolean current, Long revision) {
super(Shop.SHOP);
set(0, id);
@ -465,5 +479,6 @@ public class ShopRecord extends UpdatableRecordImpl<ShopRecord> {
set(24, payoutScheduleId);
set(25, wtime);
set(26, current);
set(27, revision);
}
}

View File

@ -6,9 +6,12 @@ import com.rbkmoney.damsel.payment_processing.PartyChange;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.newway.dao.party.iface.ContractAdjustmentDao;
import com.rbkmoney.newway.dao.party.iface.ContractDao;
import com.rbkmoney.newway.dao.party.iface.PartyDao;
import com.rbkmoney.newway.dao.party.iface.PayoutToolDao;
import com.rbkmoney.newway.domain.enums.ContractStatus;
import com.rbkmoney.newway.domain.tables.pojos.Contract;
import com.rbkmoney.newway.domain.tables.pojos.Party;
import com.rbkmoney.newway.exception.NotFoundException;
import com.rbkmoney.newway.poller.handler.impl.party_mngmnt.AbstractClaimChangedHandler;
import com.rbkmoney.newway.util.ContractUtil;
import org.slf4j.Logger;
@ -25,11 +28,13 @@ public class ContractCreatedHandler extends AbstractClaimChangedHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final ContractDao contractDao;
private final PartyDao partyDao;
private final ContractAdjustmentDao contractAdjustmentDao;
private final PayoutToolDao payoutToolDao;
public ContractCreatedHandler(ContractDao contractDao, ContractAdjustmentDao contractAdjustmentDao, PayoutToolDao payoutToolDao) {
public ContractCreatedHandler(ContractDao contractDao, PartyDao partyDao, ContractAdjustmentDao contractAdjustmentDao, PayoutToolDao payoutToolDao) {
this.contractDao = contractDao;
this.partyDao = partyDao;
this.contractAdjustmentDao = contractAdjustmentDao;
this.payoutToolDao = payoutToolDao;
}
@ -48,6 +53,11 @@ public class ContractCreatedHandler extends AbstractClaimChangedHandler {
Contract contract = new Contract();
contract.setEventId(eventId);
contract.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
Party partySource = partyDao.get(partyId);
if (partySource == null) {
throw new NotFoundException(String.format("Party not found, partyId='%s'", partyId));
}
contract.setRevision(partySource.getRevision());
contract.setContractId(contractId);
contract.setPartyId(partyId);
if (contractCreated.isSetPaymentInstitution()) {

View File

@ -9,10 +9,13 @@ import com.rbkmoney.damsel.payment_processing.Event;
import com.rbkmoney.damsel.payment_processing.PartyChange;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.newway.dao.party.iface.ContractorDao;
import com.rbkmoney.newway.dao.party.iface.PartyDao;
import com.rbkmoney.newway.domain.enums.ContractorType;
import com.rbkmoney.newway.domain.enums.LegalEntity;
import com.rbkmoney.newway.domain.enums.PrivateEntity;
import com.rbkmoney.newway.domain.tables.pojos.Contractor;
import com.rbkmoney.newway.domain.tables.pojos.Party;
import com.rbkmoney.newway.exception.NotFoundException;
import com.rbkmoney.newway.poller.handler.impl.party_mngmnt.AbstractClaimChangedHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,9 +29,11 @@ public class ContractorCreatedHandler extends AbstractClaimChangedHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final ContractorDao contractorDao;
private final PartyDao partyDao;
public ContractorCreatedHandler(ContractorDao contractorDao) {
public ContractorCreatedHandler(ContractorDao contractorDao, PartyDao partyDao) {
this.contractorDao = contractorDao;
this.partyDao = partyDao;
}
@Override
@ -46,6 +51,11 @@ public class ContractorCreatedHandler extends AbstractClaimChangedHandler {
Contractor contractor = new Contractor();
contractor.setEventId(eventId);
contractor.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
Party partySource = partyDao.get(partyId);
if (partySource == null) {
throw new NotFoundException(String.format("Party not found, partyId='%s'", partyId));
}
contractor.setRevision(partySource.getRevision());
contractor.setPartyId(partyId);
contractor.setContractorId(contractorId);
contractor.setIdentificationalLevel(partyContractor.getStatus().name());

View File

@ -8,8 +8,10 @@ import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.newway.dao.party.iface.PartyDao;
import com.rbkmoney.newway.dao.party.iface.*;
import com.rbkmoney.newway.domain.tables.pojos.ContractAdjustment;
import com.rbkmoney.newway.domain.tables.pojos.Party;
import com.rbkmoney.newway.domain.tables.pojos.PayoutTool;
import com.rbkmoney.newway.exception.NotFoundException;
import com.rbkmoney.newway.poller.handler.impl.party_mngmnt.AbstractPartyManagementHandler;
import org.slf4j.Logger;
@ -18,17 +20,29 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Component
public class PartyRevisionChangedHandler extends AbstractPartyManagementHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final PartyDao partyDao;
private final ContractDao contractDao;
private final ContractAdjustmentDao contractAdjustmentDao;
private final PayoutToolDao payoutToolDao;
private final ContractorDao contractorDao;
private final ShopDao shopDao;
private final Filter filter;
public PartyRevisionChangedHandler(PartyDao partyDao) {
public PartyRevisionChangedHandler(PartyDao partyDao, ContractDao contractDao, ContractAdjustmentDao contractAdjustmentDao, PayoutToolDao payoutToolDao, ContractorDao contractorDao, ShopDao shopDao) {
this.partyDao = partyDao;
this.contractDao = contractDao;
this.contractAdjustmentDao = contractAdjustmentDao;
this.payoutToolDao = payoutToolDao;
this.contractorDao = contractorDao;
this.shopDao = shopDao;
this.filter = new PathConditionFilter(new PathConditionRule(
"revision_changed",
new IsNullCondition().not()));
@ -49,13 +63,74 @@ public class PartyRevisionChangedHandler extends AbstractPartyManagementHandler
partySource.setWtime(null);
partySource.setEventId(eventId);
partySource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
partySource.setRevision(partyRevisionChanged.getRevision());
long revision = partyRevisionChanged.getRevision();
partySource.setRevision(revision);
partySource.setRevisionChangedAt(TypeUtil.stringToLocalDateTime(partyRevisionChanged.getTimestamp()));
partyDao.updateNotCurrent(partyId);
partyDao.save(partySource);
updateContractorsRevision(event, partyId, revision);
updateContractsRevision(event, partyId, revision);
updateShopsRevision(event, partyId, revision);
log.info("Party revision changed has been saved, eventId={}, partyId={}", eventId, partyId);
}
private void updateShopsRevision(Event event, String partyId, long revision) {
shopDao.getByPartyId(partyId).forEach(shopSource -> {
String shopId = shopSource.getShopId();
shopSource.setId(null);
shopSource.setWtime(null);
shopSource.setEventId(event.getId());
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
shopSource.setRevision(revision);
shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop revision has been saved, eventId={}, partyId={}, shopId={}", event.getId(), partyId, shopId);
});
}
private void updateContractorsRevision(Event event, String partyId, long revision) {
contractorDao.getByPartyId(partyId).forEach(contractorSource -> {
String contractorId = contractorSource.getContractorId();
contractorSource.setId(null);
contractorSource.setWtime(null);
contractorSource.setEventId(event.getId());
contractorSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
contractorSource.setRevision(revision);
contractorDao.updateNotCurrent(partyId, contractorId);
contractorDao.save(contractorSource);
log.info("Contractor revision has been saved, eventId={}, partyId={}, contractorId={}", event.getId(), partyId, contractorId);
});
}
private void updateContractsRevision(Event event, String partyId, long revision) {
contractDao.getByPartyId(partyId).forEach(contractSource -> {
Long contractSourceId = contractSource.getId();
String contractId = contractSource.getContractId();
contractSource.setId(null);
contractSource.setWtime(null);
contractSource.setEventId(event.getId());
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
contractSource.setRevision(revision);
contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List<ContractAdjustment> adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
adjustments.forEach(a -> {
a.setId(null);
a.setCntrctId(cntrctId);
});
contractAdjustmentDao.save(adjustments);
List<PayoutTool> payoutTools = payoutToolDao.getByCntrctId(contractSourceId);
payoutTools.forEach(pt -> {
pt.setId(null);
pt.setCntrctId(cntrctId);
});
payoutToolDao.save(payoutTools);
log.info("Contract revision has been saved, eventId={}, partyId={}, contractId={}", event.getId(), partyId, contractId);
});
}
@Override
public Filter<PartyChange> getFilter() {
return filter;

View File

@ -1,12 +1,14 @@
package com.rbkmoney.newway.poller.handler.impl.party_mngmnt.shop;
import com.rbkmoney.damsel.domain.Shop;
import com.rbkmoney.damsel.payment_processing.ClaimEffect;
import com.rbkmoney.damsel.payment_processing.Event;
import com.rbkmoney.damsel.payment_processing.PartyChange;
import com.rbkmoney.damsel.payment_processing.ShopEffectUnit;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.newway.dao.party.iface.PartyDao;
import com.rbkmoney.newway.dao.party.iface.ShopDao;
import com.rbkmoney.newway.domain.tables.pojos.Party;
import com.rbkmoney.newway.exception.NotFoundException;
import com.rbkmoney.newway.poller.handler.impl.party_mngmnt.AbstractClaimChangedHandler;
import com.rbkmoney.newway.util.ShopUtil;
import org.slf4j.Logger;
@ -21,9 +23,11 @@ public class ShopCreatedHandler extends AbstractClaimChangedHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final ShopDao shopDao;
private final PartyDao partyDao;
public ShopCreatedHandler(ShopDao shopDao) {
public ShopCreatedHandler(ShopDao shopDao, PartyDao partyDao) {
this.shopDao = shopDao;
this.partyDao = partyDao;
}
@Override
@ -40,6 +44,11 @@ public class ShopCreatedHandler extends AbstractClaimChangedHandler {
com.rbkmoney.newway.domain.tables.pojos.Shop shop = new com.rbkmoney.newway.domain.tables.pojos.Shop();
shop.setEventId(eventId);
shop.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
Party partySource = partyDao.get(partyId);
if (partySource == null) {
throw new NotFoundException(String.format("Party not found, partyId='%s'", partyId));
}
shop.setRevision(partySource.getRevision());
shop.setShopId(shopId);
shop.setPartyId(partyId);
shop.setCreatedAt(TypeUtil.stringToLocalDateTime(shopCreated.getCreatedAt()));

View File

@ -21,6 +21,7 @@ bm:
delay: 10000
retryDelay: 1000
maxPoolSize: 1
maxQuerySize: 300
payout:
url: http://bustermaze:8022/repo/payout
polling:

View File

@ -0,0 +1,5 @@
TRUNCATE nw.party, nw.contract, nw.contractor, nw.shop CASCADE;
ALTER TABLE nw.contract ADD COLUMN revision BIGINT NOT NULL;
ALTER TABLE nw.contractor ADD COLUMN revision BIGINT NOT NULL;
ALTER TABLE nw.shop ADD COLUMN revision BIGINT NOT NULL;

View File

@ -6,6 +6,8 @@ import com.rbkmoney.newway.domain.tables.pojos.Contract;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static io.github.benas.randombeans.api.EnhancedRandom.random;
import static org.junit.Assert.*;
@ -21,6 +23,9 @@ public class ContractDaoImplTest extends AbstractIntegrationTest {
contractDao.save(contract);
Contract contractGet = contractDao.get(contract.getPartyId(), contract.getContractId());
assertEquals(contract, contractGet);
List<Contract> contracts = contractDao.getByPartyId(contract.getPartyId());
assertEquals(1, contracts.size());
assertEquals(contract, contracts.get(0));
contractDao.updateNotCurrent(contract.getPartyId(), contract.getContractId());
assertNull(contractDao.get(contract.getPartyId(), contract.getContractId()));
}

View File

@ -6,6 +6,8 @@ import com.rbkmoney.newway.domain.tables.pojos.Contractor;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static io.github.benas.randombeans.api.EnhancedRandom.random;
import static org.junit.Assert.*;
@ -21,6 +23,9 @@ public class ContractorDaoImplTest extends AbstractIntegrationTest {
contractorDao.save(contractor);
Contractor contractorGet = contractorDao.get(contractor.getPartyId(), contractor.getContractorId());
assertEquals(contractor, contractorGet);
List<Contractor> contractors = contractorDao.getByPartyId(contractor.getPartyId());
assertEquals(1, contractors.size());
assertEquals(contractor, contractors.get(0));
contractorDao.updateNotCurrent(contractor.getPartyId(), contractor.getContractorId());
assertNull(contractorDao.get(contractor.getPartyId(), contractor.getContractorId()));
}

View File

@ -6,6 +6,8 @@ import com.rbkmoney.newway.domain.tables.pojos.Shop;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static io.github.benas.randombeans.api.EnhancedRandom.random;
import static org.junit.Assert.*;
@ -21,6 +23,9 @@ public class ShopDaoImplTest extends AbstractIntegrationTest {
shopDao.save(shop);
Shop shopGet = shopDao.get(shop.getPartyId(), shop.getShopId());
assertEquals(shop, shopGet);
List<Shop> shops = shopDao.getByPartyId(shop.getPartyId());
assertEquals(1, shops.size());
assertEquals(shop, shops.get(0));
shopDao.updateNotCurrent(shop.getPartyId(), shop.getShopId());
assertNull(shopDao.get(shop.getPartyId(), shop.getShopId()));
}