1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,3 +31,4 @@ build/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
/infrastructure/docker-compose/volumes/
|
||||||
|
|||||||
7
.idea/compiler.xml
generated
7
.idea/compiler.xml
generated
@@ -33,6 +33,13 @@
|
|||||||
<module name="order-domain-core" options="-parameters" />
|
<module name="order-domain-core" options="-parameters" />
|
||||||
<module name="order-messaging" options="-parameters" />
|
<module name="order-messaging" options="-parameters" />
|
||||||
<module name="order-service" options="" />
|
<module name="order-service" options="" />
|
||||||
|
<module name="payment-application-service" options="-parameters" />
|
||||||
|
<module name="payment-container" options="-parameters" />
|
||||||
|
<module name="payment-dataaccess" options="-parameters" />
|
||||||
|
<module name="payment-domain" options="" />
|
||||||
|
<module name="payment-domain-core" options="-parameters" />
|
||||||
|
<module name="payment-messaging" options="-parameters" />
|
||||||
|
<module name="payment-service" options="-parameters" />
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.food.order.sysyem;
|
||||||
|
|
||||||
|
public class DomainConstants {
|
||||||
|
|
||||||
|
private DomainConstants() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String UTC = "UTC";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,5 +4,6 @@ package com.food.order.sysyem.event;
|
|||||||
// Base Domain Event Generic Class
|
// Base Domain Event Generic Class
|
||||||
public interface DomainEvent<T> {
|
public interface DomainEvent<T> {
|
||||||
|
|
||||||
|
void fire();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class Money {
|
|||||||
this.amount.compareTo(other.amount) > 0;
|
this.amount.compareTo(other.amount) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Money substract(Money other) {
|
public Money subtract(Money other) {
|
||||||
return new Money(setScale(this.amount.subtract(other.getAmount())));
|
return new Money(setScale(this.amount.subtract(other.getAmount())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.food.order.sysyem.valueobject;
|
||||||
|
|
||||||
|
public enum PaymentOrderStatus {
|
||||||
|
PENDING,
|
||||||
|
CANCELLED
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
KAFKA_VERSION=7.0.1
|
KAFKA_VERSION=7.0.1
|
||||||
GLOBAL_NETWORK=food-order-system
|
GLOBAL_NETWORK=food-order-system
|
||||||
GROUP_ID=com.food-order-system
|
GROUP_ID=com.food.order
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ services:
|
|||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --list
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --list
|
||||||
|
|
||||||
echo -e 'Deleting kafka topics'
|
echo -e 'Deleting kafka topics'
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-request --delete --if-exists
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-request-value --delete --if-exists
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-response --delete --if-exists
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic payment-response-value --delete --if-exists
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-request --delete --if-exists
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-request-value --delete --if-exists
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-response --delete --if-exists
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --topic restaurant-approval-response-value --delete --if-exists
|
||||||
|
|
||||||
echo -e 'Creating kafka topics'
|
echo -e 'Creating kafka topics'
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-request --replication-factor 3 --partitions 3
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-request-value --replication-factor 3 --partitions 3
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-response --replication-factor 3 --partitions 3
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic payment-response-value --replication-factor 3 --partitions 3
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-request --replication-factor 3 --partitions 3
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-request-value --replication-factor 3 --partitions 3
|
||||||
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-response --replication-factor 3 --partitions 3
|
kafka-topics --bootstrap-server kafka-broker-1:9092 --create --if-not-exists --topic restaurant-approval-response-value --replication-factor 3 --partitions 3
|
||||||
|
|
||||||
|
|
||||||
echo -e 'Successfully created the following topics:'
|
echo -e 'Successfully created the following topics:'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.food.order.system.kafka.order.avro.model;
|
|||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public enum OrderApprovalStatus implements org.apache.avro.generic.GenericEnumSymbol<OrderApprovalStatus> {
|
public enum OrderApprovalStatus implements org.apache.avro.generic.GenericEnumSymbol<OrderApprovalStatus> {
|
||||||
APPROVED, REJECTED ;
|
APPROVED, REJECTED ;
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.food.order.system.kafka.order.avro.model;
|
|||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public enum PaymentOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentOrderStatus> {
|
public enum PaymentOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentOrderStatus> {
|
||||||
PENDING, CANCELLED ;
|
PENDING, CANCELLED ;
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import org.apache.avro.specific.SpecificData;
|
|||||||
|
|
||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
||||||
private static final long serialVersionUID = 1425163749928760031L;
|
private static final long serialVersionUID = 2928240305434837410L;
|
||||||
|
|
||||||
|
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentRequestAvroModel\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}}]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentRequestAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentOrderStatus\",\"symbols\":[\"PENDING\",\"CANCELLED\"]}}]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
|
|
||||||
private static final SpecificData MODEL$ = new SpecificData();
|
private static final SpecificData MODEL$ = new SpecificData();
|
||||||
@@ -75,13 +75,13 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
return DECODER.decode(b);
|
return DECODER.decode(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String id;
|
private java.lang.String id;
|
||||||
private String sagaId;
|
private java.lang.String sagaId;
|
||||||
private String customerId;
|
private java.lang.String customerId;
|
||||||
private String orderId;
|
private java.lang.String orderId;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private PaymentOrderStatus paymentOrderStatus;
|
private com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Note that this does not initialize fields
|
* Default constructor. Note that this does not initialize fields
|
||||||
@@ -100,7 +100,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param createdAt The new value for createdAt
|
* @param createdAt The new value for createdAt
|
||||||
* @param paymentOrderStatus The new value for paymentOrderStatus
|
* @param paymentOrderStatus The new value for paymentOrderStatus
|
||||||
*/
|
*/
|
||||||
public PaymentRequestAvroModel(String id, String sagaId, String customerId, String orderId, java.math.BigDecimal price, java.time.Instant createdAt, PaymentOrderStatus paymentOrderStatus) {
|
public PaymentRequestAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String customerId, java.lang.String orderId, java.math.BigDecimal price, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sagaId = sagaId;
|
this.sagaId = sagaId;
|
||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
@@ -110,10 +110,10 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
this.paymentOrderStatus = paymentOrderStatus;
|
this.paymentOrderStatus = paymentOrderStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecificData getSpecificData() { return MODEL$; }
|
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
|
||||||
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
||||||
// Used by DatumWriter. Applications should not call.
|
// Used by DatumWriter. Applications should not call.
|
||||||
public Object get(int field$) {
|
public java.lang.Object get(int field$) {
|
||||||
switch (field$) {
|
switch (field$) {
|
||||||
case 0: return id;
|
case 0: return id;
|
||||||
case 1: return sagaId;
|
case 1: return sagaId;
|
||||||
@@ -145,7 +145,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
|
|
||||||
// Used by DatumReader. Applications should not call.
|
// Used by DatumReader. Applications should not call.
|
||||||
@SuppressWarnings(value="unchecked")
|
@SuppressWarnings(value="unchecked")
|
||||||
public void put(int field$, Object value$) {
|
public void put(int field$, java.lang.Object value$) {
|
||||||
switch (field$) {
|
switch (field$) {
|
||||||
case 0: id = value$ != null ? value$.toString() : null; break;
|
case 0: id = value$ != null ? value$.toString() : null; break;
|
||||||
case 1: sagaId = value$ != null ? value$.toString() : null; break;
|
case 1: sagaId = value$ != null ? value$.toString() : null; break;
|
||||||
@@ -153,7 +153,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
||||||
case 4: price = (java.math.BigDecimal)value$; break;
|
case 4: price = (java.math.BigDecimal)value$; break;
|
||||||
case 5: createdAt = (java.time.Instant)value$; break;
|
case 5: createdAt = (java.time.Instant)value$; break;
|
||||||
case 6: paymentOrderStatus = (PaymentOrderStatus)value$; break;
|
case 6: paymentOrderStatus = (com.food.order.system.kafka.order.avro.model.PaymentOrderStatus)value$; break;
|
||||||
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'id' field.
|
* Gets the value of the 'id' field.
|
||||||
* @return The value of the 'id' field.
|
* @return The value of the 'id' field.
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public java.lang.String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Sets the value of the 'id' field.
|
* Sets the value of the 'id' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setId(String value) {
|
public void setId(java.lang.String value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'sagaId' field.
|
* Gets the value of the 'sagaId' field.
|
||||||
* @return The value of the 'sagaId' field.
|
* @return The value of the 'sagaId' field.
|
||||||
*/
|
*/
|
||||||
public String getSagaId() {
|
public java.lang.String getSagaId() {
|
||||||
return sagaId;
|
return sagaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Sets the value of the 'sagaId' field.
|
* Sets the value of the 'sagaId' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setSagaId(String value) {
|
public void setSagaId(java.lang.String value) {
|
||||||
this.sagaId = value;
|
this.sagaId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'customerId' field.
|
* Gets the value of the 'customerId' field.
|
||||||
* @return The value of the 'customerId' field.
|
* @return The value of the 'customerId' field.
|
||||||
*/
|
*/
|
||||||
public String getCustomerId() {
|
public java.lang.String getCustomerId() {
|
||||||
return customerId;
|
return customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Sets the value of the 'customerId' field.
|
* Sets the value of the 'customerId' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setCustomerId(String value) {
|
public void setCustomerId(java.lang.String value) {
|
||||||
this.customerId = value;
|
this.customerId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'orderId' field.
|
* Gets the value of the 'orderId' field.
|
||||||
* @return The value of the 'orderId' field.
|
* @return The value of the 'orderId' field.
|
||||||
*/
|
*/
|
||||||
public String getOrderId() {
|
public java.lang.String getOrderId() {
|
||||||
return orderId;
|
return orderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Sets the value of the 'orderId' field.
|
* Sets the value of the 'orderId' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setOrderId(String value) {
|
public void setOrderId(java.lang.String value) {
|
||||||
this.orderId = value;
|
this.orderId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'paymentOrderStatus' field.
|
* Gets the value of the 'paymentOrderStatus' field.
|
||||||
* @return The value of the 'paymentOrderStatus' field.
|
* @return The value of the 'paymentOrderStatus' field.
|
||||||
*/
|
*/
|
||||||
public PaymentOrderStatus getPaymentOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentOrderStatus getPaymentOrderStatus() {
|
||||||
return paymentOrderStatus;
|
return paymentOrderStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Sets the value of the 'paymentOrderStatus' field.
|
* Sets the value of the 'paymentOrderStatus' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setPaymentOrderStatus(PaymentOrderStatus value) {
|
public void setPaymentOrderStatus(com.food.order.system.kafka.order.avro.model.PaymentOrderStatus value) {
|
||||||
this.paymentOrderStatus = value;
|
this.paymentOrderStatus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,8 +281,8 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Creates a new PaymentRequestAvroModel RecordBuilder.
|
* Creates a new PaymentRequestAvroModel RecordBuilder.
|
||||||
* @return A new PaymentRequestAvroModel RecordBuilder
|
* @return A new PaymentRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Builder newBuilder() {
|
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder() {
|
||||||
return new Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,11 +290,11 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param other The existing builder to copy.
|
* @param other The existing builder to copy.
|
||||||
* @return A new PaymentRequestAvroModel RecordBuilder
|
* @return A new PaymentRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Builder newBuilder(Builder other) {
|
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +303,11 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
* @return A new PaymentRequestAvroModel RecordBuilder
|
* @return A new PaymentRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Builder newBuilder(PaymentRequestAvroModel other) {
|
public static com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,13 +318,13 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<PaymentRequestAvroModel>
|
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<PaymentRequestAvroModel>
|
||||||
implements org.apache.avro.data.RecordBuilder<PaymentRequestAvroModel> {
|
implements org.apache.avro.data.RecordBuilder<PaymentRequestAvroModel> {
|
||||||
|
|
||||||
private String id;
|
private java.lang.String id;
|
||||||
private String sagaId;
|
private java.lang.String sagaId;
|
||||||
private String customerId;
|
private java.lang.String customerId;
|
||||||
private String orderId;
|
private java.lang.String orderId;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private PaymentOrderStatus paymentOrderStatus;
|
private com.food.order.system.kafka.order.avro.model.PaymentOrderStatus paymentOrderStatus;
|
||||||
|
|
||||||
/** Creates a new Builder */
|
/** Creates a new Builder */
|
||||||
private Builder() {
|
private Builder() {
|
||||||
@@ -335,7 +335,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Creates a Builder by copying an existing Builder.
|
* Creates a Builder by copying an existing Builder.
|
||||||
* @param other The existing Builder to copy.
|
* @param other The existing Builder to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(Builder other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder other) {
|
||||||
super(other);
|
super(other);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -371,7 +371,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Creates a Builder by copying an existing PaymentRequestAvroModel instance
|
* Creates a Builder by copying an existing PaymentRequestAvroModel instance
|
||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(PaymentRequestAvroModel other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel other) {
|
||||||
super(SCHEMA$, MODEL$);
|
super(SCHEMA$, MODEL$);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -407,7 +407,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'id' field.
|
* Gets the value of the 'id' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public java.lang.String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'id'.
|
* @param value The value of 'id'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setId(String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setId(java.lang.String value) {
|
||||||
validate(fields()[0], value);
|
validate(fields()[0], value);
|
||||||
this.id = value;
|
this.id = value;
|
||||||
fieldSetFlags()[0] = true;
|
fieldSetFlags()[0] = true;
|
||||||
@@ -437,7 +437,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'id' field.
|
* Clears the value of the 'id' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearId() {
|
||||||
id = null;
|
id = null;
|
||||||
fieldSetFlags()[0] = false;
|
fieldSetFlags()[0] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -447,7 +447,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'sagaId' field.
|
* Gets the value of the 'sagaId' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public String getSagaId() {
|
public java.lang.String getSagaId() {
|
||||||
return sagaId;
|
return sagaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +457,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'sagaId'.
|
* @param value The value of 'sagaId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setSagaId(String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setSagaId(java.lang.String value) {
|
||||||
validate(fields()[1], value);
|
validate(fields()[1], value);
|
||||||
this.sagaId = value;
|
this.sagaId = value;
|
||||||
fieldSetFlags()[1] = true;
|
fieldSetFlags()[1] = true;
|
||||||
@@ -477,7 +477,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'sagaId' field.
|
* Clears the value of the 'sagaId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearSagaId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearSagaId() {
|
||||||
sagaId = null;
|
sagaId = null;
|
||||||
fieldSetFlags()[1] = false;
|
fieldSetFlags()[1] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -487,7 +487,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'customerId' field.
|
* Gets the value of the 'customerId' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public String getCustomerId() {
|
public java.lang.String getCustomerId() {
|
||||||
return customerId;
|
return customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'customerId'.
|
* @param value The value of 'customerId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setCustomerId(String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setCustomerId(java.lang.String value) {
|
||||||
validate(fields()[2], value);
|
validate(fields()[2], value);
|
||||||
this.customerId = value;
|
this.customerId = value;
|
||||||
fieldSetFlags()[2] = true;
|
fieldSetFlags()[2] = true;
|
||||||
@@ -517,7 +517,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'customerId' field.
|
* Clears the value of the 'customerId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearCustomerId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearCustomerId() {
|
||||||
customerId = null;
|
customerId = null;
|
||||||
fieldSetFlags()[2] = false;
|
fieldSetFlags()[2] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -527,7 +527,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'orderId' field.
|
* Gets the value of the 'orderId' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public String getOrderId() {
|
public java.lang.String getOrderId() {
|
||||||
return orderId;
|
return orderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +537,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'orderId'.
|
* @param value The value of 'orderId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setOrderId(String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setOrderId(java.lang.String value) {
|
||||||
validate(fields()[3], value);
|
validate(fields()[3], value);
|
||||||
this.orderId = value;
|
this.orderId = value;
|
||||||
fieldSetFlags()[3] = true;
|
fieldSetFlags()[3] = true;
|
||||||
@@ -557,7 +557,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'orderId' field.
|
* Clears the value of the 'orderId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearOrderId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearOrderId() {
|
||||||
orderId = null;
|
orderId = null;
|
||||||
fieldSetFlags()[3] = false;
|
fieldSetFlags()[3] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -577,7 +577,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'price'.
|
* @param value The value of 'price'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setPrice(java.math.BigDecimal value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setPrice(java.math.BigDecimal value) {
|
||||||
validate(fields()[4], value);
|
validate(fields()[4], value);
|
||||||
this.price = value;
|
this.price = value;
|
||||||
fieldSetFlags()[4] = true;
|
fieldSetFlags()[4] = true;
|
||||||
@@ -597,7 +597,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'price' field.
|
* Clears the value of the 'price' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearPrice() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearPrice() {
|
||||||
price = null;
|
price = null;
|
||||||
fieldSetFlags()[4] = false;
|
fieldSetFlags()[4] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -617,7 +617,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'createdAt'.
|
* @param value The value of 'createdAt'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setCreatedAt(java.time.Instant value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
||||||
validate(fields()[5], value);
|
validate(fields()[5], value);
|
||||||
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
||||||
fieldSetFlags()[5] = true;
|
fieldSetFlags()[5] = true;
|
||||||
@@ -637,7 +637,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'createdAt' field.
|
* Clears the value of the 'createdAt' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearCreatedAt() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearCreatedAt() {
|
||||||
fieldSetFlags()[5] = false;
|
fieldSetFlags()[5] = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -646,7 +646,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Gets the value of the 'paymentOrderStatus' field.
|
* Gets the value of the 'paymentOrderStatus' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public PaymentOrderStatus getPaymentOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentOrderStatus getPaymentOrderStatus() {
|
||||||
return paymentOrderStatus;
|
return paymentOrderStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* @param value The value of 'paymentOrderStatus'.
|
* @param value The value of 'paymentOrderStatus'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder setPaymentOrderStatus(PaymentOrderStatus value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder setPaymentOrderStatus(com.food.order.system.kafka.order.avro.model.PaymentOrderStatus value) {
|
||||||
validate(fields()[6], value);
|
validate(fields()[6], value);
|
||||||
this.paymentOrderStatus = value;
|
this.paymentOrderStatus = value;
|
||||||
fieldSetFlags()[6] = true;
|
fieldSetFlags()[6] = true;
|
||||||
@@ -676,7 +676,7 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
* Clears the value of the 'paymentOrderStatus' field.
|
* Clears the value of the 'paymentOrderStatus' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Builder clearPaymentOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel.Builder clearPaymentOrderStatus() {
|
||||||
paymentOrderStatus = null;
|
paymentOrderStatus = null;
|
||||||
fieldSetFlags()[6] = false;
|
fieldSetFlags()[6] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -687,17 +687,17 @@ public class PaymentRequestAvroModel extends org.apache.avro.specific.SpecificRe
|
|||||||
public PaymentRequestAvroModel build() {
|
public PaymentRequestAvroModel build() {
|
||||||
try {
|
try {
|
||||||
PaymentRequestAvroModel record = new PaymentRequestAvroModel();
|
PaymentRequestAvroModel record = new PaymentRequestAvroModel();
|
||||||
record.id = fieldSetFlags()[0] ? this.id : (String) defaultValue(fields()[0]);
|
record.id = fieldSetFlags()[0] ? this.id : (java.lang.String) defaultValue(fields()[0]);
|
||||||
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (String) defaultValue(fields()[1]);
|
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
|
||||||
record.customerId = fieldSetFlags()[2] ? this.customerId : (String) defaultValue(fields()[2]);
|
record.customerId = fieldSetFlags()[2] ? this.customerId : (java.lang.String) defaultValue(fields()[2]);
|
||||||
record.orderId = fieldSetFlags()[3] ? this.orderId : (String) defaultValue(fields()[3]);
|
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
|
||||||
record.price = fieldSetFlags()[4] ? this.price : (java.math.BigDecimal) defaultValue(fields()[4]);
|
record.price = fieldSetFlags()[4] ? this.price : (java.math.BigDecimal) defaultValue(fields()[4]);
|
||||||
record.createdAt = fieldSetFlags()[5] ? this.createdAt : (java.time.Instant) defaultValue(fields()[5]);
|
record.createdAt = fieldSetFlags()[5] ? this.createdAt : (java.time.Instant) defaultValue(fields()[5]);
|
||||||
record.paymentOrderStatus = fieldSetFlags()[6] ? this.paymentOrderStatus : (PaymentOrderStatus) defaultValue(fields()[6]);
|
record.paymentOrderStatus = fieldSetFlags()[6] ? this.paymentOrderStatus : (com.food.order.system.kafka.order.avro.model.PaymentOrderStatus) defaultValue(fields()[6]);
|
||||||
return record;
|
return record;
|
||||||
} catch (org.apache.avro.AvroMissingFieldException e) {
|
} catch (org.apache.avro.AvroMissingFieldException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (java.lang.Exception e) {
|
||||||
throw new org.apache.avro.AvroRuntimeException(e);
|
throw new org.apache.avro.AvroRuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.food.order.system.kafka.order.avro.model;
|
package com.food.order.system.kafka.order.avro.model;
|
||||||
|
|
||||||
|
import org.apache.avro.generic.GenericArray;
|
||||||
import org.apache.avro.specific.SpecificData;
|
import org.apache.avro.specific.SpecificData;
|
||||||
|
import org.apache.avro.util.Utf8;
|
||||||
import org.apache.avro.message.BinaryMessageEncoder;
|
import org.apache.avro.message.BinaryMessageEncoder;
|
||||||
import org.apache.avro.message.BinaryMessageDecoder;
|
import org.apache.avro.message.BinaryMessageDecoder;
|
||||||
import org.apache.avro.message.SchemaStore;
|
import org.apache.avro.message.SchemaStore;
|
||||||
|
|
||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
||||||
private static final long serialVersionUID = -2126784712017759782L;
|
private static final long serialVersionUID = -3686686114915224929L;
|
||||||
|
|
||||||
|
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentResponseAvroModel\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"paymentId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentResponseAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"paymentId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"customerId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"paymentStatus\",\"type\":{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
|
|
||||||
private static final SpecificData MODEL$ = new SpecificData();
|
private static final SpecificData MODEL$ = new SpecificData();
|
||||||
@@ -82,7 +84,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private PaymentStatus paymentStatus;
|
private com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus;
|
||||||
private java.util.List<java.lang.String> failureMessages;
|
private java.util.List<java.lang.String> failureMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +106,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param paymentStatus The new value for paymentStatus
|
* @param paymentStatus The new value for paymentStatus
|
||||||
* @param failureMessages The new value for failureMessages
|
* @param failureMessages The new value for failureMessages
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String paymentId, java.lang.String customerId, java.lang.String orderId, java.math.BigDecimal price, java.time.Instant createdAt, PaymentStatus paymentStatus, java.util.List<java.lang.String> failureMessages) {
|
public PaymentResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String paymentId, java.lang.String customerId, java.lang.String orderId, java.math.BigDecimal price, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus, java.util.List<java.lang.String> failureMessages) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sagaId = sagaId;
|
this.sagaId = sagaId;
|
||||||
this.paymentId = paymentId;
|
this.paymentId = paymentId;
|
||||||
@@ -164,7 +166,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
case 4: orderId = value$ != null ? value$.toString() : null; break;
|
case 4: orderId = value$ != null ? value$.toString() : null; break;
|
||||||
case 5: price = (java.math.BigDecimal)value$; break;
|
case 5: price = (java.math.BigDecimal)value$; break;
|
||||||
case 6: createdAt = (java.time.Instant)value$; break;
|
case 6: createdAt = (java.time.Instant)value$; break;
|
||||||
case 7: paymentStatus = (PaymentStatus)value$; break;
|
case 7: paymentStatus = (com.food.order.system.kafka.order.avro.model.PaymentStatus)value$; break;
|
||||||
case 8: failureMessages = (java.util.List<java.lang.String>)value$; break;
|
case 8: failureMessages = (java.util.List<java.lang.String>)value$; break;
|
||||||
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
||||||
}
|
}
|
||||||
@@ -293,7 +295,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Gets the value of the 'paymentStatus' field.
|
* Gets the value of the 'paymentStatus' field.
|
||||||
* @return The value of the 'paymentStatus' field.
|
* @return The value of the 'paymentStatus' field.
|
||||||
*/
|
*/
|
||||||
public PaymentStatus getPaymentStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentStatus getPaymentStatus() {
|
||||||
return paymentStatus;
|
return paymentStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +304,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Sets the value of the 'paymentStatus' field.
|
* Sets the value of the 'paymentStatus' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setPaymentStatus(PaymentStatus value) {
|
public void setPaymentStatus(com.food.order.system.kafka.order.avro.model.PaymentStatus value) {
|
||||||
this.paymentStatus = value;
|
this.paymentStatus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,8 +329,8 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Creates a new PaymentResponseAvroModel RecordBuilder.
|
* Creates a new PaymentResponseAvroModel RecordBuilder.
|
||||||
* @return A new PaymentResponseAvroModel RecordBuilder
|
* @return A new PaymentResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static PaymentResponseAvroModel.Builder newBuilder() {
|
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder() {
|
||||||
return new PaymentResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,11 +338,11 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param other The existing builder to copy.
|
* @param other The existing builder to copy.
|
||||||
* @return A new PaymentResponseAvroModel RecordBuilder
|
* @return A new PaymentResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static PaymentResponseAvroModel.Builder newBuilder(PaymentResponseAvroModel.Builder other) {
|
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new PaymentResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new PaymentResponseAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,11 +351,11 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
* @return A new PaymentResponseAvroModel RecordBuilder
|
* @return A new PaymentResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static PaymentResponseAvroModel.Builder newBuilder(PaymentResponseAvroModel other) {
|
public static com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new PaymentResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new PaymentResponseAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +373,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private PaymentStatus paymentStatus;
|
private com.food.order.system.kafka.order.avro.model.PaymentStatus paymentStatus;
|
||||||
private java.util.List<java.lang.String> failureMessages;
|
private java.util.List<java.lang.String> failureMessages;
|
||||||
|
|
||||||
/** Creates a new Builder */
|
/** Creates a new Builder */
|
||||||
@@ -383,7 +385,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Creates a Builder by copying an existing Builder.
|
* Creates a Builder by copying an existing Builder.
|
||||||
* @param other The existing Builder to copy.
|
* @param other The existing Builder to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(PaymentResponseAvroModel.Builder other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder other) {
|
||||||
super(other);
|
super(other);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -427,7 +429,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Creates a Builder by copying an existing PaymentResponseAvroModel instance
|
* Creates a Builder by copying an existing PaymentResponseAvroModel instance
|
||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(PaymentResponseAvroModel other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel other) {
|
||||||
super(SCHEMA$, MODEL$);
|
super(SCHEMA$, MODEL$);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -481,7 +483,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'id'.
|
* @param value The value of 'id'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setId(java.lang.String value) {
|
||||||
validate(fields()[0], value);
|
validate(fields()[0], value);
|
||||||
this.id = value;
|
this.id = value;
|
||||||
fieldSetFlags()[0] = true;
|
fieldSetFlags()[0] = true;
|
||||||
@@ -501,7 +503,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'id' field.
|
* Clears the value of the 'id' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearId() {
|
||||||
id = null;
|
id = null;
|
||||||
fieldSetFlags()[0] = false;
|
fieldSetFlags()[0] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -521,7 +523,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'sagaId'.
|
* @param value The value of 'sagaId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setSagaId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setSagaId(java.lang.String value) {
|
||||||
validate(fields()[1], value);
|
validate(fields()[1], value);
|
||||||
this.sagaId = value;
|
this.sagaId = value;
|
||||||
fieldSetFlags()[1] = true;
|
fieldSetFlags()[1] = true;
|
||||||
@@ -541,7 +543,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'sagaId' field.
|
* Clears the value of the 'sagaId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearSagaId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearSagaId() {
|
||||||
sagaId = null;
|
sagaId = null;
|
||||||
fieldSetFlags()[1] = false;
|
fieldSetFlags()[1] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -561,7 +563,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'paymentId'.
|
* @param value The value of 'paymentId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setPaymentId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPaymentId(java.lang.String value) {
|
||||||
validate(fields()[2], value);
|
validate(fields()[2], value);
|
||||||
this.paymentId = value;
|
this.paymentId = value;
|
||||||
fieldSetFlags()[2] = true;
|
fieldSetFlags()[2] = true;
|
||||||
@@ -581,7 +583,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'paymentId' field.
|
* Clears the value of the 'paymentId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearPaymentId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPaymentId() {
|
||||||
paymentId = null;
|
paymentId = null;
|
||||||
fieldSetFlags()[2] = false;
|
fieldSetFlags()[2] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -601,7 +603,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'customerId'.
|
* @param value The value of 'customerId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setCustomerId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setCustomerId(java.lang.String value) {
|
||||||
validate(fields()[3], value);
|
validate(fields()[3], value);
|
||||||
this.customerId = value;
|
this.customerId = value;
|
||||||
fieldSetFlags()[3] = true;
|
fieldSetFlags()[3] = true;
|
||||||
@@ -621,7 +623,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'customerId' field.
|
* Clears the value of the 'customerId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearCustomerId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearCustomerId() {
|
||||||
customerId = null;
|
customerId = null;
|
||||||
fieldSetFlags()[3] = false;
|
fieldSetFlags()[3] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -641,7 +643,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'orderId'.
|
* @param value The value of 'orderId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setOrderId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setOrderId(java.lang.String value) {
|
||||||
validate(fields()[4], value);
|
validate(fields()[4], value);
|
||||||
this.orderId = value;
|
this.orderId = value;
|
||||||
fieldSetFlags()[4] = true;
|
fieldSetFlags()[4] = true;
|
||||||
@@ -661,7 +663,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'orderId' field.
|
* Clears the value of the 'orderId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearOrderId() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearOrderId() {
|
||||||
orderId = null;
|
orderId = null;
|
||||||
fieldSetFlags()[4] = false;
|
fieldSetFlags()[4] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -681,7 +683,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'price'.
|
* @param value The value of 'price'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setPrice(java.math.BigDecimal value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPrice(java.math.BigDecimal value) {
|
||||||
validate(fields()[5], value);
|
validate(fields()[5], value);
|
||||||
this.price = value;
|
this.price = value;
|
||||||
fieldSetFlags()[5] = true;
|
fieldSetFlags()[5] = true;
|
||||||
@@ -701,7 +703,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'price' field.
|
* Clears the value of the 'price' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearPrice() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPrice() {
|
||||||
price = null;
|
price = null;
|
||||||
fieldSetFlags()[5] = false;
|
fieldSetFlags()[5] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -721,7 +723,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'createdAt'.
|
* @param value The value of 'createdAt'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
||||||
validate(fields()[6], value);
|
validate(fields()[6], value);
|
||||||
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
||||||
fieldSetFlags()[6] = true;
|
fieldSetFlags()[6] = true;
|
||||||
@@ -741,7 +743,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'createdAt' field.
|
* Clears the value of the 'createdAt' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearCreatedAt() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearCreatedAt() {
|
||||||
fieldSetFlags()[6] = false;
|
fieldSetFlags()[6] = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -750,7 +752,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Gets the value of the 'paymentStatus' field.
|
* Gets the value of the 'paymentStatus' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public PaymentStatus getPaymentStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentStatus getPaymentStatus() {
|
||||||
return paymentStatus;
|
return paymentStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,7 +762,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'paymentStatus'.
|
* @param value The value of 'paymentStatus'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setPaymentStatus(PaymentStatus value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setPaymentStatus(com.food.order.system.kafka.order.avro.model.PaymentStatus value) {
|
||||||
validate(fields()[7], value);
|
validate(fields()[7], value);
|
||||||
this.paymentStatus = value;
|
this.paymentStatus = value;
|
||||||
fieldSetFlags()[7] = true;
|
fieldSetFlags()[7] = true;
|
||||||
@@ -780,7 +782,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'paymentStatus' field.
|
* Clears the value of the 'paymentStatus' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearPaymentStatus() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearPaymentStatus() {
|
||||||
paymentStatus = null;
|
paymentStatus = null;
|
||||||
fieldSetFlags()[7] = false;
|
fieldSetFlags()[7] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -800,7 +802,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* @param value The value of 'failureMessages'.
|
* @param value The value of 'failureMessages'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
|
||||||
validate(fields()[8], value);
|
validate(fields()[8], value);
|
||||||
this.failureMessages = value;
|
this.failureMessages = value;
|
||||||
fieldSetFlags()[8] = true;
|
fieldSetFlags()[8] = true;
|
||||||
@@ -820,7 +822,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
* Clears the value of the 'failureMessages' field.
|
* Clears the value of the 'failureMessages' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public PaymentResponseAvroModel.Builder clearFailureMessages() {
|
public com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel.Builder clearFailureMessages() {
|
||||||
failureMessages = null;
|
failureMessages = null;
|
||||||
fieldSetFlags()[8] = false;
|
fieldSetFlags()[8] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -838,7 +840,7 @@ public class PaymentResponseAvroModel extends org.apache.avro.specific.SpecificR
|
|||||||
record.orderId = fieldSetFlags()[4] ? this.orderId : (java.lang.String) defaultValue(fields()[4]);
|
record.orderId = fieldSetFlags()[4] ? this.orderId : (java.lang.String) defaultValue(fields()[4]);
|
||||||
record.price = fieldSetFlags()[5] ? this.price : (java.math.BigDecimal) defaultValue(fields()[5]);
|
record.price = fieldSetFlags()[5] ? this.price : (java.math.BigDecimal) defaultValue(fields()[5]);
|
||||||
record.createdAt = fieldSetFlags()[6] ? this.createdAt : (java.time.Instant) defaultValue(fields()[6]);
|
record.createdAt = fieldSetFlags()[6] ? this.createdAt : (java.time.Instant) defaultValue(fields()[6]);
|
||||||
record.paymentStatus = fieldSetFlags()[7] ? this.paymentStatus : (PaymentStatus) defaultValue(fields()[7]);
|
record.paymentStatus = fieldSetFlags()[7] ? this.paymentStatus : (com.food.order.system.kafka.order.avro.model.PaymentStatus) defaultValue(fields()[7]);
|
||||||
record.failureMessages = fieldSetFlags()[8] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[8]);
|
record.failureMessages = fieldSetFlags()[8] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[8]);
|
||||||
return record;
|
return record;
|
||||||
} catch (org.apache.avro.AvroMissingFieldException e) {
|
} catch (org.apache.avro.AvroMissingFieldException e) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.food.order.system.kafka.order.avro.model;
|
|||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public enum PaymentStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentStatus> {
|
public enum PaymentStatus implements org.apache.avro.generic.GenericEnumSymbol<PaymentStatus> {
|
||||||
COMPLETED, CANCELLED, FAILED ;
|
COMPLETED, CANCELLED, FAILED ;
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"PaymentStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"COMPLETED\",\"CANCELLED\",\"FAILED\"]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.food.order.system.kafka.order.avro.model;
|
package com.food.order.system.kafka.order.avro.model;
|
||||||
|
|
||||||
import org.apache.avro.message.BinaryMessageDecoder;
|
import org.apache.avro.generic.GenericArray;
|
||||||
import org.apache.avro.message.BinaryMessageEncoder;
|
|
||||||
import org.apache.avro.message.SchemaStore;
|
|
||||||
import org.apache.avro.specific.SpecificData;
|
import org.apache.avro.specific.SpecificData;
|
||||||
|
import org.apache.avro.util.Utf8;
|
||||||
|
import org.apache.avro.message.BinaryMessageEncoder;
|
||||||
|
import org.apache.avro.message.BinaryMessageDecoder;
|
||||||
|
import org.apache.avro.message.SchemaStore;
|
||||||
|
|
||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public class Product extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
public class Product extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
||||||
private static final long serialVersionUID = -6511580554663840009L;
|
private static final long serialVersionUID = -6762943505103404653L;
|
||||||
|
|
||||||
|
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Product\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Product\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
|
|
||||||
private static final SpecificData MODEL$ = new SpecificData();
|
private static final SpecificData MODEL$ = new SpecificData();
|
||||||
@@ -150,8 +152,8 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* Creates a new Product RecordBuilder.
|
* Creates a new Product RecordBuilder.
|
||||||
* @return A new Product RecordBuilder
|
* @return A new Product RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Product.Builder newBuilder() {
|
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder() {
|
||||||
return new Product.Builder();
|
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,11 +161,11 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* @param other The existing builder to copy.
|
* @param other The existing builder to copy.
|
||||||
* @return A new Product RecordBuilder
|
* @return A new Product RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Product.Builder newBuilder(Product.Builder other) {
|
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder(com.food.order.system.kafka.order.avro.model.Product.Builder other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new Product.Builder();
|
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new Product.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.Product.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +174,11 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
* @return A new Product RecordBuilder
|
* @return A new Product RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static Product.Builder newBuilder(Product other) {
|
public static com.food.order.system.kafka.order.avro.model.Product.Builder newBuilder(com.food.order.system.kafka.order.avro.model.Product other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new Product.Builder();
|
return new com.food.order.system.kafka.order.avro.model.Product.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new Product.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.Product.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +201,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* Creates a Builder by copying an existing Builder.
|
* Creates a Builder by copying an existing Builder.
|
||||||
* @param other The existing Builder to copy.
|
* @param other The existing Builder to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(Product.Builder other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.Product.Builder other) {
|
||||||
super(other);
|
super(other);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -215,7 +217,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* Creates a Builder by copying an existing Product instance
|
* Creates a Builder by copying an existing Product instance
|
||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(Product other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.Product other) {
|
||||||
super(SCHEMA$, MODEL$);
|
super(SCHEMA$, MODEL$);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -241,7 +243,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* @param value The value of 'id'.
|
* @param value The value of 'id'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Product.Builder setId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.Product.Builder setId(java.lang.String value) {
|
||||||
validate(fields()[0], value);
|
validate(fields()[0], value);
|
||||||
this.id = value;
|
this.id = value;
|
||||||
fieldSetFlags()[0] = true;
|
fieldSetFlags()[0] = true;
|
||||||
@@ -261,7 +263,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* Clears the value of the 'id' field.
|
* Clears the value of the 'id' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Product.Builder clearId() {
|
public com.food.order.system.kafka.order.avro.model.Product.Builder clearId() {
|
||||||
id = null;
|
id = null;
|
||||||
fieldSetFlags()[0] = false;
|
fieldSetFlags()[0] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -281,7 +283,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* @param value The value of 'quantity'.
|
* @param value The value of 'quantity'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Product.Builder setQuantity(int value) {
|
public com.food.order.system.kafka.order.avro.model.Product.Builder setQuantity(int value) {
|
||||||
validate(fields()[1], value);
|
validate(fields()[1], value);
|
||||||
this.quantity = value;
|
this.quantity = value;
|
||||||
fieldSetFlags()[1] = true;
|
fieldSetFlags()[1] = true;
|
||||||
@@ -301,7 +303,7 @@ public class Product extends org.apache.avro.specific.SpecificRecordBase impleme
|
|||||||
* Clears the value of the 'quantity' field.
|
* Clears the value of the 'quantity' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public Product.Builder clearQuantity() {
|
public com.food.order.system.kafka.order.avro.model.Product.Builder clearQuantity() {
|
||||||
fieldSetFlags()[1] = false;
|
fieldSetFlags()[1] = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.food.order.system.kafka.order.avro.model;
|
package com.food.order.system.kafka.order.avro.model;
|
||||||
|
|
||||||
|
import org.apache.avro.generic.GenericArray;
|
||||||
import org.apache.avro.specific.SpecificData;
|
import org.apache.avro.specific.SpecificData;
|
||||||
|
import org.apache.avro.util.Utf8;
|
||||||
import org.apache.avro.message.BinaryMessageEncoder;
|
import org.apache.avro.message.BinaryMessageEncoder;
|
||||||
import org.apache.avro.message.BinaryMessageDecoder;
|
import org.apache.avro.message.BinaryMessageDecoder;
|
||||||
import org.apache.avro.message.SchemaStore;
|
import org.apache.avro.message.SchemaStore;
|
||||||
|
|
||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
||||||
private static final long serialVersionUID = -3917361261016430486L;
|
private static final long serialVersionUID = -3514710772324064017L;
|
||||||
|
|
||||||
|
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalRequestAvroModel\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"symbols\":[\"PAID\"]}},{\"name\":\"products\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"Product\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}}]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalRequestAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantOrderStatus\",\"type\":{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"symbols\":[\"PAID\"]}},{\"name\":\"products\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"Product\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"logicalType\":\"uuid\"},{\"name\":\"quantity\",\"type\":\"int\"}]}}},{\"name\":\"price\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":10,\"scale\":2}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}}]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
|
|
||||||
private static final SpecificData MODEL$ = new SpecificData();
|
private static final SpecificData MODEL$ = new SpecificData();
|
||||||
@@ -79,8 +81,8 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
private java.lang.String sagaId;
|
private java.lang.String sagaId;
|
||||||
private java.lang.String restaurantId;
|
private java.lang.String restaurantId;
|
||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private RestaurantOrderStatus restaurantOrderStatus;
|
private com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus;
|
||||||
private java.util.List<Product> products;
|
private java.util.List<com.food.order.system.kafka.order.avro.model.Product> products;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param price The new value for price
|
* @param price The new value for price
|
||||||
* @param createdAt The new value for createdAt
|
* @param createdAt The new value for createdAt
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, RestaurantOrderStatus restaurantOrderStatus, java.util.List<Product> products, java.math.BigDecimal price, java.time.Instant createdAt) {
|
public RestaurantApprovalRequestAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus, java.util.List<com.food.order.system.kafka.order.avro.model.Product> products, java.math.BigDecimal price, java.time.Instant createdAt) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sagaId = sagaId;
|
this.sagaId = sagaId;
|
||||||
this.restaurantId = restaurantId;
|
this.restaurantId = restaurantId;
|
||||||
@@ -156,8 +158,8 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
case 1: sagaId = value$ != null ? value$.toString() : null; break;
|
case 1: sagaId = value$ != null ? value$.toString() : null; break;
|
||||||
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
|
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
|
||||||
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
||||||
case 4: restaurantOrderStatus = (RestaurantOrderStatus)value$; break;
|
case 4: restaurantOrderStatus = (com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus)value$; break;
|
||||||
case 5: products = (java.util.List<Product>)value$; break;
|
case 5: products = (java.util.List<com.food.order.system.kafka.order.avro.model.Product>)value$; break;
|
||||||
case 6: price = (java.math.BigDecimal)value$; break;
|
case 6: price = (java.math.BigDecimal)value$; break;
|
||||||
case 7: createdAt = (java.time.Instant)value$; break;
|
case 7: createdAt = (java.time.Instant)value$; break;
|
||||||
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
||||||
@@ -236,7 +238,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Gets the value of the 'restaurantOrderStatus' field.
|
* Gets the value of the 'restaurantOrderStatus' field.
|
||||||
* @return The value of the 'restaurantOrderStatus' field.
|
* @return The value of the 'restaurantOrderStatus' field.
|
||||||
*/
|
*/
|
||||||
public RestaurantOrderStatus getRestaurantOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus getRestaurantOrderStatus() {
|
||||||
return restaurantOrderStatus;
|
return restaurantOrderStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +247,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Sets the value of the 'restaurantOrderStatus' field.
|
* Sets the value of the 'restaurantOrderStatus' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setRestaurantOrderStatus(RestaurantOrderStatus value) {
|
public void setRestaurantOrderStatus(com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus value) {
|
||||||
this.restaurantOrderStatus = value;
|
this.restaurantOrderStatus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +255,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Gets the value of the 'products' field.
|
* Gets the value of the 'products' field.
|
||||||
* @return The value of the 'products' field.
|
* @return The value of the 'products' field.
|
||||||
*/
|
*/
|
||||||
public java.util.List<Product> getProducts() {
|
public java.util.List<com.food.order.system.kafka.order.avro.model.Product> getProducts() {
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +264,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Sets the value of the 'products' field.
|
* Sets the value of the 'products' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setProducts(java.util.List<Product> value) {
|
public void setProducts(java.util.List<com.food.order.system.kafka.order.avro.model.Product> value) {
|
||||||
this.products = value;
|
this.products = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,8 +306,8 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Creates a new RestaurantApprovalRequestAvroModel RecordBuilder.
|
* Creates a new RestaurantApprovalRequestAvroModel RecordBuilder.
|
||||||
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalRequestAvroModel.Builder newBuilder() {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder() {
|
||||||
return new RestaurantApprovalRequestAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,11 +315,11 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param other The existing builder to copy.
|
* @param other The existing builder to copy.
|
||||||
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalRequestAvroModel.Builder newBuilder(RestaurantApprovalRequestAvroModel.Builder other) {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new RestaurantApprovalRequestAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new RestaurantApprovalRequestAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,11 +328,11 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
* @return A new RestaurantApprovalRequestAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalRequestAvroModel.Builder newBuilder(RestaurantApprovalRequestAvroModel other) {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new RestaurantApprovalRequestAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new RestaurantApprovalRequestAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +347,8 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
private java.lang.String sagaId;
|
private java.lang.String sagaId;
|
||||||
private java.lang.String restaurantId;
|
private java.lang.String restaurantId;
|
||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private RestaurantOrderStatus restaurantOrderStatus;
|
private com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus restaurantOrderStatus;
|
||||||
private java.util.List<Product> products;
|
private java.util.List<com.food.order.system.kafka.order.avro.model.Product> products;
|
||||||
private java.math.BigDecimal price;
|
private java.math.BigDecimal price;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
|
|
||||||
@@ -359,7 +361,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Creates a Builder by copying an existing Builder.
|
* Creates a Builder by copying an existing Builder.
|
||||||
* @param other The existing Builder to copy.
|
* @param other The existing Builder to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(RestaurantApprovalRequestAvroModel.Builder other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder other) {
|
||||||
super(other);
|
super(other);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -399,7 +401,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Creates a Builder by copying an existing RestaurantApprovalRequestAvroModel instance
|
* Creates a Builder by copying an existing RestaurantApprovalRequestAvroModel instance
|
||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(RestaurantApprovalRequestAvroModel other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel other) {
|
||||||
super(SCHEMA$, MODEL$);
|
super(SCHEMA$, MODEL$);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -449,7 +451,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'id'.
|
* @param value The value of 'id'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setId(java.lang.String value) {
|
||||||
validate(fields()[0], value);
|
validate(fields()[0], value);
|
||||||
this.id = value;
|
this.id = value;
|
||||||
fieldSetFlags()[0] = true;
|
fieldSetFlags()[0] = true;
|
||||||
@@ -469,7 +471,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'id' field.
|
* Clears the value of the 'id' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearId() {
|
||||||
id = null;
|
id = null;
|
||||||
fieldSetFlags()[0] = false;
|
fieldSetFlags()[0] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -489,7 +491,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'sagaId'.
|
* @param value The value of 'sagaId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setSagaId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setSagaId(java.lang.String value) {
|
||||||
validate(fields()[1], value);
|
validate(fields()[1], value);
|
||||||
this.sagaId = value;
|
this.sagaId = value;
|
||||||
fieldSetFlags()[1] = true;
|
fieldSetFlags()[1] = true;
|
||||||
@@ -509,7 +511,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'sagaId' field.
|
* Clears the value of the 'sagaId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearSagaId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearSagaId() {
|
||||||
sagaId = null;
|
sagaId = null;
|
||||||
fieldSetFlags()[1] = false;
|
fieldSetFlags()[1] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -529,7 +531,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'restaurantId'.
|
* @param value The value of 'restaurantId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setRestaurantId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setRestaurantId(java.lang.String value) {
|
||||||
validate(fields()[2], value);
|
validate(fields()[2], value);
|
||||||
this.restaurantId = value;
|
this.restaurantId = value;
|
||||||
fieldSetFlags()[2] = true;
|
fieldSetFlags()[2] = true;
|
||||||
@@ -549,7 +551,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'restaurantId' field.
|
* Clears the value of the 'restaurantId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearRestaurantId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearRestaurantId() {
|
||||||
restaurantId = null;
|
restaurantId = null;
|
||||||
fieldSetFlags()[2] = false;
|
fieldSetFlags()[2] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -569,7 +571,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'orderId'.
|
* @param value The value of 'orderId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setOrderId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setOrderId(java.lang.String value) {
|
||||||
validate(fields()[3], value);
|
validate(fields()[3], value);
|
||||||
this.orderId = value;
|
this.orderId = value;
|
||||||
fieldSetFlags()[3] = true;
|
fieldSetFlags()[3] = true;
|
||||||
@@ -589,7 +591,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'orderId' field.
|
* Clears the value of the 'orderId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearOrderId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearOrderId() {
|
||||||
orderId = null;
|
orderId = null;
|
||||||
fieldSetFlags()[3] = false;
|
fieldSetFlags()[3] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -599,7 +601,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Gets the value of the 'restaurantOrderStatus' field.
|
* Gets the value of the 'restaurantOrderStatus' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public RestaurantOrderStatus getRestaurantOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus getRestaurantOrderStatus() {
|
||||||
return restaurantOrderStatus;
|
return restaurantOrderStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,7 +611,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'restaurantOrderStatus'.
|
* @param value The value of 'restaurantOrderStatus'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setRestaurantOrderStatus(RestaurantOrderStatus value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setRestaurantOrderStatus(com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus value) {
|
||||||
validate(fields()[4], value);
|
validate(fields()[4], value);
|
||||||
this.restaurantOrderStatus = value;
|
this.restaurantOrderStatus = value;
|
||||||
fieldSetFlags()[4] = true;
|
fieldSetFlags()[4] = true;
|
||||||
@@ -629,7 +631,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'restaurantOrderStatus' field.
|
* Clears the value of the 'restaurantOrderStatus' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearRestaurantOrderStatus() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearRestaurantOrderStatus() {
|
||||||
restaurantOrderStatus = null;
|
restaurantOrderStatus = null;
|
||||||
fieldSetFlags()[4] = false;
|
fieldSetFlags()[4] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -639,7 +641,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Gets the value of the 'products' field.
|
* Gets the value of the 'products' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public java.util.List<Product> getProducts() {
|
public java.util.List<com.food.order.system.kafka.order.avro.model.Product> getProducts() {
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +651,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'products'.
|
* @param value The value of 'products'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setProducts(java.util.List<Product> value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setProducts(java.util.List<com.food.order.system.kafka.order.avro.model.Product> value) {
|
||||||
validate(fields()[5], value);
|
validate(fields()[5], value);
|
||||||
this.products = value;
|
this.products = value;
|
||||||
fieldSetFlags()[5] = true;
|
fieldSetFlags()[5] = true;
|
||||||
@@ -669,7 +671,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'products' field.
|
* Clears the value of the 'products' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearProducts() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearProducts() {
|
||||||
products = null;
|
products = null;
|
||||||
fieldSetFlags()[5] = false;
|
fieldSetFlags()[5] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -689,7 +691,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'price'.
|
* @param value The value of 'price'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setPrice(java.math.BigDecimal value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setPrice(java.math.BigDecimal value) {
|
||||||
validate(fields()[6], value);
|
validate(fields()[6], value);
|
||||||
this.price = value;
|
this.price = value;
|
||||||
fieldSetFlags()[6] = true;
|
fieldSetFlags()[6] = true;
|
||||||
@@ -709,7 +711,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'price' field.
|
* Clears the value of the 'price' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearPrice() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearPrice() {
|
||||||
price = null;
|
price = null;
|
||||||
fieldSetFlags()[6] = false;
|
fieldSetFlags()[6] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -729,7 +731,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* @param value The value of 'createdAt'.
|
* @param value The value of 'createdAt'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
||||||
validate(fields()[7], value);
|
validate(fields()[7], value);
|
||||||
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
||||||
fieldSetFlags()[7] = true;
|
fieldSetFlags()[7] = true;
|
||||||
@@ -749,7 +751,7 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
* Clears the value of the 'createdAt' field.
|
* Clears the value of the 'createdAt' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalRequestAvroModel.Builder clearCreatedAt() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel.Builder clearCreatedAt() {
|
||||||
fieldSetFlags()[7] = false;
|
fieldSetFlags()[7] = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -763,8 +765,8 @@ public class RestaurantApprovalRequestAvroModel extends org.apache.avro.specific
|
|||||||
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
|
record.sagaId = fieldSetFlags()[1] ? this.sagaId : (java.lang.String) defaultValue(fields()[1]);
|
||||||
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
|
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
|
||||||
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
|
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
|
||||||
record.restaurantOrderStatus = fieldSetFlags()[4] ? this.restaurantOrderStatus : (RestaurantOrderStatus) defaultValue(fields()[4]);
|
record.restaurantOrderStatus = fieldSetFlags()[4] ? this.restaurantOrderStatus : (com.food.order.system.kafka.order.avro.model.RestaurantOrderStatus) defaultValue(fields()[4]);
|
||||||
record.products = fieldSetFlags()[5] ? this.products : (java.util.List<Product>) defaultValue(fields()[5]);
|
record.products = fieldSetFlags()[5] ? this.products : (java.util.List<com.food.order.system.kafka.order.avro.model.Product>) defaultValue(fields()[5]);
|
||||||
record.price = fieldSetFlags()[6] ? this.price : (java.math.BigDecimal) defaultValue(fields()[6]);
|
record.price = fieldSetFlags()[6] ? this.price : (java.math.BigDecimal) defaultValue(fields()[6]);
|
||||||
record.createdAt = fieldSetFlags()[7] ? this.createdAt : (java.time.Instant) defaultValue(fields()[7]);
|
record.createdAt = fieldSetFlags()[7] ? this.createdAt : (java.time.Instant) defaultValue(fields()[7]);
|
||||||
return record;
|
return record;
|
||||||
|
|||||||
@@ -5,17 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.food.order.system.kafka.order.avro.model;
|
package com.food.order.system.kafka.order.avro.model;
|
||||||
|
|
||||||
|
import org.apache.avro.generic.GenericArray;
|
||||||
import org.apache.avro.specific.SpecificData;
|
import org.apache.avro.specific.SpecificData;
|
||||||
|
import org.apache.avro.util.Utf8;
|
||||||
import org.apache.avro.message.BinaryMessageEncoder;
|
import org.apache.avro.message.BinaryMessageEncoder;
|
||||||
import org.apache.avro.message.BinaryMessageDecoder;
|
import org.apache.avro.message.BinaryMessageDecoder;
|
||||||
import org.apache.avro.message.SchemaStore;
|
import org.apache.avro.message.SchemaStore;
|
||||||
|
|
||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
|
||||||
private static final long serialVersionUID = -3431989201238018220L;
|
private static final long serialVersionUID = -5203212934279996672L;
|
||||||
|
|
||||||
|
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalResponseAvroModel\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"orderApprovalStatus\",\"type\":{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"RestaurantApprovalResponseAvroModel\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"fields\":[{\"name\":\"id\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"sagaId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"restaurantId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"orderId\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"createdAt\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"orderApprovalStatus\",\"type\":{\"type\":\"enum\",\"name\":\"OrderApprovalStatus\",\"symbols\":[\"APPROVED\",\"REJECTED\"]}},{\"name\":\"failureMessages\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}}]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
|
|
||||||
private static final SpecificData MODEL$ = new SpecificData();
|
private static final SpecificData MODEL$ = new SpecificData();
|
||||||
@@ -79,7 +81,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
private java.lang.String restaurantId;
|
private java.lang.String restaurantId;
|
||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private OrderApprovalStatus orderApprovalStatus;
|
private com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus;
|
||||||
private java.util.List<java.lang.String> failureMessages;
|
private java.util.List<java.lang.String> failureMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +101,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param orderApprovalStatus The new value for orderApprovalStatus
|
* @param orderApprovalStatus The new value for orderApprovalStatus
|
||||||
* @param failureMessages The new value for failureMessages
|
* @param failureMessages The new value for failureMessages
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, java.time.Instant createdAt, OrderApprovalStatus orderApprovalStatus, java.util.List<java.lang.String> failureMessages) {
|
public RestaurantApprovalResponseAvroModel(java.lang.String id, java.lang.String sagaId, java.lang.String restaurantId, java.lang.String orderId, java.time.Instant createdAt, com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus, java.util.List<java.lang.String> failureMessages) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sagaId = sagaId;
|
this.sagaId = sagaId;
|
||||||
this.restaurantId = restaurantId;
|
this.restaurantId = restaurantId;
|
||||||
@@ -151,7 +153,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
|
case 2: restaurantId = value$ != null ? value$.toString() : null; break;
|
||||||
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
case 3: orderId = value$ != null ? value$.toString() : null; break;
|
||||||
case 4: createdAt = (java.time.Instant)value$; break;
|
case 4: createdAt = (java.time.Instant)value$; break;
|
||||||
case 5: orderApprovalStatus = (OrderApprovalStatus)value$; break;
|
case 5: orderApprovalStatus = (com.food.order.system.kafka.order.avro.model.OrderApprovalStatus)value$; break;
|
||||||
case 6: failureMessages = (java.util.List<java.lang.String>)value$; break;
|
case 6: failureMessages = (java.util.List<java.lang.String>)value$; break;
|
||||||
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
|
||||||
}
|
}
|
||||||
@@ -246,7 +248,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Gets the value of the 'orderApprovalStatus' field.
|
* Gets the value of the 'orderApprovalStatus' field.
|
||||||
* @return The value of the 'orderApprovalStatus' field.
|
* @return The value of the 'orderApprovalStatus' field.
|
||||||
*/
|
*/
|
||||||
public OrderApprovalStatus getOrderApprovalStatus() {
|
public com.food.order.system.kafka.order.avro.model.OrderApprovalStatus getOrderApprovalStatus() {
|
||||||
return orderApprovalStatus;
|
return orderApprovalStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +257,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Sets the value of the 'orderApprovalStatus' field.
|
* Sets the value of the 'orderApprovalStatus' field.
|
||||||
* @param value the value to set.
|
* @param value the value to set.
|
||||||
*/
|
*/
|
||||||
public void setOrderApprovalStatus(OrderApprovalStatus value) {
|
public void setOrderApprovalStatus(com.food.order.system.kafka.order.avro.model.OrderApprovalStatus value) {
|
||||||
this.orderApprovalStatus = value;
|
this.orderApprovalStatus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,8 +282,8 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Creates a new RestaurantApprovalResponseAvroModel RecordBuilder.
|
* Creates a new RestaurantApprovalResponseAvroModel RecordBuilder.
|
||||||
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalResponseAvroModel.Builder newBuilder() {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder() {
|
||||||
return new RestaurantApprovalResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -289,11 +291,11 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param other The existing builder to copy.
|
* @param other The existing builder to copy.
|
||||||
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalResponseAvroModel.Builder newBuilder(RestaurantApprovalResponseAvroModel.Builder other) {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new RestaurantApprovalResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new RestaurantApprovalResponseAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,11 +304,11 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
* @return A new RestaurantApprovalResponseAvroModel RecordBuilder
|
||||||
*/
|
*/
|
||||||
public static RestaurantApprovalResponseAvroModel.Builder newBuilder(RestaurantApprovalResponseAvroModel other) {
|
public static com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder newBuilder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel other) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return new RestaurantApprovalResponseAvroModel.Builder();
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder();
|
||||||
} else {
|
} else {
|
||||||
return new RestaurantApprovalResponseAvroModel.Builder(other);
|
return new com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +324,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
private java.lang.String restaurantId;
|
private java.lang.String restaurantId;
|
||||||
private java.lang.String orderId;
|
private java.lang.String orderId;
|
||||||
private java.time.Instant createdAt;
|
private java.time.Instant createdAt;
|
||||||
private OrderApprovalStatus orderApprovalStatus;
|
private com.food.order.system.kafka.order.avro.model.OrderApprovalStatus orderApprovalStatus;
|
||||||
private java.util.List<java.lang.String> failureMessages;
|
private java.util.List<java.lang.String> failureMessages;
|
||||||
|
|
||||||
/** Creates a new Builder */
|
/** Creates a new Builder */
|
||||||
@@ -334,7 +336,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Creates a Builder by copying an existing Builder.
|
* Creates a Builder by copying an existing Builder.
|
||||||
* @param other The existing Builder to copy.
|
* @param other The existing Builder to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(RestaurantApprovalResponseAvroModel.Builder other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder other) {
|
||||||
super(other);
|
super(other);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -370,7 +372,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Creates a Builder by copying an existing RestaurantApprovalResponseAvroModel instance
|
* Creates a Builder by copying an existing RestaurantApprovalResponseAvroModel instance
|
||||||
* @param other The existing instance to copy.
|
* @param other The existing instance to copy.
|
||||||
*/
|
*/
|
||||||
private Builder(RestaurantApprovalResponseAvroModel other) {
|
private Builder(com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel other) {
|
||||||
super(SCHEMA$, MODEL$);
|
super(SCHEMA$, MODEL$);
|
||||||
if (isValidValue(fields()[0], other.id)) {
|
if (isValidValue(fields()[0], other.id)) {
|
||||||
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
this.id = data().deepCopy(fields()[0].schema(), other.id);
|
||||||
@@ -416,7 +418,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'id'.
|
* @param value The value of 'id'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setId(java.lang.String value) {
|
||||||
validate(fields()[0], value);
|
validate(fields()[0], value);
|
||||||
this.id = value;
|
this.id = value;
|
||||||
fieldSetFlags()[0] = true;
|
fieldSetFlags()[0] = true;
|
||||||
@@ -436,7 +438,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'id' field.
|
* Clears the value of the 'id' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearId() {
|
||||||
id = null;
|
id = null;
|
||||||
fieldSetFlags()[0] = false;
|
fieldSetFlags()[0] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -456,7 +458,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'sagaId'.
|
* @param value The value of 'sagaId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setSagaId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setSagaId(java.lang.String value) {
|
||||||
validate(fields()[1], value);
|
validate(fields()[1], value);
|
||||||
this.sagaId = value;
|
this.sagaId = value;
|
||||||
fieldSetFlags()[1] = true;
|
fieldSetFlags()[1] = true;
|
||||||
@@ -476,7 +478,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'sagaId' field.
|
* Clears the value of the 'sagaId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearSagaId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearSagaId() {
|
||||||
sagaId = null;
|
sagaId = null;
|
||||||
fieldSetFlags()[1] = false;
|
fieldSetFlags()[1] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -496,7 +498,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'restaurantId'.
|
* @param value The value of 'restaurantId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setRestaurantId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setRestaurantId(java.lang.String value) {
|
||||||
validate(fields()[2], value);
|
validate(fields()[2], value);
|
||||||
this.restaurantId = value;
|
this.restaurantId = value;
|
||||||
fieldSetFlags()[2] = true;
|
fieldSetFlags()[2] = true;
|
||||||
@@ -516,7 +518,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'restaurantId' field.
|
* Clears the value of the 'restaurantId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearRestaurantId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearRestaurantId() {
|
||||||
restaurantId = null;
|
restaurantId = null;
|
||||||
fieldSetFlags()[2] = false;
|
fieldSetFlags()[2] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -536,7 +538,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'orderId'.
|
* @param value The value of 'orderId'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setOrderId(java.lang.String value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setOrderId(java.lang.String value) {
|
||||||
validate(fields()[3], value);
|
validate(fields()[3], value);
|
||||||
this.orderId = value;
|
this.orderId = value;
|
||||||
fieldSetFlags()[3] = true;
|
fieldSetFlags()[3] = true;
|
||||||
@@ -556,7 +558,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'orderId' field.
|
* Clears the value of the 'orderId' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearOrderId() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearOrderId() {
|
||||||
orderId = null;
|
orderId = null;
|
||||||
fieldSetFlags()[3] = false;
|
fieldSetFlags()[3] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -576,7 +578,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'createdAt'.
|
* @param value The value of 'createdAt'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setCreatedAt(java.time.Instant value) {
|
||||||
validate(fields()[4], value);
|
validate(fields()[4], value);
|
||||||
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
this.createdAt = value.truncatedTo(java.time.temporal.ChronoUnit.MILLIS);
|
||||||
fieldSetFlags()[4] = true;
|
fieldSetFlags()[4] = true;
|
||||||
@@ -596,7 +598,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'createdAt' field.
|
* Clears the value of the 'createdAt' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearCreatedAt() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearCreatedAt() {
|
||||||
fieldSetFlags()[4] = false;
|
fieldSetFlags()[4] = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -605,7 +607,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Gets the value of the 'orderApprovalStatus' field.
|
* Gets the value of the 'orderApprovalStatus' field.
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public OrderApprovalStatus getOrderApprovalStatus() {
|
public com.food.order.system.kafka.order.avro.model.OrderApprovalStatus getOrderApprovalStatus() {
|
||||||
return orderApprovalStatus;
|
return orderApprovalStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +617,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'orderApprovalStatus'.
|
* @param value The value of 'orderApprovalStatus'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setOrderApprovalStatus(OrderApprovalStatus value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setOrderApprovalStatus(com.food.order.system.kafka.order.avro.model.OrderApprovalStatus value) {
|
||||||
validate(fields()[5], value);
|
validate(fields()[5], value);
|
||||||
this.orderApprovalStatus = value;
|
this.orderApprovalStatus = value;
|
||||||
fieldSetFlags()[5] = true;
|
fieldSetFlags()[5] = true;
|
||||||
@@ -635,7 +637,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'orderApprovalStatus' field.
|
* Clears the value of the 'orderApprovalStatus' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearOrderApprovalStatus() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearOrderApprovalStatus() {
|
||||||
orderApprovalStatus = null;
|
orderApprovalStatus = null;
|
||||||
fieldSetFlags()[5] = false;
|
fieldSetFlags()[5] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -655,7 +657,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* @param value The value of 'failureMessages'.
|
* @param value The value of 'failureMessages'.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder setFailureMessages(java.util.List<java.lang.String> value) {
|
||||||
validate(fields()[6], value);
|
validate(fields()[6], value);
|
||||||
this.failureMessages = value;
|
this.failureMessages = value;
|
||||||
fieldSetFlags()[6] = true;
|
fieldSetFlags()[6] = true;
|
||||||
@@ -675,7 +677,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
* Clears the value of the 'failureMessages' field.
|
* Clears the value of the 'failureMessages' field.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
*/
|
*/
|
||||||
public RestaurantApprovalResponseAvroModel.Builder clearFailureMessages() {
|
public com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel.Builder clearFailureMessages() {
|
||||||
failureMessages = null;
|
failureMessages = null;
|
||||||
fieldSetFlags()[6] = false;
|
fieldSetFlags()[6] = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -691,7 +693,7 @@ public class RestaurantApprovalResponseAvroModel extends org.apache.avro.specifi
|
|||||||
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
|
record.restaurantId = fieldSetFlags()[2] ? this.restaurantId : (java.lang.String) defaultValue(fields()[2]);
|
||||||
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
|
record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.String) defaultValue(fields()[3]);
|
||||||
record.createdAt = fieldSetFlags()[4] ? this.createdAt : (java.time.Instant) defaultValue(fields()[4]);
|
record.createdAt = fieldSetFlags()[4] ? this.createdAt : (java.time.Instant) defaultValue(fields()[4]);
|
||||||
record.orderApprovalStatus = fieldSetFlags()[5] ? this.orderApprovalStatus : (OrderApprovalStatus) defaultValue(fields()[5]);
|
record.orderApprovalStatus = fieldSetFlags()[5] ? this.orderApprovalStatus : (com.food.order.system.kafka.order.avro.model.OrderApprovalStatus) defaultValue(fields()[5]);
|
||||||
record.failureMessages = fieldSetFlags()[6] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[6]);
|
record.failureMessages = fieldSetFlags()[6] ? this.failureMessages : (java.util.List<java.lang.String>) defaultValue(fields()[6]);
|
||||||
return record;
|
return record;
|
||||||
} catch (org.apache.avro.AvroMissingFieldException e) {
|
} catch (org.apache.avro.AvroMissingFieldException e) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package com.food.order.system.kafka.order.avro.model;
|
|||||||
@org.apache.avro.specific.AvroGenerated
|
@org.apache.avro.specific.AvroGenerated
|
||||||
public enum RestaurantOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<RestaurantOrderStatus> {
|
public enum RestaurantOrderStatus implements org.apache.avro.generic.GenericEnumSymbol<RestaurantOrderStatus> {
|
||||||
PAID ;
|
PAID ;
|
||||||
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"namespace\":\"com.food.ordering.system.kafka.order.avro.model\",\"symbols\":[\"PAID\"]}");
|
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"RestaurantOrderStatus\",\"namespace\":\"com.food.order.system.kafka.order.avro.model\",\"symbols\":[\"PAID\"]}");
|
||||||
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
|
||||||
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"namespace": "com.food.ordering.system.kafka.order.avro.model",
|
"namespace": "com.food.order.system.kafka.order.avro.model",
|
||||||
"type": "record",
|
"type": "record",
|
||||||
"name": "PaymentResponseAvroModel",
|
"name": "PaymentResponseAvroModel",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"namespace": "com.food.ordering.system.kafka.order.avro.model",
|
"namespace": "com.food.order.system.kafka.order.avro.model",
|
||||||
"type": "record",
|
"type": "record",
|
||||||
"name": "RestaurantApprovalRequestAvroModel",
|
"name": "RestaurantApprovalRequestAvroModel",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"namespace": "com.food.ordering.system.kafka.order.avro.model",
|
"namespace": "com.food.order.system.kafka.order.avro.model",
|
||||||
"type": "record",
|
"type": "record",
|
||||||
"name": "RestaurantApprovalResponseAvroModel",
|
"name": "RestaurantApprovalResponseAvroModel",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.food.order.system.order.messaging.publisher.kafka;
|
package com.food.order.system.kafka.producer;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
import org.apache.kafka.clients.producer.RecordMetadata;
|
||||||
@@ -8,7 +8,7 @@ import org.springframework.util.concurrent.ListenableFutureCallback;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OrderKafkaMessageHelper {
|
public class KafkaMessageHelper {
|
||||||
|
|
||||||
public <T> ListenableFutureCallback<SendResult<String, T>> getKafkaCallBack
|
public <T> ListenableFutureCallback<SendResult<String, T>> getKafkaCallBack
|
||||||
(String responseTopicName, T t,String orderId, String requestAvroModelName) {
|
(String responseTopicName, T t,String orderId, String requestAvroModelName) {
|
||||||
@@ -1,48 +1,52 @@
|
|||||||
package com.food.order.system.kafka.producer.service.impl;
|
package com.food.order.system.kafka.producer.service.impl;
|
||||||
|
|
||||||
import com.food.order.system.kafka.producer.exception.KafkaProducerException;
|
|
||||||
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.avro.specific.SpecificRecordBase;
|
import org.apache.avro.specific.SpecificRecordBase;
|
||||||
import org.springframework.kafka.KafkaException;
|
|
||||||
import org.springframework.kafka.core.KafkaTemplate;
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
import org.springframework.kafka.support.SendResult;
|
import org.springframework.kafka.support.SendResult;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.concurrent.ListenableFuture;
|
|
||||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class KafkaProducerImpl<K extends Serializable, V extends SpecificRecordBase> implements KafkaProducer<K, V> {
|
public class KafkaProducerImpl<K extends Serializable, V extends SpecificRecordBase> implements KafkaProducer<K, V> {
|
||||||
|
|
||||||
private final KafkaTemplate<K, V> kafkaTemplate;
|
private final KafkaTemplate<K, V> kafkaTemplate;
|
||||||
|
|
||||||
public KafkaProducerImpl(KafkaTemplate<K, V> kafkaTemplate) {
|
|
||||||
this.kafkaTemplate = kafkaTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(String topicName, K key, V message, ListenableFutureCallback<SendResult<K, V>> callback) {
|
public void send(String topicName, K key, V message, ListenableFutureCallback<SendResult<K, V>> callback) {
|
||||||
log.info("Sending message={} to topic={}", message, topicName);
|
log.info("Sending message to topic: {}, also message {}", topicName,message);
|
||||||
try {
|
kafkaTemplate.send(topicName, key, message)
|
||||||
ListenableFuture<SendResult<K, V>> kafkaResultFuture = kafkaTemplate.send(topicName, key, message);
|
.addCallback(new ListenableFutureCallback<>() {
|
||||||
kafkaResultFuture.addCallback(callback);
|
@Override
|
||||||
} catch (KafkaException e) {
|
public void onFailure(Throwable ex) {
|
||||||
log.error("Error on kafka producer with key: {}, message: {} and exception: {}", key, message,
|
log.error("Error sending message to topic: {}, also message {}", topicName, message, ex);
|
||||||
e.getMessage());
|
callback.onFailure(ex);
|
||||||
throw new KafkaProducerException("Error on kafka producer with key: " + key + " and message: " + message);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(SendResult<K, V> result) {
|
||||||
|
log.info("Message sent to topic: {}, also message {}", topicName, message);
|
||||||
|
callback.onSuccess(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void close() {
|
public void destroy() {
|
||||||
if (kafkaTemplate != null) {
|
log.info("KafkaProducerImpl is being destroyed");
|
||||||
log.info("Closing kafka producer!");
|
if (Objects.nonNull(kafkaTemplate)) {
|
||||||
kafkaTemplate.destroy();
|
kafkaTemplate.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ logging:
|
|||||||
com.food.order.system : DEBUG
|
com.food.order.system : DEBUG
|
||||||
|
|
||||||
order-service:
|
order-service:
|
||||||
payment-request-topic-name: payment-request
|
payment-request-topic-name: payment-request-value
|
||||||
payment-response-topic-name: payment-response
|
payment-response-topic-name: payment-response-value
|
||||||
restaurant-approval-request-topic-name: restaurant-approval-request
|
restaurant-approval-request-topic-name: restaurant-approval-request-value
|
||||||
restaurant-approval-response-topic-name: restaurant-approval-response
|
restaurant-approval-response-topic-name: restaurant-approval-response-value
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
jpa:
|
jpa:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.food.order.sysyem;
|
package com.food.order.sysyem;
|
||||||
|
|
||||||
import com.food.order.sysyem.dto.create.CreateOrderCommand;
|
import com.food.order.sysyem.dto.create.CreateOrderCommand;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
import com.food.order.sysyem.mapper.OrderDataMapper;
|
import com.food.order.sysyem.mapper.OrderDataMapper;
|
||||||
import com.food.order.sysyem.ports.output.repository.CustomerRepository;
|
import com.food.order.sysyem.ports.output.repository.CustomerRepository;
|
||||||
import com.food.order.sysyem.ports.output.repository.OrderRepository;
|
import com.food.order.sysyem.ports.output.repository.OrderRepository;
|
||||||
@@ -27,6 +28,7 @@ public class OrderCreateHelper {
|
|||||||
private final CustomerRepository customerRepository;
|
private final CustomerRepository customerRepository;
|
||||||
private final RestaurantRepository restaurantRepository;
|
private final RestaurantRepository restaurantRepository;
|
||||||
private final OrderDataMapper orderDataMapper;
|
private final OrderDataMapper orderDataMapper;
|
||||||
|
private final DomainEventPublisher<OrderCreatedEvent> publisher;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderCreatedEvent persistOrder(CreateOrderCommand createOrderCommand) {
|
public OrderCreatedEvent persistOrder(CreateOrderCommand createOrderCommand) {
|
||||||
@@ -34,7 +36,7 @@ public class OrderCreateHelper {
|
|||||||
checkCustomer(createOrderCommand.customerId());
|
checkCustomer(createOrderCommand.customerId());
|
||||||
Restaurant restaurant = checkRestaurant(createOrderCommand);
|
Restaurant restaurant = checkRestaurant(createOrderCommand);
|
||||||
var order = orderDataMapper.createOrderCommandToOrder(createOrderCommand);
|
var order = orderDataMapper.createOrderCommandToOrder(createOrderCommand);
|
||||||
var createdEventOrder = orderDomainService.validateAndInitiateOrder(order, restaurant);
|
var createdEventOrder = orderDomainService.validateAndInitiateOrder(order, restaurant,publisher);
|
||||||
saveOrder(order);
|
saveOrder(order);
|
||||||
log.info("Created Order Event : {}", createdEventOrder);
|
log.info("Created Order Event : {}", createdEventOrder);
|
||||||
return createdEventOrder;
|
return createdEventOrder;
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
package com.food.order.system.domain.event;
|
package com.food.order.system.domain.event;
|
||||||
|
|
||||||
import com.food.order.system.domain.entity.Order;
|
import com.food.order.system.domain.entity.Order;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
public class OrderCancelledEvent extends OrderEvent {
|
public class OrderCancelledEvent extends OrderEvent {
|
||||||
|
|
||||||
public OrderCancelledEvent(Order order, ZonedDateTime utc) {
|
private final DomainEventPublisher<OrderCancelledEvent> publisher;
|
||||||
|
|
||||||
|
|
||||||
|
public OrderCancelledEvent(Order order, ZonedDateTime utc, DomainEventPublisher<OrderCancelledEvent> publisher) {
|
||||||
super(order, utc);
|
super(order, utc);
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
package com.food.order.system.domain.event;
|
package com.food.order.system.domain.event;
|
||||||
|
|
||||||
import com.food.order.system.domain.entity.Order;
|
import com.food.order.system.domain.entity.Order;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
public class OrderCreatedEvent extends OrderEvent {
|
public class OrderCreatedEvent extends OrderEvent {
|
||||||
public OrderCreatedEvent(Order order, ZonedDateTime createdAt) {
|
|
||||||
|
private final DomainEventPublisher<OrderCreatedEvent> publisher;
|
||||||
|
public OrderCreatedEvent(Order order, ZonedDateTime createdAt, DomainEventPublisher<OrderCreatedEvent> publisher) {
|
||||||
super(order, createdAt);
|
super(order, createdAt);
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
package com.food.order.system.domain.event;
|
package com.food.order.system.domain.event;
|
||||||
|
|
||||||
import com.food.order.system.domain.entity.Order;
|
import com.food.order.system.domain.entity.Order;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
public class OrderPaidEvent extends OrderEvent {
|
public class OrderPaidEvent extends OrderEvent {
|
||||||
|
|
||||||
public OrderPaidEvent(Order order, ZonedDateTime utc) {
|
private final DomainEventPublisher<OrderPaidEvent> publisher;
|
||||||
|
|
||||||
|
public OrderPaidEvent(Order order, ZonedDateTime utc, DomainEventPublisher<OrderPaidEvent> publisher) {
|
||||||
super(order, utc);
|
super(order, utc);
|
||||||
|
this.publisher = publisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,19 @@ import com.food.order.system.domain.entity.Restaurant;
|
|||||||
import com.food.order.system.domain.event.OrderCancelledEvent;
|
import com.food.order.system.domain.event.OrderCancelledEvent;
|
||||||
import com.food.order.system.domain.event.OrderCreatedEvent;
|
import com.food.order.system.domain.event.OrderCreatedEvent;
|
||||||
import com.food.order.system.domain.event.OrderPaidEvent;
|
import com.food.order.system.domain.event.OrderPaidEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface OrderDomainService {
|
public interface OrderDomainService {
|
||||||
|
|
||||||
OrderCreatedEvent validateAndInitiateOrder(Order order, Restaurant restaurant);
|
OrderCreatedEvent validateAndInitiateOrder(Order order, Restaurant restaurant, DomainEventPublisher<OrderCreatedEvent> publisher);
|
||||||
|
|
||||||
OrderPaidEvent payOrder(Order order);
|
OrderPaidEvent payOrder(Order order,DomainEventPublisher<OrderPaidEvent> publisher);
|
||||||
|
|
||||||
void approve(Order order);
|
void approve(Order order);
|
||||||
|
|
||||||
OrderCancelledEvent cancelOrderPayment(Order order, List<String> failureMessages);
|
OrderCancelledEvent cancelOrderPayment(Order order, List<String> failureMessages,DomainEventPublisher<OrderCancelledEvent> publisher);
|
||||||
|
|
||||||
void cancelOrder(Order order, List<String> failureMessages);
|
void cancelOrder(Order order, List<String> failureMessages);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.food.order.system.domain.event.OrderCreatedEvent;
|
|||||||
import com.food.order.system.domain.event.OrderPaidEvent;
|
import com.food.order.system.domain.event.OrderPaidEvent;
|
||||||
import com.food.order.system.domain.exception.OrderDomainException;
|
import com.food.order.system.domain.exception.OrderDomainException;
|
||||||
import com.food.order.system.domain.service.OrderDomainService;
|
import com.food.order.system.domain.service.OrderDomainService;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@@ -19,13 +20,14 @@ public class OrderDomainServiceImpl implements OrderDomainService {
|
|||||||
private static final String UTC = "UTC";
|
private static final String UTC = "UTC";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderCreatedEvent validateAndInitiateOrder(Order order, Restaurant restaurant) {
|
public OrderCreatedEvent validateAndInitiateOrder(Order order, Restaurant restaurant,
|
||||||
|
DomainEventPublisher<OrderCreatedEvent> publisher) {
|
||||||
validateRestaurant(restaurant);
|
validateRestaurant(restaurant);
|
||||||
setOrderProductInformation(order,restaurant);
|
setOrderProductInformation(order,restaurant);
|
||||||
order.validateOrder();
|
order.validateOrder();
|
||||||
order.initializeOrder();
|
order.initializeOrder();
|
||||||
log.info("Order with id {} initialize successfully", order.getId().getValue());
|
log.info("Order with id {} initialize successfully", order.getId().getValue());
|
||||||
return new OrderCreatedEvent(order, ZonedDateTime.now(ZoneId.of(UTC)));
|
return new OrderCreatedEvent(order, ZonedDateTime.now(ZoneId.of(UTC)),publisher);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOrderProductInformation(Order order, Restaurant restaurant) {
|
private void setOrderProductInformation(Order order, Restaurant restaurant) {
|
||||||
@@ -46,10 +48,10 @@ public class OrderDomainServiceImpl implements OrderDomainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderPaidEvent payOrder(Order order) {
|
public OrderPaidEvent payOrder(Order order, DomainEventPublisher<OrderPaidEvent> publisher) {
|
||||||
order.pay();
|
order.pay();
|
||||||
log.info("Order with id {} paid successfully", order.getId().getValue());
|
log.info("Order with id {} paid successfully", order.getId().getValue());
|
||||||
return new OrderPaidEvent(order, ZonedDateTime.now(ZoneId.of(UTC)));
|
return new OrderPaidEvent(order, ZonedDateTime.now(ZoneId.of(UTC)),publisher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,10 +61,11 @@ public class OrderDomainServiceImpl implements OrderDomainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderCancelledEvent cancelOrderPayment(Order order, List<String> failureMessages) {
|
public OrderCancelledEvent cancelOrderPayment(Order order, List<String> failureMessages,
|
||||||
|
DomainEventPublisher<OrderCancelledEvent> publisher) {
|
||||||
order.initCancel(failureMessages);
|
order.initCancel(failureMessages);
|
||||||
log.info("Order with id {} cancelled successfully", order.getId().getValue());
|
log.info("Order with id {} cancelled successfully", order.getId().getValue());
|
||||||
return new OrderCancelledEvent(order, ZonedDateTime.now(ZoneId.of(UTC)));
|
return new OrderCancelledEvent(order, ZonedDateTime.now(ZoneId.of(UTC)),publisher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.food.order.system.order.messaging.listener.kafka;
|
package com.food.order.system.order.messaging.listener.kafka;
|
||||||
|
|
||||||
import com.food.order.sysyem.ports.input.message.listener.payment.PaymentResponseMessageListener;
|
|
||||||
import com.food.order.system.kafka.consumer.KafkaConsumer;
|
import com.food.order.system.kafka.consumer.KafkaConsumer;
|
||||||
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
|
||||||
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
||||||
import com.food.order.system.kafka.order.avro.model.PaymentStatus;
|
import com.food.order.system.kafka.order.avro.model.PaymentStatus;
|
||||||
|
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
||||||
|
import com.food.order.sysyem.ports.input.message.listener.payment.PaymentResponseMessageListener;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.food.order.system.order.messaging.listener.kafka;
|
package com.food.order.system.order.messaging.listener.kafka;
|
||||||
|
|
||||||
import com.food.order.sysyem.ports.input.message.listener.restaurantapproval.RestaurantApprovalResponseMessageListener;
|
|
||||||
import com.food.order.system.kafka.consumer.KafkaConsumer;
|
import com.food.order.system.kafka.consumer.KafkaConsumer;
|
||||||
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
|
||||||
import com.food.order.system.kafka.order.avro.model.OrderApprovalStatus;
|
import com.food.order.system.kafka.order.avro.model.OrderApprovalStatus;
|
||||||
import com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel;
|
import com.food.order.system.kafka.order.avro.model.RestaurantApprovalResponseAvroModel;
|
||||||
|
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
||||||
|
import com.food.order.sysyem.ports.input.message.listener.restaurantapproval.RestaurantApprovalResponseMessageListener;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.food.order.system.order.messaging.publisher.kafka;
|
package com.food.order.system.order.messaging.publisher.kafka;
|
||||||
|
|
||||||
import com.food.order.system.domain.event.OrderCancelledEvent;
|
import com.food.order.system.domain.event.OrderCancelledEvent;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
||||||
import com.food.order.sysyem.config.OrderServiceConfigData;
|
import com.food.order.sysyem.config.OrderServiceConfigData;
|
||||||
import com.food.order.sysyem.ports.output.message.publisher.payment.OrderCancelledPaymentRequestMessagePublisher;
|
import com.food.order.sysyem.ports.output.message.publisher.payment.OrderCancelledPaymentRequestMessagePublisher;
|
||||||
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -19,7 +20,7 @@ public class CancelOrderKafkaMessagePublisher implements OrderCancelledPaymentRe
|
|||||||
private final OrderServiceConfigData configData;
|
private final OrderServiceConfigData configData;
|
||||||
private final KafkaProducer<String, PaymentRequestAvroModel> kafkaProducer;
|
private final KafkaProducer<String, PaymentRequestAvroModel> kafkaProducer;
|
||||||
|
|
||||||
private final OrderKafkaMessageHelper orderKafkaMessageHelper;
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(OrderCancelledEvent event) {
|
public void publish(OrderCancelledEvent event) {
|
||||||
@@ -35,7 +36,7 @@ public class CancelOrderKafkaMessagePublisher implements OrderCancelledPaymentRe
|
|||||||
configData.getPaymentRequestTopicName(),
|
configData.getPaymentRequestTopicName(),
|
||||||
orderId,
|
orderId,
|
||||||
paymentRequestAvroModel,
|
paymentRequestAvroModel,
|
||||||
orderKafkaMessageHelper.getKafkaCallBack(configData.getPaymentRequestTopicName()
|
kafkaMessageHelper.getKafkaCallBack(configData.getPaymentRequestTopicName()
|
||||||
,paymentRequestAvroModel,
|
,paymentRequestAvroModel,
|
||||||
orderId,
|
orderId,
|
||||||
"PaymentRequestAvroModel"));
|
"PaymentRequestAvroModel"));
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package com.food.order.system.order.messaging.publisher.kafka;
|
|||||||
|
|
||||||
|
|
||||||
import com.food.order.system.domain.event.OrderCreatedEvent;
|
import com.food.order.system.domain.event.OrderCreatedEvent;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
||||||
import com.food.order.sysyem.config.OrderServiceConfigData;
|
import com.food.order.sysyem.config.OrderServiceConfigData;
|
||||||
import com.food.order.sysyem.ports.output.message.publisher.payment.OrderCreatedPaymentRequestMessagePublisher;
|
import com.food.order.sysyem.ports.output.message.publisher.payment.OrderCreatedPaymentRequestMessagePublisher;
|
||||||
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -19,7 +20,7 @@ public class CreateOrderKafkaMessagePublisher implements OrderCreatedPaymentRequ
|
|||||||
private final OrderMessagingDataMapper orderMessagingDataMapper;
|
private final OrderMessagingDataMapper orderMessagingDataMapper;
|
||||||
private final OrderServiceConfigData configData;
|
private final OrderServiceConfigData configData;
|
||||||
private final KafkaProducer<String, PaymentRequestAvroModel> kafkaProducer;
|
private final KafkaProducer<String, PaymentRequestAvroModel> kafkaProducer;
|
||||||
private final OrderKafkaMessageHelper orderKafkaMessageHelper;
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,7 +36,7 @@ public class CreateOrderKafkaMessagePublisher implements OrderCreatedPaymentRequ
|
|||||||
configData.getPaymentRequestTopicName(),
|
configData.getPaymentRequestTopicName(),
|
||||||
orderId,
|
orderId,
|
||||||
paymentRequestAvroModel,
|
paymentRequestAvroModel,
|
||||||
orderKafkaMessageHelper.getKafkaCallBack(configData.getPaymentRequestTopicName(),
|
kafkaMessageHelper.getKafkaCallBack(configData.getPaymentRequestTopicName(),
|
||||||
paymentRequestAvroModel,
|
paymentRequestAvroModel,
|
||||||
orderId,
|
orderId,
|
||||||
"PaymentRequestAvroModel"));
|
"PaymentRequestAvroModel"));
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.food.order.system.order.messaging.publisher.kafka;
|
package com.food.order.system.order.messaging.publisher.kafka;
|
||||||
|
|
||||||
import com.food.order.sysyem.config.OrderServiceConfigData;
|
|
||||||
import com.food.order.sysyem.ports.output.message.publisher.restaurantapproval.OrderPaidRestaurantRequestMessagePublisher;
|
|
||||||
import com.food.order.system.domain.event.OrderPaidEvent;
|
import com.food.order.system.domain.event.OrderPaidEvent;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
import com.food.order.system.order.messaging.mapper.OrderMessagingDataMapper;
|
||||||
import com.food.order.system.kafka.order.avro.model.RestaurantApprovalRequestAvroModel;
|
import com.food.order.sysyem.config.OrderServiceConfigData;
|
||||||
|
import com.food.order.sysyem.ports.output.message.publisher.restaurantapproval.OrderPaidRestaurantRequestMessagePublisher;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -18,7 +19,7 @@ public class PayOrderKafkaMessagePublisher implements OrderPaidRestaurantRequest
|
|||||||
private final OrderMessagingDataMapper orderMessagingDataMapper;
|
private final OrderMessagingDataMapper orderMessagingDataMapper;
|
||||||
private final OrderServiceConfigData configData;
|
private final OrderServiceConfigData configData;
|
||||||
private final KafkaProducer<String, RestaurantApprovalRequestAvroModel> kafkaProducer;
|
private final KafkaProducer<String, RestaurantApprovalRequestAvroModel> kafkaProducer;
|
||||||
private final OrderKafkaMessageHelper orderKafkaMessageHelper;
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(OrderPaidEvent event) {
|
public void publish(OrderPaidEvent event) {
|
||||||
@@ -32,7 +33,7 @@ public class PayOrderKafkaMessagePublisher implements OrderPaidRestaurantRequest
|
|||||||
kafkaProducer.send(configData.getRestaurantApprovalRequestTopicName(),
|
kafkaProducer.send(configData.getRestaurantApprovalRequestTopicName(),
|
||||||
orderId,
|
orderId,
|
||||||
message,
|
message,
|
||||||
orderKafkaMessageHelper.getKafkaCallBack(configData.getRestaurantApprovalRequestTopicName(), message,
|
kafkaMessageHelper.getKafkaCallBack(configData.getRestaurantApprovalRequestTopicName(), message,
|
||||||
orderId,
|
orderId,
|
||||||
"RestaurantApprovalRequestAvroModel"));
|
"RestaurantApprovalRequestAvroModel"));
|
||||||
|
|
||||||
|
|||||||
64
payment-service/payment-container/pom.xml
Normal file
64
payment-service/payment-container/pom.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-service</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-container</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-domain-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-application-service</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-dataaccess</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-messaging</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<image>
|
||||||
|
<name>${project.groupId}/payment.service:${project.version}</name>
|
||||||
|
</image>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build-image</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.food.order.system.payment.service.domain;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class BeanConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PaymentDomainService paymentDomainService() {
|
||||||
|
return new PaymentDomainServiceImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.food.order.system.payment.service.domain;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
|
|
||||||
|
@EnableJpaRepositories(basePackages = "com.food.order.system.payment.data.access")
|
||||||
|
@EntityScan(basePackages = "com.food.order.system.payment.data.access")
|
||||||
|
@SpringBootApplication(scanBasePackages = "com.food.order")
|
||||||
|
public class PaymentServiceApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(PaymentServiceApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
server:
|
||||||
|
port: 8182
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.food.order.system: DEBUG
|
||||||
|
|
||||||
|
payment-service:
|
||||||
|
payment-request-topic-name: payment-request-value
|
||||||
|
payment-response-topic-name: payment-response-value
|
||||||
|
|
||||||
|
spring:
|
||||||
|
jpa:
|
||||||
|
open-in-view: false
|
||||||
|
show-sql: true
|
||||||
|
database-platform: org.hibernate.dialect.PostgreSQL9Dialect
|
||||||
|
properties:
|
||||||
|
hibernate:
|
||||||
|
dialect: org.hibernate.dialect.PostgreSQL9Dialect
|
||||||
|
datasource:
|
||||||
|
url: jdbc:postgresql://localhost:5432/postgres?currentSchema=payment&binaryTransfer=true&reWriteBatchedInserts=true&stringtype=unspecified
|
||||||
|
username: postgres
|
||||||
|
password: postgres
|
||||||
|
driver-class-name: org.postgresql.Driver
|
||||||
|
platform: postgres
|
||||||
|
schema: classpath:init-schema.sql
|
||||||
|
data: classpath:init-data.sql
|
||||||
|
initialization-mode: always
|
||||||
|
|
||||||
|
kafka-config:
|
||||||
|
bootstrap-servers: localhost:19092, localhost:29092, localhost:39092
|
||||||
|
schema-registry-url-key: schema.registry.url
|
||||||
|
schema-registry-url: http://localhost:8081
|
||||||
|
num-of-partitions: 3
|
||||||
|
replication-factor: 3
|
||||||
|
|
||||||
|
kafka-producer-config:
|
||||||
|
key-serializer-class: org.apache.kafka.common.serialization.StringSerializer
|
||||||
|
value-serializer-class: io.confluent.kafka.serializers.KafkaAvroSerializer
|
||||||
|
compression-type: snappy
|
||||||
|
acks: all
|
||||||
|
batch-size: 16384
|
||||||
|
batch-size-boost-factor: 100
|
||||||
|
linger-ms: 5
|
||||||
|
request-timeout-ms: 60000
|
||||||
|
retry-count: 5
|
||||||
|
|
||||||
|
kafka-consumer-config:
|
||||||
|
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||||
|
value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
|
||||||
|
payment-consumer-group-id: payment-topic-consumer
|
||||||
|
auto-offset-reset: earliest
|
||||||
|
specific-avro-reader-key: specific.avro.reader
|
||||||
|
specific-avro-reader: true
|
||||||
|
batch-listener: true
|
||||||
|
auto-startup: true
|
||||||
|
concurrency-level: 3
|
||||||
|
session-timeout-ms: 10000
|
||||||
|
heartbeat-interval-ms: 3000
|
||||||
|
max-poll-interval-ms: 300000
|
||||||
|
max-poll-records: 500
|
||||||
|
max-partition-fetch-bytes-default: 1048576
|
||||||
|
max-partition-fetch-bytes-boost-factor: 1
|
||||||
|
poll-timeout-ms: 150
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
INSERT INTO payment.credit_entry(id, customer_id, total_credit_amount)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb21', 'd215b5f8-0249-4dc5-89a3-51fd148cfb41', 500.00);
|
||||||
|
INSERT INTO payment.credit_history(id, customer_id, amount, type)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb23', 'd215b5f8-0249-4dc5-89a3-51fd148cfb41', 100.00, 'CREDIT');
|
||||||
|
INSERT INTO payment.credit_history(id, customer_id, amount, type)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb24', 'd215b5f8-0249-4dc5-89a3-51fd148cfb41', 600.00, 'CREDIT');
|
||||||
|
INSERT INTO payment.credit_history(id, customer_id, amount, type)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb25', 'd215b5f8-0249-4dc5-89a3-51fd148cfb41', 200.00, 'DEBIT');
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO payment.credit_entry(id, customer_id, total_credit_amount)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb22', 'd215b5f8-0249-4dc5-89a3-51fd148cfb43', 100.00);
|
||||||
|
INSERT INTO payment.credit_history(id, customer_id, amount, type)
|
||||||
|
VALUES ('d215b5f8-0249-4dc5-89a3-51fd148cfb26', 'd215b5f8-0249-4dc5-89a3-51fd148cfb43', 100.00, 'CREDIT');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
DROP SCHEMA IF EXISTS payment CASCADE;
|
||||||
|
|
||||||
|
CREATE SCHEMA payment;
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS payment_status;
|
||||||
|
|
||||||
|
CREATE TYPE payment_status AS ENUM ('COMPLETED', 'CANCELLED', 'FAILED');
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS "payment".payments CASCADE;
|
||||||
|
|
||||||
|
CREATE TABLE "payment".payments
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
customer_id uuid NOT NULL,
|
||||||
|
order_id uuid NOT NULL,
|
||||||
|
price numeric(10,2) NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
status payment_status NOT NULL,
|
||||||
|
CONSTRAINT payments_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS "payment".credit_entry CASCADE;
|
||||||
|
|
||||||
|
CREATE TABLE "payment".credit_entry
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
customer_id uuid NOT NULL,
|
||||||
|
total_credit_amount numeric(10,2) NOT NULL,
|
||||||
|
CONSTRAINT credit_entry_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS transaction_type;
|
||||||
|
|
||||||
|
CREATE TYPE transaction_type AS ENUM ('DEBIT', 'CREDIT');
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS "payment".credit_history CASCADE;
|
||||||
|
|
||||||
|
CREATE TABLE "payment".credit_history
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
customer_id uuid NOT NULL,
|
||||||
|
amount numeric(10,2) NOT NULL,
|
||||||
|
type transaction_type NOT NULL,
|
||||||
|
CONSTRAINT credit_history_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
34
payment-service/payment-dataaccess/pom.xml
Normal file
34
payment-service/payment-dataaccess/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-service</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-dataaccess</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-application-service</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.food.order.system.payment.data.access.creditentry.adapter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.CreditEntryRepository;
|
||||||
|
import com.food.order.system.payment.data.access.creditentry.mapper.CreditEntryDataAccessMapper;
|
||||||
|
import com.food.order.system.payment.data.access.creditentry.repository.CreditEntryJpaRepository;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreditEntryRepositoryImpl implements CreditEntryRepository {
|
||||||
|
|
||||||
|
private final CreditEntryJpaRepository creditEntryJpaRepository;
|
||||||
|
private final CreditEntryDataAccessMapper creditEntryDataAccessMapper;
|
||||||
|
|
||||||
|
public CreditEntryRepositoryImpl(CreditEntryJpaRepository creditEntryJpaRepository,
|
||||||
|
CreditEntryDataAccessMapper creditEntryDataAccessMapper) {
|
||||||
|
this.creditEntryJpaRepository = creditEntryJpaRepository;
|
||||||
|
this.creditEntryDataAccessMapper = creditEntryDataAccessMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreditEntry save(CreditEntry creditEntry) {
|
||||||
|
return creditEntryDataAccessMapper
|
||||||
|
.creditEntryEntityToCreditEntry(creditEntryJpaRepository
|
||||||
|
.save(creditEntryDataAccessMapper.creditEntryToCreditEntryEntity(creditEntry)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<CreditEntry> findByCustomerId(CustomerId customerId) {
|
||||||
|
return creditEntryJpaRepository
|
||||||
|
.findByCustomerId(customerId.getValue())
|
||||||
|
.map(creditEntryDataAccessMapper::creditEntryEntityToCreditEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.food.order.system.payment.data.access.creditentry.entity;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "credit_entry")
|
||||||
|
@Entity
|
||||||
|
public class CreditEntryEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private UUID id;
|
||||||
|
private UUID customerId;
|
||||||
|
private BigDecimal totalCreditAmount;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
CreditEntryEntity that = (CreditEntryEntity) o;
|
||||||
|
return id.equals(that.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.food.order.system.payment.data.access.creditentry.exception;
|
||||||
|
|
||||||
|
public class CreditEntryDataaccessException extends RuntimeException {
|
||||||
|
|
||||||
|
public CreditEntryDataaccessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.food.order.system.payment.data.access.creditentry.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.creditentry.entity.CreditEntryEntity;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.CreditEntryId;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreditEntryDataAccessMapper {
|
||||||
|
|
||||||
|
public CreditEntry creditEntryEntityToCreditEntry(CreditEntryEntity creditEntryEntity) {
|
||||||
|
return CreditEntry.builder()
|
||||||
|
.id(new CreditEntryId(creditEntryEntity.getId()))
|
||||||
|
.customerId(new CustomerId(creditEntryEntity.getCustomerId()))
|
||||||
|
.totalCreditAmount(new Money(creditEntryEntity.getTotalCreditAmount()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditEntryEntity creditEntryToCreditEntryEntity(CreditEntry creditEntry) {
|
||||||
|
return CreditEntryEntity.builder()
|
||||||
|
.id(creditEntry.getId().getValue())
|
||||||
|
.customerId(creditEntry.getCustomerId().getValue())
|
||||||
|
.totalCreditAmount(creditEntry.getTotalCreditAmount().getAmount())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.food.order.system.payment.data.access.creditentry.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.creditentry.entity.CreditEntryEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CreditEntryJpaRepository extends JpaRepository<CreditEntryEntity, UUID> {
|
||||||
|
|
||||||
|
Optional<CreditEntryEntity> findByCustomerId(UUID customerId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.food.order.system.payment.data.access.credithistory.adapter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.CreditHistoryRepository;
|
||||||
|
import com.food.order.system.payment.data.access.credithistory.mapper.CreditHistoryDataAccessMapper;
|
||||||
|
import com.food.order.system.payment.data.access.credithistory.repository.CreditHistoryJpaRepository;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreditHistoryRepositoryImpl implements CreditHistoryRepository {
|
||||||
|
|
||||||
|
private final CreditHistoryJpaRepository creditHistoryJpaRepository;
|
||||||
|
private final CreditHistoryDataAccessMapper creditHistoryDataAccessMapper;
|
||||||
|
|
||||||
|
public CreditHistoryRepositoryImpl(CreditHistoryJpaRepository creditHistoryJpaRepository,
|
||||||
|
CreditHistoryDataAccessMapper creditHistoryDataAccessMapper) {
|
||||||
|
this.creditHistoryJpaRepository = creditHistoryJpaRepository;
|
||||||
|
this.creditHistoryDataAccessMapper = creditHistoryDataAccessMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreditHistory save(CreditHistory creditHistory) {
|
||||||
|
return creditHistoryDataAccessMapper.creditHistoryEntityToCreditHistory(creditHistoryJpaRepository
|
||||||
|
.save(creditHistoryDataAccessMapper.creditHistoryToCreditHistoryEntity(creditHistory)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<CreditHistory>> findByCustomerId(CustomerId customerId) {
|
||||||
|
return creditHistoryJpaRepository.findByCustomerId(customerId.getValue())
|
||||||
|
.map(creditHistoryList ->
|
||||||
|
creditHistoryList.stream()
|
||||||
|
.map(creditHistoryDataAccessMapper::creditHistoryEntityToCreditHistory)
|
||||||
|
.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.food.order.system.payment.data.access.credithistory.entity;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.TransactionType;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "credit_history")
|
||||||
|
@Entity
|
||||||
|
public class CreditHistoryEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private UUID id;
|
||||||
|
private UUID customerId;
|
||||||
|
private BigDecimal amount;
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private TransactionType type;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
CreditHistoryEntity that = (CreditHistoryEntity) o;
|
||||||
|
return id.equals(that.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.food.order.system.payment.data.access.credithistory.exception;
|
||||||
|
|
||||||
|
public class CreditHistoryDataaccessException extends RuntimeException {
|
||||||
|
|
||||||
|
public CreditHistoryDataaccessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.food.order.system.payment.data.access.credithistory.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.credithistory.entity.CreditHistoryEntity;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.CreditHistoryId;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreditHistoryDataAccessMapper {
|
||||||
|
|
||||||
|
public CreditHistory creditHistoryEntityToCreditHistory(CreditHistoryEntity creditHistoryEntity) {
|
||||||
|
return CreditHistory.builder()
|
||||||
|
.id(new CreditHistoryId(creditHistoryEntity.getId()))
|
||||||
|
.customerId(new CustomerId(creditHistoryEntity.getCustomerId()))
|
||||||
|
.amount(new Money(creditHistoryEntity.getAmount()))
|
||||||
|
.transactionType(creditHistoryEntity.getType())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditHistoryEntity creditHistoryToCreditHistoryEntity(CreditHistory creditHistory) {
|
||||||
|
return CreditHistoryEntity.builder()
|
||||||
|
.id(creditHistory.getId().getValue())
|
||||||
|
.customerId(creditHistory.getCustomerId().getValue())
|
||||||
|
.amount(creditHistory.getAmount().getAmount())
|
||||||
|
.type(creditHistory.getTransactionType())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.food.order.system.payment.data.access.credithistory.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.credithistory.entity.CreditHistoryEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CreditHistoryJpaRepository extends JpaRepository<CreditHistoryEntity, UUID> {
|
||||||
|
|
||||||
|
Optional<List<CreditHistoryEntity>> findByCustomerId(UUID customerId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.food.order.system.payment.data.access.payment.adapter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.PaymentRepository;
|
||||||
|
import com.food.order.system.payment.data.access.payment.mapper.PaymentDataAccessMapper;
|
||||||
|
import com.food.order.system.payment.data.access.payment.repository.PaymentJpaRepository;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PaymentRepositoryImpl implements PaymentRepository {
|
||||||
|
|
||||||
|
private final PaymentJpaRepository paymentJpaRepository;
|
||||||
|
private final PaymentDataAccessMapper paymentDataAccessMapper;
|
||||||
|
|
||||||
|
public PaymentRepositoryImpl(PaymentJpaRepository paymentJpaRepository,
|
||||||
|
PaymentDataAccessMapper paymentDataAccessMapper) {
|
||||||
|
this.paymentJpaRepository = paymentJpaRepository;
|
||||||
|
this.paymentDataAccessMapper = paymentDataAccessMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Payment save(Payment payment) {
|
||||||
|
return paymentDataAccessMapper
|
||||||
|
.paymentEntityToPayment(paymentJpaRepository
|
||||||
|
.save(paymentDataAccessMapper.paymentToPaymentEntity(payment)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Payment> findByOrderId(UUID orderId) {
|
||||||
|
return paymentJpaRepository.findByOrderId(orderId)
|
||||||
|
.map(paymentDataAccessMapper::paymentEntityToPayment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.food.order.system.payment.data.access.payment.entity;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentStatus;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table(name = "payments")
|
||||||
|
@Entity
|
||||||
|
public class PaymentEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private UUID id;
|
||||||
|
private UUID customerId;
|
||||||
|
private UUID orderId;
|
||||||
|
private BigDecimal price;
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private PaymentStatus status;
|
||||||
|
private ZonedDateTime createdAt;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
PaymentEntity that = (PaymentEntity) o;
|
||||||
|
return id.equals(that.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.food.order.system.payment.data.access.payment.exception;
|
||||||
|
|
||||||
|
public class PaymentDataaccessException extends RuntimeException {
|
||||||
|
|
||||||
|
public PaymentDataaccessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.food.order.system.payment.data.access.payment.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.payment.entity.PaymentEntity;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.PaymentId;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import com.food.order.sysyem.valueobject.OrderId;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PaymentDataAccessMapper {
|
||||||
|
|
||||||
|
public PaymentEntity paymentToPaymentEntity(Payment payment) {
|
||||||
|
return PaymentEntity.builder()
|
||||||
|
.id(payment.getId().getValue())
|
||||||
|
.customerId(payment.getCustomerId().getValue())
|
||||||
|
.orderId(payment.getOrderId().getValue())
|
||||||
|
.price(payment.getPrice().getAmount())
|
||||||
|
.status(payment.getStatus())
|
||||||
|
.createdAt(payment.getCreatedAt())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Payment paymentEntityToPayment(PaymentEntity paymentEntity) {
|
||||||
|
return Payment.builder()
|
||||||
|
.id(new PaymentId(paymentEntity.getId()))
|
||||||
|
.customerId(new CustomerId(paymentEntity.getCustomerId()))
|
||||||
|
.orderId(new OrderId(paymentEntity.getOrderId()))
|
||||||
|
.price(new Money(paymentEntity.getPrice()))
|
||||||
|
.createdAt(paymentEntity.getCreatedAt())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.food.order.system.payment.data.access.payment.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.data.access.payment.entity.PaymentEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PaymentJpaRepository extends JpaRepository<PaymentEntity, UUID> {
|
||||||
|
|
||||||
|
Optional<PaymentEntity> findByOrderId(UUID orderId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-domain</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-application-service</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>common-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-tx</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-domain-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.food.order.system.payment.application.service;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.dto.PaymentRequest;
|
||||||
|
import com.food.order.system.payment.application.service.exception.PaymentApplicationServiceException;
|
||||||
|
import com.food.order.system.payment.application.service.mapper.PaymentDataMapper;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.CreditEntryRepository;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.CreditHistoryRepository;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.repository.PaymentRepository;
|
||||||
|
import com.food.order.system.payment.service.domain.PaymentDomainService;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentRequestHelper {
|
||||||
|
private final PaymentDomainService paymentDomainService;
|
||||||
|
private final PaymentDataMapper paymentDataMapper;
|
||||||
|
private final PaymentRepository paymentRepository;
|
||||||
|
private final CreditEntryRepository creditEntryRepository;
|
||||||
|
private final CreditHistoryRepository creditHistoryRepository;
|
||||||
|
|
||||||
|
private final DomainEventPublisher<PaymentCompletedEvent> publisher;
|
||||||
|
private final DomainEventPublisher<PaymentCancelledEvent> publisherCancelled;
|
||||||
|
|
||||||
|
private final DomainEventPublisher<PaymentFailedEvent> failedEventDomainEventPublisher;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public PaymentEvent persistPayment(PaymentRequest paymentRequest) {
|
||||||
|
log.info("Received payment complete event for id : {}", paymentRequest.getOrderId());
|
||||||
|
var payment = paymentDataMapper.paymentRequestModelToPayment(paymentRequest);
|
||||||
|
var creditEntry = getCreditEntry(payment.getCustomerId());
|
||||||
|
var creditHistory = getCreditHistory(payment.getCustomerId());
|
||||||
|
List<String> failureMessage = new ArrayList<>();
|
||||||
|
|
||||||
|
var paymentEvent = paymentDomainService.validateAndInitializePayment
|
||||||
|
(payment, creditEntry, creditHistory, failureMessage,publisher,failedEventDomainEventPublisher);
|
||||||
|
|
||||||
|
persistDbObject(payment, creditEntry, creditHistory, failureMessage);
|
||||||
|
return paymentEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PaymentEvent persistCancelPayment(PaymentRequest paymentRequest) {
|
||||||
|
log.info("Received payment cancel event for id : {}", paymentRequest.getOrderId());
|
||||||
|
var payment = paymentRepository.findByOrderId
|
||||||
|
(UUID.fromString(paymentRequest.getOrderId())).orElseThrow(
|
||||||
|
() -> new PaymentApplicationServiceException("Payment not found"));
|
||||||
|
var creditEntry = getCreditEntry(payment.getCustomerId());
|
||||||
|
var creditHistory = getCreditHistory(payment.getCustomerId());
|
||||||
|
List<String> failureMessage = new ArrayList<>();
|
||||||
|
var paymentEvent = paymentDomainService.validateAndCancelledPayment
|
||||||
|
(payment, creditEntry, creditHistory, failureMessage,publisherCancelled,failedEventDomainEventPublisher);
|
||||||
|
|
||||||
|
persistDbObject(payment, creditEntry, creditHistory, failureMessage);
|
||||||
|
return paymentEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void persistDbObject(Payment payment, CreditEntry creditEntry, List<CreditHistory> creditHistory, List<String> failureMessage) {
|
||||||
|
paymentRepository.save(payment);
|
||||||
|
if (failureMessage.isEmpty()) {
|
||||||
|
creditEntryRepository.save(creditEntry);
|
||||||
|
creditHistoryRepository.save(creditHistory.get(creditHistory.size() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<CreditHistory> getCreditHistory(CustomerId customerId) {
|
||||||
|
return creditHistoryRepository.findByCustomerId(customerId).orElseThrow(
|
||||||
|
() -> new PaymentApplicationServiceException("No credit history found for customer id : " + customerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private CreditEntry getCreditEntry(CustomerId customerId) {
|
||||||
|
return creditEntryRepository.findByCustomerId(customerId).orElseThrow(
|
||||||
|
() -> new PaymentApplicationServiceException("Credit entry not found for customer id : " + customerId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.food.order.system.payment.application.service;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.dto.PaymentRequest;
|
||||||
|
import com.food.order.system.payment.application.service.ports.input.message.listener.PaymentRequestMessageListener;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentEvent;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentRequestMessageListenerImpl implements PaymentRequestMessageListener {
|
||||||
|
|
||||||
|
private final PaymentRequestHelper paymentRequestHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void completePayment(PaymentRequest paymentRequest) {
|
||||||
|
var event = paymentRequestHelper.persistPayment(paymentRequest);
|
||||||
|
fireEvent(event);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void cancelPayment(PaymentRequest paymentRequest) {
|
||||||
|
var event = paymentRequestHelper.persistCancelPayment(paymentRequest);
|
||||||
|
fireEvent(event);
|
||||||
|
}
|
||||||
|
private void fireEvent(PaymentEvent event) {
|
||||||
|
|
||||||
|
log.info("Firing event : {}", event);
|
||||||
|
event.fire();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.food.order.system.payment.application.service.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "payment-service")
|
||||||
|
public class PaymentServiceConfigData {
|
||||||
|
|
||||||
|
private String paymentRequestTopicName;
|
||||||
|
private String paymentResponseTopicName;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.food.order.system.payment.application.service.dto;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentOrderStatus;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PaymentRequest {
|
||||||
|
private String id;
|
||||||
|
private String sagaId;
|
||||||
|
private String orderId;
|
||||||
|
private String customerId;
|
||||||
|
private BigDecimal price;
|
||||||
|
private Instant createdAt;
|
||||||
|
private PaymentOrderStatus status;
|
||||||
|
|
||||||
|
public void setStatus(PaymentOrderStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.food.order.system.payment.application.service.exception;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.exception.DomainException;
|
||||||
|
|
||||||
|
public class PaymentApplicationServiceException extends DomainException {
|
||||||
|
|
||||||
|
public PaymentApplicationServiceException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentApplicationServiceException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.food.order.system.payment.application.service.mapper;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.dto.PaymentRequest;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import com.food.order.sysyem.valueobject.OrderId;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PaymentDataMapper {
|
||||||
|
|
||||||
|
|
||||||
|
public Payment paymentRequestModelToPayment(PaymentRequest paymentRequest) {
|
||||||
|
return Payment.builder()
|
||||||
|
.customerId(new CustomerId(UUID.fromString(paymentRequest.getCustomerId())))
|
||||||
|
.orderId(new OrderId(UUID.fromString(paymentRequest.getOrderId())))
|
||||||
|
.price(new Money(paymentRequest.getPrice()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.input.message.listener;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.application.service.dto.PaymentRequest;
|
||||||
|
|
||||||
|
public interface PaymentRequestMessageListener {
|
||||||
|
void completePayment(PaymentRequest paymentRequest);
|
||||||
|
void cancelPayment(PaymentRequest paymentRequest);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.message.publisher;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
public interface PaymentCancelledMessagePublisher extends DomainEventPublisher<PaymentCancelledEvent> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.message.publisher;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
public interface PaymentCompletedMessagePublisher extends DomainEventPublisher<PaymentCompletedEvent> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.message.publisher;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
public interface PaymentFailedMessagePublisher extends DomainEventPublisher<PaymentFailedEvent> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface CreditEntryRepository {
|
||||||
|
CreditEntry save(CreditEntry creditEntry);
|
||||||
|
Optional<CreditEntry> findByCustomerId(CustomerId orderId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface CreditHistoryRepository {
|
||||||
|
CreditHistory save(CreditHistory creditHistory);
|
||||||
|
Optional<List<CreditHistory>> findByCustomerId(CustomerId orderId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.food.order.system.payment.application.service.ports.output.repository;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface PaymentRepository {
|
||||||
|
Payment save(Payment payment);
|
||||||
|
Optional<Payment> findByOrderId(UUID orderId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
22
payment-service/payment-domain/payment-domain-core/pom.xml
Normal file
22
payment-service/payment-domain/payment-domain-core/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-domain</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-domain-core</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>common-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.food.order.system.payment.service.domain;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PaymentDomainService {
|
||||||
|
|
||||||
|
PaymentEvent validateAndInitializePayment( Payment paymentEvent,
|
||||||
|
CreditEntry creditEntry,
|
||||||
|
List<CreditHistory> creditHistory,
|
||||||
|
List<String> failureMessages,
|
||||||
|
DomainEventPublisher<PaymentCompletedEvent> publisher,
|
||||||
|
DomainEventPublisher<PaymentFailedEvent> failedEventDomainEventPublisher);
|
||||||
|
|
||||||
|
PaymentEvent validateAndCancelledPayment( Payment paymentEvent,
|
||||||
|
CreditEntry creditEntry,
|
||||||
|
List<CreditHistory> creditHistory,
|
||||||
|
List<String> failureMessages,
|
||||||
|
DomainEventPublisher<PaymentCancelledEvent> publisher,
|
||||||
|
DomainEventPublisher<PaymentFailedEvent> failedEventDomainEventPublisher);
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package com.food.order.system.payment.service.domain;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditEntry;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.CreditHistory;
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.CreditHistoryId;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.TransactionType;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentStatus;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.food.order.sysyem.DomainConstants.UTC;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class PaymentDomainServiceImpl implements PaymentDomainService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaymentEvent validateAndInitializePayment(Payment payment,
|
||||||
|
CreditEntry creditEntry,
|
||||||
|
List<CreditHistory> creditHistory,
|
||||||
|
List<String> failureMessages,
|
||||||
|
DomainEventPublisher<PaymentCompletedEvent> publisher,
|
||||||
|
DomainEventPublisher<PaymentFailedEvent> failedPublisher) {
|
||||||
|
payment.validatePayment(failureMessages);
|
||||||
|
payment.initializePayment();
|
||||||
|
validateCreditEntry(payment,creditEntry,failureMessages);
|
||||||
|
subtractCreditEntry(payment,creditEntry);
|
||||||
|
updateCreditHistory(payment,creditHistory, TransactionType.DEBIT);
|
||||||
|
validateCreditHistory(creditEntry,creditHistory,failureMessages);
|
||||||
|
|
||||||
|
if (failureMessages.isEmpty()) {
|
||||||
|
log.info("Payment is valid and initialized");
|
||||||
|
payment.updateStatus(PaymentStatus.COMPLETED);
|
||||||
|
return new PaymentCompletedEvent(payment, ZonedDateTime.now(ZoneId.of(UTC)),publisher );
|
||||||
|
} else {
|
||||||
|
log.info("Payment is invalid and not initialized");
|
||||||
|
payment.updateStatus(PaymentStatus.FAILED);
|
||||||
|
return new PaymentFailedEvent(payment, ZonedDateTime.now(ZoneId.of(UTC)), failureMessages,failedPublisher);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaymentEvent validateAndCancelledPayment(Payment payment,
|
||||||
|
CreditEntry creditEntry,
|
||||||
|
List<CreditHistory> creditHistory,
|
||||||
|
List<String> failureMessages,
|
||||||
|
DomainEventPublisher<PaymentCancelledEvent> publisher,
|
||||||
|
DomainEventPublisher<PaymentFailedEvent> failedPublisher) {
|
||||||
|
|
||||||
|
payment.validatePayment(failureMessages);
|
||||||
|
addCreditEntry(payment,creditEntry);
|
||||||
|
updateCreditHistory(payment,creditHistory, TransactionType.CREDIT);
|
||||||
|
|
||||||
|
if (failureMessages.isEmpty()) {
|
||||||
|
log.info("Payment is valid and cancelled");
|
||||||
|
payment.updateStatus(PaymentStatus.CANCELED);
|
||||||
|
return new PaymentCancelledEvent(payment, ZonedDateTime.now(ZoneId.of(UTC)),publisher);
|
||||||
|
} else {
|
||||||
|
log.info("Payment is invalid and not cancelled");
|
||||||
|
payment.updateStatus(PaymentStatus.FAILED);
|
||||||
|
return new PaymentFailedEvent(payment, ZonedDateTime.now(ZoneId.of(UTC)), failureMessages,failedPublisher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCreditEntry(Payment payment, CreditEntry creditEntry) {
|
||||||
|
creditEntry.addCreditAmount(payment.getPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCreditHistory(CreditEntry creditEntry, List<CreditHistory> creditHistory, List<String> failureMessages) {
|
||||||
|
var totalCreditHistory = getTotalHistoryAmount(creditHistory, TransactionType.CREDIT);
|
||||||
|
var totalDebitHistory = getTotalHistoryAmount(creditHistory, TransactionType.DEBIT);
|
||||||
|
|
||||||
|
if (totalDebitHistory.isGreaterThan(totalCreditHistory)) {
|
||||||
|
failureMessages.add("Customer id " + creditEntry.getCustomerId() + " has insufficient credit");
|
||||||
|
log.error("Customer id {} has insufficient credit", creditEntry.getCustomerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!creditEntry.getTotalCreditAmount().equals(totalCreditHistory.subtract(totalDebitHistory))) {
|
||||||
|
failureMessages.add("Customer id " + creditEntry.getCustomerId() + " has total is not equal to credit history");
|
||||||
|
log.error("Customer id {} has total is not equal to credit history", creditEntry.getCustomerId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Money getTotalHistoryAmount(List<CreditHistory> creditHistory, TransactionType transactionType) {
|
||||||
|
return creditHistory.stream()
|
||||||
|
.filter(history -> transactionType.equals(history.getTransactionType()))
|
||||||
|
.map(CreditHistory::getAmount)
|
||||||
|
.reduce(Money.ZERO, Money::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCreditHistory(Payment payment, List<CreditHistory> creditHistory, TransactionType transactionType) {
|
||||||
|
creditHistory.add(
|
||||||
|
CreditHistory.builder()
|
||||||
|
.id(new CreditHistoryId(UUID.randomUUID()))
|
||||||
|
.customerId(payment.getCustomerId())
|
||||||
|
.amount(payment.getPrice())
|
||||||
|
.transactionType(transactionType)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void subtractCreditEntry(Payment payment, CreditEntry creditEntry) {
|
||||||
|
creditEntry.subtractCreditAmount(payment.getPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCreditEntry(Payment payment, CreditEntry creditEntry, List<String> failureMessages) {
|
||||||
|
if(payment.getPrice().isGreaterThan(creditEntry.getTotalCreditAmount())){
|
||||||
|
failureMessages.add("Customer id "+ payment.getCustomerId() + " , has insufficient credit amount" +
|
||||||
|
creditEntry.getTotalCreditAmount() + " to pay for order id " + payment.getOrderId());
|
||||||
|
log.error("Payment price is greater than credit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.entity;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.CreditEntryId;
|
||||||
|
import com.food.order.sysyem.entity.BaseEntity;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
|
||||||
|
public class CreditEntry extends BaseEntity<CreditEntryId> {
|
||||||
|
|
||||||
|
private final CustomerId customerId;
|
||||||
|
|
||||||
|
private Money totalCreditAmount;
|
||||||
|
|
||||||
|
public void addCreditAmount(Money creditAmount) {
|
||||||
|
totalCreditAmount = totalCreditAmount.add(creditAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subtractCreditAmount(Money creditAmount) {
|
||||||
|
totalCreditAmount = totalCreditAmount.subtract(creditAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private CreditEntry(Builder builder) {
|
||||||
|
setId(builder.creditEntryId);
|
||||||
|
customerId = builder.customerId;
|
||||||
|
totalCreditAmount = builder.totalCreditAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomerId getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Money getTotalCreditAmount() {
|
||||||
|
return totalCreditAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private CreditEntryId creditEntryId;
|
||||||
|
private CustomerId customerId;
|
||||||
|
private Money totalCreditAmount;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder id(CreditEntryId val) {
|
||||||
|
creditEntryId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder customerId(CustomerId val) {
|
||||||
|
customerId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder totalCreditAmount(Money val) {
|
||||||
|
totalCreditAmount = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditEntry build() {
|
||||||
|
return new CreditEntry(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.entity;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.CreditHistoryId;
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.TransactionType;
|
||||||
|
import com.food.order.sysyem.entity.BaseEntity;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
|
||||||
|
public class CreditHistory extends BaseEntity<CreditHistoryId> {
|
||||||
|
|
||||||
|
private final CustomerId customerId;
|
||||||
|
private final Money amount;
|
||||||
|
private final TransactionType transactionType;
|
||||||
|
|
||||||
|
private CreditHistory(Builder builder) {
|
||||||
|
setId(builder.creditHistoryId);
|
||||||
|
customerId = builder.customerId;
|
||||||
|
amount = builder.amount;
|
||||||
|
transactionType = builder.transactionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CustomerId getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Money getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransactionType getTransactionType() {
|
||||||
|
return transactionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private CreditHistoryId creditHistoryId;
|
||||||
|
private CustomerId customerId;
|
||||||
|
private Money amount;
|
||||||
|
private TransactionType transactionType;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder id(CreditHistoryId val) {
|
||||||
|
creditHistoryId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder customerId(CustomerId val) {
|
||||||
|
customerId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder amount(Money val) {
|
||||||
|
amount = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder transactionType(TransactionType val) {
|
||||||
|
transactionType = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditHistory build() {
|
||||||
|
return new CreditHistory(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.entity;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.valueobject.PaymentId;
|
||||||
|
import com.food.order.sysyem.entity.AggregateRoot;
|
||||||
|
import com.food.order.sysyem.valueobject.CustomerId;
|
||||||
|
import com.food.order.sysyem.valueobject.Money;
|
||||||
|
import com.food.order.sysyem.valueobject.OrderId;
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentStatus;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Payment extends AggregateRoot<PaymentId> {
|
||||||
|
|
||||||
|
private final OrderId orderId;
|
||||||
|
private final CustomerId customerId;
|
||||||
|
private final Money price;
|
||||||
|
|
||||||
|
private PaymentStatus status;
|
||||||
|
private ZonedDateTime createdAt;
|
||||||
|
|
||||||
|
public void initializePayment(){
|
||||||
|
setId(new PaymentId(UUID.randomUUID()));
|
||||||
|
createdAt = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validatePayment(List<String > failureMessages){
|
||||||
|
if (Objects.isNull(price) || !price.isGreaterThanZero()){
|
||||||
|
failureMessages.add("Payment price must be greater than zero");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStatus ( PaymentStatus status ) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Payment(Builder builder) {
|
||||||
|
setId(builder.paymentId);
|
||||||
|
orderId = builder.orderId;
|
||||||
|
customerId = builder.customerId;
|
||||||
|
price = builder.price;
|
||||||
|
status = builder.status;
|
||||||
|
createdAt = builder.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OrderId getOrderId() {
|
||||||
|
return orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomerId getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Money getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private PaymentId paymentId;
|
||||||
|
private OrderId orderId;
|
||||||
|
private CustomerId customerId;
|
||||||
|
private Money price;
|
||||||
|
private PaymentStatus status;
|
||||||
|
private ZonedDateTime createdAt;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder id(PaymentId val) {
|
||||||
|
paymentId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder orderId(OrderId val) {
|
||||||
|
orderId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder customerId(CustomerId val) {
|
||||||
|
customerId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder price(Money val) {
|
||||||
|
price = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder status(PaymentStatus val) {
|
||||||
|
status = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder createdAt(ZonedDateTime val) {
|
||||||
|
createdAt = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Payment build() {
|
||||||
|
return new Payment(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.event;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class PaymentCancelledEvent extends PaymentEvent{
|
||||||
|
|
||||||
|
private final DomainEventPublisher<PaymentCancelledEvent> publisher;
|
||||||
|
|
||||||
|
public PaymentCancelledEvent(Payment payment, ZonedDateTime createdAt, DomainEventPublisher<PaymentCancelledEvent> publisher) {
|
||||||
|
super(payment, createdAt, Collections.emptyList());
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.event;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class PaymentCompletedEvent extends PaymentEvent{
|
||||||
|
|
||||||
|
private final DomainEventPublisher<PaymentCompletedEvent> publisher;
|
||||||
|
|
||||||
|
public PaymentCompletedEvent(Payment payment,
|
||||||
|
ZonedDateTime createdAt,
|
||||||
|
DomainEventPublisher<PaymentCompletedEvent> publisher) {
|
||||||
|
super(payment, createdAt , Collections.emptyList());
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.event;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.sysyem.event.DomainEvent;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class PaymentEvent implements DomainEvent<Payment> {
|
||||||
|
private final Payment payment;
|
||||||
|
private final ZonedDateTime createdAt;
|
||||||
|
private final List<String> failureMessages;
|
||||||
|
|
||||||
|
public PaymentEvent(Payment payment, ZonedDateTime createdAt, List<String> failureMessages) {
|
||||||
|
this.payment = payment;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.failureMessages = failureMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Payment getPayment() {
|
||||||
|
return payment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getFailureMessages() {
|
||||||
|
return failureMessages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.event;
|
||||||
|
|
||||||
|
import com.food.order.system.payment.service.domain.entity.Payment;
|
||||||
|
import com.food.order.sysyem.event.publisher.DomainEventPublisher;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PaymentFailedEvent extends PaymentEvent{
|
||||||
|
|
||||||
|
private final DomainEventPublisher<PaymentFailedEvent> publisher;
|
||||||
|
|
||||||
|
public PaymentFailedEvent(Payment payment, ZonedDateTime createdAt, List<String> failureMessages,
|
||||||
|
DomainEventPublisher<PaymentFailedEvent> publisher) {
|
||||||
|
super(payment, createdAt, failureMessages);
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire() {
|
||||||
|
publisher.publish(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.exception;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.exception.DomainException;
|
||||||
|
|
||||||
|
public class PayemntDomainException extends DomainException {
|
||||||
|
public PayemntDomainException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PayemntDomainException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.exception;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.exception.DomainException;
|
||||||
|
|
||||||
|
public class PaymentNotFoundException extends DomainException {
|
||||||
|
public PaymentNotFoundException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentNotFoundException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.valueobject;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.valueobject.BaseId;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CreditEntryId extends BaseId<UUID> {
|
||||||
|
public CreditEntryId(UUID value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.valueobject;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.valueobject.BaseId;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CreditHistoryId extends BaseId<UUID> {
|
||||||
|
|
||||||
|
public CreditHistoryId(UUID value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.valueobject;
|
||||||
|
|
||||||
|
import com.food.order.sysyem.valueobject.BaseId;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PaymentId extends BaseId<UUID> {
|
||||||
|
public PaymentId(UUID id) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.food.order.system.payment.service.domain.valueobject;
|
||||||
|
|
||||||
|
public enum TransactionType {
|
||||||
|
DEBIT, CREDIT
|
||||||
|
}
|
||||||
20
payment-service/payment-domain/pom.xml
Normal file
20
payment-service/payment-domain/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-service</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-domain</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>payment-domain-core</module>
|
||||||
|
<module>payment-application-service</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
35
payment-service/payment-messaging/pom.xml
Normal file
35
payment-service/payment-messaging/pom.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>payment-service</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-messaging</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-application-service</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>kafka-producer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>kafka-consumer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>kafka-model</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.food.order.system.payment.messaging.listener.kafka;
|
||||||
|
|
||||||
|
import com.food.order.system.kafka.consumer.KafkaConsumer;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
||||||
|
import com.food.order.system.payment.application.service.ports.input.message.listener.PaymentRequestMessageListener;
|
||||||
|
import com.food.order.system.payment.messaging.mapper.PaymentMessagingDataMapper;
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentOrderStatus;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
import org.springframework.kafka.support.KafkaHeaders;
|
||||||
|
import org.springframework.messaging.handler.annotation.Header;
|
||||||
|
import org.springframework.messaging.handler.annotation.Payload;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentRequestKafkaListener implements KafkaConsumer<PaymentRequestAvroModel> {
|
||||||
|
|
||||||
|
private final PaymentMessagingDataMapper paymentMessagingDataMapper;
|
||||||
|
private final PaymentRequestMessageListener paymentRequestMessageListener;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@KafkaListener(id = "${kafka-consumer-config.payment-consumer-group-id}",
|
||||||
|
topics = "${payment-service.payment-request-topic-name}")
|
||||||
|
public void receive(@Payload List<PaymentRequestAvroModel> messages,
|
||||||
|
@Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) List<String> keys,
|
||||||
|
@Header(KafkaHeaders.RECEIVED_PARTITION_ID) List<Integer> partitions,
|
||||||
|
@Header(KafkaHeaders.OFFSET) List<Long> offsets) {
|
||||||
|
log.info("{} number of payment requests received with keys:{}, partitions:{} and offsets: {}",
|
||||||
|
messages.size(),
|
||||||
|
keys.toString(),
|
||||||
|
partitions.toString(),
|
||||||
|
offsets.toString());
|
||||||
|
|
||||||
|
messages.forEach(paymentRequestAvroModel -> {
|
||||||
|
if (PaymentOrderStatus.PENDING.name().equalsIgnoreCase(paymentRequestAvroModel.getPaymentOrderStatus().name())) {
|
||||||
|
log.info("Processing payment for order id: {}", paymentRequestAvroModel.getOrderId());
|
||||||
|
paymentRequestMessageListener.completePayment(paymentMessagingDataMapper
|
||||||
|
.paymentRequestAvroModelToPaymentRequest(paymentRequestAvroModel));
|
||||||
|
} else if(PaymentOrderStatus.CANCELLED.name().equalsIgnoreCase(paymentRequestAvroModel.getPaymentOrderStatus().name())) {
|
||||||
|
log.info("Cancelling payment for order id: {}", paymentRequestAvroModel.getOrderId());
|
||||||
|
paymentRequestMessageListener.cancelPayment(paymentMessagingDataMapper
|
||||||
|
.paymentRequestAvroModelToPaymentRequest(paymentRequestAvroModel));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.food.order.system.payment.messaging.mapper;
|
||||||
|
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentRequestAvroModel;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentStatus;
|
||||||
|
import com.food.order.system.payment.application.service.dto.PaymentRequest;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import com.food.order.sysyem.valueobject.PaymentOrderStatus;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PaymentMessagingDataMapper {
|
||||||
|
|
||||||
|
public PaymentResponseAvroModel paymentCompletedEventToPaymentResponseAvroModel(PaymentCompletedEvent paymentCompletedEvent) {
|
||||||
|
return PaymentResponseAvroModel.newBuilder()
|
||||||
|
.setId(UUID.randomUUID().toString())
|
||||||
|
.setSagaId("")
|
||||||
|
.setPaymentId(paymentCompletedEvent.getPayment().getId().getValue().toString())
|
||||||
|
.setCustomerId(paymentCompletedEvent.getPayment().getCustomerId().getValue().toString())
|
||||||
|
.setOrderId(paymentCompletedEvent.getPayment().getOrderId().getValue().toString())
|
||||||
|
.setPrice(paymentCompletedEvent.getPayment().getPrice().getAmount())
|
||||||
|
.setCreatedAt(paymentCompletedEvent.getPayment().getCreatedAt().toInstant())
|
||||||
|
.setPaymentStatus(PaymentStatus.valueOf(paymentCompletedEvent.getPayment().getStatus().name()))
|
||||||
|
.setFailureMessages(paymentCompletedEvent.getFailureMessages())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentResponseAvroModel paymentCancelEventToPaymentResponseAvroModel(PaymentCancelledEvent paymentCancelledEvent) {
|
||||||
|
return PaymentResponseAvroModel.newBuilder()
|
||||||
|
.setId(UUID.randomUUID().toString())
|
||||||
|
.setSagaId("")
|
||||||
|
.setPaymentId(paymentCancelledEvent.getPayment().getId().getValue().toString())
|
||||||
|
.setCustomerId(paymentCancelledEvent.getPayment().getCustomerId().getValue().toString())
|
||||||
|
.setOrderId(paymentCancelledEvent.getPayment().getOrderId().getValue().toString())
|
||||||
|
.setPrice(paymentCancelledEvent.getPayment().getPrice().getAmount())
|
||||||
|
.setCreatedAt(paymentCancelledEvent.getPayment().getCreatedAt().toInstant())
|
||||||
|
.setPaymentStatus(PaymentStatus.valueOf(paymentCancelledEvent.getPayment().getStatus().name()))
|
||||||
|
.setFailureMessages(paymentCancelledEvent.getFailureMessages())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentResponseAvroModel paymentFailedEventToPaymentResponseAvroModel(PaymentFailedEvent paymentFailedEvent) {
|
||||||
|
return PaymentResponseAvroModel.newBuilder()
|
||||||
|
.setId(UUID.randomUUID().toString())
|
||||||
|
.setSagaId("")
|
||||||
|
.setPaymentId(paymentFailedEvent.getPayment().getId().getValue().toString())
|
||||||
|
.setCustomerId(paymentFailedEvent.getPayment().getCustomerId().getValue().toString())
|
||||||
|
.setOrderId(paymentFailedEvent.getPayment().getOrderId().getValue().toString())
|
||||||
|
.setPrice(paymentFailedEvent.getPayment().getPrice().getAmount())
|
||||||
|
.setCreatedAt(paymentFailedEvent.getPayment().getCreatedAt().toInstant())
|
||||||
|
.setPaymentStatus(PaymentStatus.valueOf(paymentFailedEvent.getPayment().getStatus().name()))
|
||||||
|
.setFailureMessages(paymentFailedEvent.getFailureMessages())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentRequest paymentRequestAvroModelToPaymentRequest(PaymentRequestAvroModel paymentRequestAvroModel) {
|
||||||
|
return PaymentRequest.builder()
|
||||||
|
.id(paymentRequestAvroModel.getId())
|
||||||
|
.sagaId(paymentRequestAvroModel.getSagaId())
|
||||||
|
.customerId(paymentRequestAvroModel.getCustomerId())
|
||||||
|
.orderId(paymentRequestAvroModel.getOrderId())
|
||||||
|
.price(paymentRequestAvroModel.getPrice())
|
||||||
|
.createdAt(paymentRequestAvroModel.getCreatedAt())
|
||||||
|
.status(PaymentOrderStatus.valueOf(paymentRequestAvroModel.getPaymentOrderStatus().name()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.food.order.system.payment.messaging.publisher.kafka;
|
||||||
|
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
|
import com.food.order.system.payment.application.service.config.PaymentServiceConfigData;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.message.publisher.PaymentCancelledMessagePublisher;
|
||||||
|
import com.food.order.system.payment.messaging.mapper.PaymentMessagingDataMapper;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCancelledEvent;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentCancelledKafkaMessagePublisher implements PaymentCancelledMessagePublisher {
|
||||||
|
|
||||||
|
private final PaymentMessagingDataMapper paymentDataMapper;
|
||||||
|
private final KafkaProducer<String , PaymentResponseAvroModel> kafkaProducer;
|
||||||
|
private final PaymentServiceConfigData paymentServiceConfigData;
|
||||||
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(PaymentCancelledEvent event) {
|
||||||
|
log.info("Publishing payment cancelled event to kafka");
|
||||||
|
var orderId = event.getPayment().getOrderId().getValue().toString();
|
||||||
|
try {
|
||||||
|
var paymentResponseAvroModel =
|
||||||
|
paymentDataMapper.paymentCancelEventToPaymentResponseAvroModel(event);
|
||||||
|
|
||||||
|
kafkaProducer.send(paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
orderId,
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
kafkaMessageHelper.getKafkaCallBack(
|
||||||
|
paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
orderId,
|
||||||
|
"PaymentResponseAvroModel"));
|
||||||
|
|
||||||
|
log.info("Published payment cancelled event to kafka");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while publishing payment cancelled event to kafka", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.food.order.system.payment.messaging.publisher.kafka;
|
||||||
|
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
|
import com.food.order.system.payment.application.service.config.PaymentServiceConfigData;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.message.publisher.PaymentCompletedMessagePublisher;
|
||||||
|
import com.food.order.system.payment.messaging.mapper.PaymentMessagingDataMapper;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentCompletedEvent;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentCompletedKafkaMessagePublisher implements PaymentCompletedMessagePublisher {
|
||||||
|
|
||||||
|
private final PaymentMessagingDataMapper paymentDataMapper;
|
||||||
|
private final KafkaProducer<String , PaymentResponseAvroModel> kafkaProducer;
|
||||||
|
private final PaymentServiceConfigData paymentServiceConfigData;
|
||||||
|
|
||||||
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(PaymentCompletedEvent event) {
|
||||||
|
log.info("Publishing payment completed event to kafka");
|
||||||
|
var orderId = event.getPayment().getOrderId().getValue().toString();
|
||||||
|
try {
|
||||||
|
var paymentResponseAvroModel =
|
||||||
|
paymentDataMapper.paymentCompletedEventToPaymentResponseAvroModel(event);
|
||||||
|
|
||||||
|
kafkaProducer.send(paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
orderId,
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
kafkaMessageHelper.getKafkaCallBack(
|
||||||
|
paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
orderId,
|
||||||
|
"PaymentResponseAvroModel"));
|
||||||
|
|
||||||
|
log.info("Published payment completed event to kafka");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while publishing payment completed event to kafka", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.food.order.system.payment.messaging.publisher.kafka;
|
||||||
|
|
||||||
|
import com.food.order.system.kafka.order.avro.model.PaymentResponseAvroModel;
|
||||||
|
import com.food.order.system.kafka.producer.KafkaMessageHelper;
|
||||||
|
import com.food.order.system.kafka.producer.service.KafkaProducer;
|
||||||
|
import com.food.order.system.payment.application.service.config.PaymentServiceConfigData;
|
||||||
|
import com.food.order.system.payment.application.service.ports.output.message.publisher.PaymentFailedMessagePublisher;
|
||||||
|
import com.food.order.system.payment.messaging.mapper.PaymentMessagingDataMapper;
|
||||||
|
import com.food.order.system.payment.service.domain.event.PaymentFailedEvent;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentFailedKafkaMessagePublisher implements PaymentFailedMessagePublisher {
|
||||||
|
|
||||||
|
private final PaymentMessagingDataMapper paymentDataMapper;
|
||||||
|
private final KafkaProducer<String , PaymentResponseAvroModel> kafkaProducer;
|
||||||
|
private final PaymentServiceConfigData paymentServiceConfigData;
|
||||||
|
|
||||||
|
private final KafkaMessageHelper kafkaMessageHelper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(PaymentFailedEvent event) {
|
||||||
|
log.info("Publishing payment failed event to kafka");
|
||||||
|
var orderId = event.getPayment().getOrderId().getValue().toString();
|
||||||
|
try {
|
||||||
|
var paymentResponseAvroModel =
|
||||||
|
paymentDataMapper.paymentFailedEventToPaymentResponseAvroModel(event);
|
||||||
|
|
||||||
|
kafkaProducer.send(paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
orderId,
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
kafkaMessageHelper.getKafkaCallBack(
|
||||||
|
paymentServiceConfigData.getPaymentResponseTopicName(),
|
||||||
|
paymentResponseAvroModel,
|
||||||
|
orderId,
|
||||||
|
"PaymentResponseAvroModel"));
|
||||||
|
|
||||||
|
log.info("Published payment failed event to kafka");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while publishing payment failed event to kafka", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
payment-service/pom.xml
Normal file
22
payment-service/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>food-ordering-system</artifactId>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>payment-service</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>payment-domain</module>
|
||||||
|
<module>payment-dataaccess</module>
|
||||||
|
<module>payment-messaging</module>
|
||||||
|
<module>payment-container</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
34
pom.xml
34
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<version>2.7.1</version>
|
<version>2.6.7</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<module>infrastructure</module>
|
<module>infrastructure</module>
|
||||||
<module>infrastructure/kafka</module>
|
<module>infrastructure/kafka</module>
|
||||||
<module>customer-service</module>
|
<module>customer-service</module>
|
||||||
|
<module>payment-service</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
@@ -41,12 +42,43 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-domain</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.food.order</groupId>
|
<groupId>com.food.order</groupId>
|
||||||
<artifactId>order-app</artifactId>
|
<artifactId>order-app</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-application-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-domain-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-dataaccess</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.food.order</groupId>
|
||||||
|
<artifactId>payment-messaging</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.food.order</groupId>
|
<groupId>com.food.order</groupId>
|
||||||
<artifactId>order-application-service</artifactId>
|
<artifactId>order-application-service</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user