Commit 7a2fff6d authored by WeiWei's avatar WeiWei

完善XYQB数据源配置

parent 83f15dd8
...@@ -4,6 +4,8 @@ import cn.quantgroup.cashloanflowboss.core.persistence.Primary; ...@@ -4,6 +4,8 @@ import cn.quantgroup.cashloanflowboss.core.persistence.Primary;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/** /**
* function: * function:
...@@ -13,6 +15,8 @@ import javax.persistence.Column; ...@@ -13,6 +15,8 @@ import javax.persistence.Column;
*/ */
@Data @Data
@Entity
@Table(name = "order")
public class Order extends Primary { public class Order extends Primary {
@Column(name = "channel_order_number") @Column(name = "channel_order_number")
private String channelOrderNumber; private String channelOrderNumber;
......
...@@ -63,7 +63,7 @@ public class CashLoanFlowBossDataSourceConfiguration { ...@@ -63,7 +63,7 @@ public class CashLoanFlowBossDataSourceConfiguration {
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) { public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource()) return builder.dataSource(createDataSource())
.packages("cn.quantgroup") .packages("cn.quantgroup.cashloanflowboss.api")
.persistenceUnit(uniquename) .persistenceUnit(uniquename)
.build(); .build();
} }
......
...@@ -11,7 +11,7 @@ import java.util.Map; ...@@ -11,7 +11,7 @@ import java.util.Map;
* Created by WeiWei on 2019/8/12. * Created by WeiWei on 2019/8/12.
*/ */
@Component @Component
@FeignClient(name = "XYQBCenter", url = "${}", fallback = XYQBCenter.Fallback.class) @FeignClient(name = "XYQBCenter", url = "${api.https}", fallback = XYQBCenter.Fallback.class)
public interface XYQBCenter { public interface XYQBCenter {
@PostMapping(value = "/ex/paycenter/pay_notify", consumes = "application/x-www-form-urlencoded") @PostMapping(value = "/ex/paycenter/pay_notify", consumes = "application/x-www-form-urlencoded")
......
...@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity; ...@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
/** /**
* Created by WeiWei on 2019/8/12. * Created by WeiWei on 2019/8/12.
...@@ -14,6 +12,10 @@ import javax.persistence.Table; ...@@ -14,6 +12,10 @@ import javax.persistence.Table;
@Table(name = "contract") @Table(name = "contract")
public class Contract { public class Contract {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/** /**
* 用户ID * 用户ID
*/ */
......
...@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity; ...@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
...@@ -16,6 +14,10 @@ import java.util.Date; ...@@ -16,6 +14,10 @@ import java.util.Date;
@Table(name = "waiting_funding_corp_operate_people") @Table(name = "waiting_funding_corp_operate_people")
public class FundLending { public class FundLending {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/** /**
* 借款订单号 * 借款订单号
*/ */
......
package cn.quantgroup.cashloanflowboss.spi.xyqb.repository; package cn.quantgroup.cashloanflowboss.spi.xyqb.repository;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.Contract; import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.Contract;
import cn.quantgroup.cashloanflowboss.spi.xyqb.source.XYQBDataSource;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -8,8 +9,9 @@ import org.springframework.stereotype.Repository; ...@@ -8,8 +9,9 @@ import org.springframework.stereotype.Repository;
/** /**
* Created by WeiWei on 2019/8/13. * Created by WeiWei on 2019/8/13.
*/ */
@XYQBDataSource
@Repository @Repository
public interface ContractRepository extends CrudRepository<Contract, Integer> { public interface ContractRepository extends CrudRepository<Contract, Long> {
/** /**
* 更新合同状态 * 更新合同状态
......
package cn.quantgroup.cashloanflowboss.spi.xyqb.repository; package cn.quantgroup.cashloanflowboss.spi.xyqb.repository;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.FundLending; import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.FundLending;
import cn.quantgroup.cashloanflowboss.spi.xyqb.source.XYQBDataSource;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
...@@ -12,6 +13,7 @@ import java.util.Map; ...@@ -12,6 +13,7 @@ import java.util.Map;
/** /**
* Created by WeiWei on 2019/8/12. * Created by WeiWei on 2019/8/12.
*/ */
@XYQBDataSource
@Repository @Repository
public interface FundLendingRepository extends CrudRepository<FundLending, Integer> { public interface FundLendingRepository extends CrudRepository<FundLending, Integer> {
......
...@@ -2,28 +2,33 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.source; ...@@ -2,28 +2,33 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.source;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource; import javax.sql.DataSource;
@Configuration @Configuration
@EnableTransactionManagement @EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"cn.quantgroup"}, includeFilters = @ComponentScan.Filter(XYQBDataSource.class)) @EnableJpaRepositories(basePackages = {"cn.quantgroup.cashloanflowboss.spi.xyqb"}, entityManagerFactoryRef = "xyqbEntityManager", transactionManagerRef = "xyqbTransactionManager", includeFilters = @ComponentScan.Filter(XYQBDataSource.class))
public class XYQBDataSourceConfiguration { public class XYQBDataSourceConfiguration {
@Bean @Bean
public DataSource xyqbDataSource(@Autowired XYQBDataSourceProperty dataSourceProperty) { @ConfigurationProperties(prefix = "data.xyqb")
public DataSource xyqbDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build(); DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(200);
source.setMaxActive(dataSourceProperty.getMaxActive()); source.setMinIdle(10);
source.setMinIdle(dataSourceProperty.getMinIdle()); source.setInitialSize(10);
source.setInitialSize(dataSourceProperty.getInitialSize());
source.setMaxWait(500000); source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000); source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000); source.setMinEvictableIdleTimeMillis(300000);
...@@ -32,9 +37,23 @@ public class XYQBDataSourceConfiguration { ...@@ -32,9 +37,23 @@ public class XYQBDataSourceConfiguration {
source.setTestOnBorrow(false); source.setTestOnBorrow(false);
source.setTestOnReturn(false); source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE); source.setPoolPreparedStatements(Boolean.FALSE);
return source; return source;
} }
@Bean
public LocalContainerEntityManagerFactoryBean xyqbEntityManager(EntityManagerFactoryBuilder builder, DataSource xyqbDataSource) {
return builder.dataSource(xyqbDataSource)
.packages("cn.quantgroup.cashloanflowboss")
.persistenceUnit("XYQB-DataSource")
.build();
}
@Bean
public PlatformTransactionManager xyqbTransactionManager(EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
} }
...@@ -2,12 +2,14 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.source; ...@@ -2,12 +2,14 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.source;
import lombok.Data; import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/** /**
* Created by WeiWei on 2019/8/12. * Created by WeiWei on 2019/8/12.
*/ */
@Data @Data
@ConfigurationProperties("application.datasource.xyqb") @Component
@ConfigurationProperties("application.database.xyqb")
public class XYQBDataSourceProperty { public class XYQBDataSourceProperty {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment