Add data jpa module and project
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.cubetiqs.data.config;
|
||||
|
||||
import com.cubetiqs.data.domain.AuditDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
|
||||
/**
|
||||
* Auditor Aware Configurer
|
||||
*
|
||||
* @author sombochea
|
||||
* @see AuditorAware
|
||||
* @see AuditDetails
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface AuditorAwareConfigurer {
|
||||
String AUDITOR_AWARE_BEAN = "auditorAware";
|
||||
|
||||
@Bean
|
||||
default AuditorAware<AuditDetails> auditorAware() {
|
||||
return new AuditorAwareImpl();
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/cubetiqs/data/config/AuditorAwareImpl.java
Normal file
25
src/main/java/com/cubetiqs/data/config/AuditorAwareImpl.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.cubetiqs.data.config;
|
||||
|
||||
import com.cubetiqs.data.domain.AuditDetails;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Audit Aware Impl
|
||||
*
|
||||
* @author sombochea
|
||||
* @see AuditorAware
|
||||
* @see AuditDetails
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AuditorAwareImpl implements AuditorAware<AuditDetails> {
|
||||
private final static String SYSTEM = "admin";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Optional<AuditDetails> getCurrentAuditor() {
|
||||
return Optional.of(new AuditDetails(SYSTEM));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.cubetiqs.data.config;
|
||||
|
||||
import com.cubetiqs.data.repository.BaseRepositoryImpl;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Persistence Configuration Context.
|
||||
* This identifier used for boot config and app base packages and repositories bean.
|
||||
* Default scan components are "com.cubetiqs" and "com.cubetiqs.data.repository" for current base repository registration.
|
||||
*
|
||||
* @author sombochea
|
||||
* @see Target
|
||||
* @see Retention
|
||||
* @see Configuration
|
||||
* @see EnableJpaRepositories
|
||||
* @see EnableTransactionManagement
|
||||
* @see BaseRepositoryImpl
|
||||
* @since 1.0
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Configuration
|
||||
@EnableJpaRepositories(
|
||||
basePackages = {"com.cubetiqs.data.repository", "com.cubetiqs"},
|
||||
repositoryBaseClass = BaseRepositoryImpl.class
|
||||
)
|
||||
@EnableTransactionManagement
|
||||
public @interface PersistenceContext {
|
||||
}
|
||||
Reference in New Issue
Block a user