-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entire Customer Module Integrated and Swagger also Intgrated
- Loading branch information
Showing
29 changed files
with
581 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...em/booking-core/src/main/java/org/ticketbooking/core/api/config/ApiApplicationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...okingSystem/booking-core/src/main/java/org/ticketbooking/core/dao/address/AddressDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
package org.ticketbooking.core.dao.address; | ||
|
||
import java.util.List; | ||
|
||
import org.ticketbooking.core.domain.user.AddressImpl; | ||
|
||
public interface AddressDao { | ||
void createAddress(AddressImpl address); | ||
void deleteAddress(Long id); | ||
AddressImpl fetchAddress(Long id); | ||
List<AddressImpl> fetchAddressByCustomer(Long customerId); | ||
//List<AddressImpl> fetchAddressByCustomer(Long customerId); | ||
void updateAddress(AddressImpl address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ng-core/src/main/java/org/ticketbooking/core/dao/customer/address/CustomerAddressDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.ticketbooking.core.dao.customer.address; | ||
|
||
import org.ticketbooking.core.domain.user.CustomerAddressImpl; | ||
|
||
|
||
|
||
public interface CustomerAddressDao{ | ||
void createCustomerAddress(CustomerAddressImpl customerAddress); | ||
} |
18 changes: 18 additions & 0 deletions
18
...ore/src/main/java/org/ticketbooking/core/dao/customer/address/CustomerAddressDaoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.ticketbooking.core.dao.customer.address; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
|
||
import org.springframework.stereotype.Repository; | ||
import org.ticketbooking.core.domain.user.CustomerAddressImpl; | ||
|
||
@Repository("customerAddressDao") | ||
public class CustomerAddressDaoImpl implements CustomerAddressDao{ | ||
|
||
@PersistenceContext | ||
EntityManager entityManager; | ||
|
||
public void createCustomerAddress(CustomerAddressImpl customerAddress){ | ||
entityManager.persist(customerAddress); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...stem/booking-core/src/main/java/org/ticketbooking/core/domain/common/audit/Auditable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.ticketbooking.core.domain.common.audit; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
|
||
@Embeddable | ||
public class Auditable implements Serializable{ | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = -2384592094387880727L; | ||
|
||
@Column(name="TBS_CREATED_DATE") | ||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date createdDate; | ||
|
||
@Column(name="TBS_UPDATED_DATE") | ||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date lastUpdatedDate; | ||
|
||
public Date getCreatedDate() { | ||
return createdDate; | ||
} | ||
|
||
public void setCreatedDate(Date createdDate) { | ||
this.createdDate = createdDate; | ||
} | ||
|
||
public Date getLastUpdatedDate() { | ||
return lastUpdatedDate; | ||
} | ||
|
||
public void setLastUpdatedDate(Date lastUpdatedDate) { | ||
this.lastUpdatedDate = lastUpdatedDate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Auditable [createdDate=" + createdDate + ", lastUpdatedDate=" | ||
+ lastUpdatedDate + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result | ||
+ ((createdDate == null) ? 0 : createdDate.hashCode()); | ||
result = prime * result | ||
+ ((lastUpdatedDate == null) ? 0 : lastUpdatedDate.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
Auditable other = (Auditable) obj; | ||
if (createdDate == null) { | ||
if (other.createdDate != null) | ||
return false; | ||
} else if (!createdDate.equals(other.createdDate)) | ||
return false; | ||
if (lastUpdatedDate == null) { | ||
if (other.lastUpdatedDate != null) | ||
return false; | ||
} else if (!lastUpdatedDate.equals(other.lastUpdatedDate)) | ||
return false; | ||
return true; | ||
} | ||
|
||
|
||
|
||
} |
70 changes: 70 additions & 0 deletions
70
...g-core/src/main/java/org/ticketbooking/core/domain/common/listener/AuditableListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.ticketbooking.core.domain.common.listener; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Date; | ||
|
||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.PrePersist; | ||
import javax.persistence.PreUpdate; | ||
|
||
import org.ticketbooking.core.domain.common.audit.Auditable; | ||
|
||
public class AuditableListener { | ||
|
||
@PrePersist | ||
public void setAuditableFieldforCreate(Object entity) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { | ||
if (entity.getClass().isAnnotationPresent(Entity.class)) { | ||
Field field = getSingleField(entity.getClass(), "auditable"); | ||
field.setAccessible(true); | ||
if (field.isAnnotationPresent(Embedded.class)) { | ||
Object auditable = field.get(entity); | ||
if (auditable == null) { | ||
field.set(entity, new Auditable()); | ||
auditable = field.get(entity); | ||
} | ||
Field temporalField = auditable.getClass().getDeclaredField("createdDate"); | ||
Field agentField = auditable.getClass().getDeclaredField("lastUpdatedDate"); | ||
setAuditValueTemporal(temporalField, auditable); | ||
setAuditValueTemporal(agentField, auditable); | ||
} | ||
} | ||
} | ||
|
||
@PreUpdate | ||
public void setAuditableFieldForUdate(Object entity) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException{ | ||
if (entity.getClass().isAnnotationPresent(Entity.class)) { | ||
Field field = getSingleField(entity.getClass(), "auditable"); | ||
field.setAccessible(true); | ||
if (field.isAnnotationPresent(Embedded.class)) { | ||
Object auditable = field.get(entity); | ||
if (auditable == null) { | ||
field.set(entity, new Auditable()); | ||
auditable = field.get(entity); | ||
} | ||
Field agentField = auditable.getClass().getDeclaredField("lastUpdatedDate"); | ||
setAuditValueTemporal(agentField, auditable); | ||
} | ||
} | ||
} | ||
|
||
|
||
private void setAuditValueTemporal(Field temporalField, Object auditable) throws IllegalArgumentException, IllegalAccessException { | ||
temporalField.setAccessible(true); | ||
temporalField.set(auditable, new Date()); | ||
} | ||
|
||
private Field getSingleField(Class<?> clazz, String fieldName) | ||
throws IllegalStateException { | ||
try { | ||
return clazz.getDeclaredField(fieldName); | ||
} catch (NoSuchFieldException nsf) { | ||
// Try superclass | ||
if (clazz.getSuperclass() != null) { | ||
return getSingleField(clazz.getSuperclass(), fieldName); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.