Commit 7a2fff6d authored by WeiWei's avatar WeiWei

完善XYQB数据源配置

parent 83f15dd8
......@@ -4,6 +4,8 @@ import cn.quantgroup.cashloanflowboss.core.persistence.Primary;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* function:
......@@ -13,6 +15,8 @@ import javax.persistence.Column;
*/
@Data
@Entity
@Table(name = "order")
public class Order extends Primary {
@Column(name = "channel_order_number")
private String channelOrderNumber;
......
......@@ -63,7 +63,7 @@ public class CashLoanFlowBossDataSourceConfiguration {
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup")
.packages("cn.quantgroup.cashloanflowboss.api")
.persistenceUnit(uniquename)
.build();
}
......
......@@ -11,7 +11,7 @@ import java.util.Map;
* Created by WeiWei on 2019/8/12.
*/
@Component
@FeignClient(name = "XYQBCenter", url = "${}", fallback = XYQBCenter.Fallback.class)
@FeignClient(name = "XYQBCenter", url = "${api.https}", fallback = XYQBCenter.Fallback.class)
public interface XYQBCenter {
@PostMapping(value = "/ex/paycenter/pay_notify", consumes = "application/x-www-form-urlencoded")
......
......@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.*;
/**
* Created by WeiWei on 2019/8/12.
......@@ -14,6 +12,10 @@ import javax.persistence.Table;
@Table(name = "contract")
public class Contract {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/**
* 用户ID
*/
......
......@@ -2,9 +2,7 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
......@@ -16,6 +14,10 @@ import java.util.Date;
@Table(name = "waiting_funding_corp_operate_people")
public class FundLending {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/**
* 借款订单号
*/
......
package cn.quantgroup.cashloanflowboss.spi.xyqb.repository;
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.repository.CrudRepository;
import org.springframework.stereotype.Repository;
......@@ -8,8 +9,9 @@ import org.springframework.stereotype.Repository;
/**
* Created by WeiWei on 2019/8/13.
*/
@XYQBDataSource
@Repository
public interface ContractRepository extends CrudRepository<Contract, Integer> {
public interface ContractRepository extends CrudRepository<Contract, Long> {
/**
* 更新合同状态
......
package cn.quantgroup.cashloanflowboss.spi.xyqb.repository;
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.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
......@@ -12,6 +13,7 @@ import java.util.Map;
/**
* Created by WeiWei on 2019/8/12.
*/
@XYQBDataSource
@Repository
public interface FundLendingRepository extends CrudRepository<FundLending, Integer> {
......
......@@ -2,28 +2,33 @@ package cn.quantgroup.cashloanflowboss.spi.xyqb.source;
import com.alibaba.druid.pool.DruidDataSource;
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.ComponentScan;
import org.springframework.context.annotation.Configuration;
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 javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@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 {
@Bean
public DataSource xyqbDataSource(@Autowired XYQBDataSourceProperty dataSourceProperty) {
@ConfigurationProperties(prefix = "data.xyqb")
public DataSource xyqbDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(dataSourceProperty.getMaxActive());
source.setMinIdle(dataSourceProperty.getMinIdle());
source.setInitialSize(dataSourceProperty.getInitialSize());
source.setMaxActive(200);
source.setMinIdle(10);
source.setInitialSize(10);
source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000);
......@@ -32,9 +37,23 @@ public class XYQBDataSourceConfiguration {
source.setTestOnBorrow(false);
source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE);
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;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* Created by WeiWei on 2019/8/12.
*/
@Data
@ConfigurationProperties("application.datasource.xyqb")
@Component
@ConfigurationProperties("application.database.xyqb")
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