Commit 4354c86c authored by suntao's avatar suntao

channelconf

parent 29490912
package cn.quantgroup.cashloanflowboss.api.channel.controller;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import cn.quantgroup.cashloanflowboss.api.channel.service.ChannelConfService;
import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.Map;
/**
......@@ -14,7 +20,7 @@ import java.util.Map;
* @author suntao
*/
@RestController
@RequestMapping("channel/cfg")
@RequestMapping("channel")
public class ChannelConfController {
......@@ -23,15 +29,16 @@ public class ChannelConfController {
@GetMapping("/info")
public Result channelConfInfo(Integer channelId) {
public Page<ChannelConfiguration> channelInfo(@RequestParam @Valid Pagination pagination, Integer channelId) {
return channelConfService.getChannelInfo(pagination, channelId);
}
Map<String, Object> channelConf = channelConfService.getChannelConf(channelId);
if (channelConf == null) {
return new Result();
} else {
// TODO
return null;
}
@GetMapping("/cfg/info")
public Result channelConfInfo(Integer channelId) {
return channelConfService.getChannelConf(channelId);
}
}
package cn.quantgroup.cashloanflowboss.api.channel.entity.clf;
import cn.quantgroup.cashloanflowboss.api.channel.model.clf.EncType;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* Created by wudi on 2016/11/28.
*/
@Data
@Entity
@Table(name = "channel_configuration", catalog = "cash_loan_flow")
public class ChannelConfiguration implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "channel_name")
private String channelName;
@Column(name = "channel_code")
private String channelCode;
@Column(name = "registered_from")
private Long registeredFrom;
/**
* 默认有效
*/
@Column(name = "is_active")
private Boolean isActive = Boolean.TRUE;
@Column(name = "created_at")
private Timestamp createdAt = new Timestamp(System.currentTimeMillis());
/**
* 请求是否使用标准api
*/
@Column(name = "is_request_standard")
private Boolean isRequestStandard = Boolean.FALSE;
/**
* 加密类型
*/
@Column(name = "enc_type")
private EncType encType = EncType.AES;
/**
* aes加密key
*/
@Column(name = "aes_key")
private String aesKey;
/**
* md5摘要key
*/
@Column(name = "md5_key")
private String md5Key;
/**
* 授信中心channelCode, 爬虫提交channelCode
*/
@Column(name = "spider_center_channel_code")
private String spiderCenterChannelCode;
/**
* 授信中心商户渠道channelCode,授信授权提交channelCode
*/
@Column(name = "spider_center_merchant_channel_code")
private String spiderCenterMerchantChannelCode;
/**
* 渠道认证选项
*/
@Column(name = "auth_option")
private String authOption;
/**
* 免密登陆跳转url
*/
@Column(name = "login_page_url")
private String loginPageUrl;
}
\ No newline at end of file
package cn.quantgroup.cashloanflowboss.api.channel.model;
package cn.quantgroup.cashloanflowboss.api.channel.model.boss;
import lombok.Data;
......
package cn.quantgroup.cashloanflowboss.api.channel.model;
package cn.quantgroup.cashloanflowboss.api.channel.model.boss;
import lombok.Data;
......
package cn.quantgroup.cashloanflowboss.api.channel.model.clf;
/**
* function:
* date: 2019/8/6
*
* @author: suntao
*/
public class ChannelConfigurationPage {
}
package cn.quantgroup.cashloanflowboss.api.channel.model.clf;
/**
* Created by liqing on 2017/4/26 0026.
* 加解密方式
*/
public enum EncType {
AES("AES", "aesStandardCryptoService"),RSA("RSA", "rsaStandardCryptoService"),NONE("NONE", "noneStandardCryptoService");
public String text;
public String serviceClass;
EncType(String text, String serviceClass){
this.text = text;
this.serviceClass = serviceClass;
}
}
package cn.quantgroup.cashloanflowboss.api.channel.repository.clf;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ChannelConfigurationRepository extends PagingAndSortingRepository<ChannelConfiguration, String> {
/**
* 获取用户列表(分页)
*
* @param pageable 分页
* @return
*/
Page<ChannelConfiguration> findAllBy(Pageable pageable);
ChannelConfiguration findByRegisteredFrom(Integer channelId);
}
package cn.quantgroup.cashloanflowboss.api.channel.service;
import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import cn.quantgroup.cashloanflowboss.api.channel.repository.boss.ChannelConfRepository;
import cn.quantgroup.cashloanflowboss.api.channel.repository.clf.ChannelConfigurationRepository;
import cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil;
import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.Map;
......@@ -18,20 +25,29 @@ import java.util.Map;
@Service
public class ChannelConfService {
// @Autowired
// private ChannelConfRepository channelConfRepository;
@Autowired
private ChannelConfRepository channelConfRepository;
@Autowired
private ChannelConfigurationRepository clfChannelConfigurationRepository;
public Map<String, Object> getChannelConf(Integer channelId) {
public Page<ChannelConfiguration> getChannelInfo(Pagination pagination, Integer channelId) {
if (channelId == null) {
return clfChannelConfigurationRepository.findAllBy(new PageRequest(pagination.getPageNumber(), pagination.getPageSize()));
} else {
ChannelConfiguration channelConfiguration = clfChannelConfigurationRepository.findByRegisteredFrom(channelId);
Page<ChannelConfiguration> result = null;
return null;
}
}
// ChannelConf channelConf = channelConfRepository.getByChannelId(channelId);
// if (channelConf == null) {
// return null;
// }
//
// return ChannelConfUtil.channelConfConvertVOModel(channelConf);
return null;
public Result getChannelConf(Integer channelId) {
ChannelConf channelConf = channelConfRepository.getByChannelId(channelId);
return Result.buildSuccess(ChannelConfUtil.channelConfConvertVOModel(channelConf), "success");
}
}
......@@ -2,8 +2,8 @@ package cn.quantgroup.cashloanflowboss.api.channel.util;
import java.util.Date;
import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfAddModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfBaseModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.boss.ChannelConfAddModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.boss.ChannelConfBaseModel;
import org.springframework.beans.BeanUtils;
import java.util.HashMap;
......
package cn.quantgroup.cashloanflowboss.core.base;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import cn.quantgroup.cashloanflowboss.core.dictionary.Status;
import lombok.Data;
......@@ -50,4 +51,27 @@ public class Result<T> {
}
@SuppressWarnings("unchecked")
public static<T> Result buildSuccess(T data) {
return new Result(ApplicationStatus.SUCCESS, data);
}
@SuppressWarnings("unchecked")
public static<T> Result buildSuccess(T data, String message) {
return new Result(ApplicationStatus.SUCCESS, data, message);
}
@SuppressWarnings("unchecked")
public static<T> Result buildFial(T data) {
return new Result(ApplicationStatus.FAILURE, data);
}
@SuppressWarnings("unchecked")
public static<T> Result buildFial(T data, String message) {
return new Result(ApplicationStatus.FAILURE, data, message);
}
}
package cn.quantgroup.cashloanflowboss.core.configuration.data;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
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.Configuration;
import org.springframework.context.annotation.Primary;
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
@EntityScan(basePackages = {"cn.quantgroup.cashloanflowboss.api.*.entity.clf"})
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"cn.quantgroup.cashloanflowboss.api.*.repository.clf"},
entityManagerFactoryRef = "bossEntityManager",
transactionManagerRef = "bossTransactionManager")
public class ClfDSConfig {
@Value("${data.boss.url}")
private String jdbcUrl;
@Value("${data.boss.password}")
private String password;
@Value("${data.boss.username}")
private String user;
private String uniquename = "bossDS";
@Value("${data.boss.pool-size}")
private Integer poolSize;
@Primary
@Bean(name = "bossDataSource")
@ConfigurationProperties(prefix = "data.boss")
public DataSource createDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(200);
source.setMinIdle(10);
source.setInitialSize(10);
source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000);
source.setValidationQuery("SELECT 'x'");
source.setTestWhileIdle(true);
source.setTestOnBorrow(false);
source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE);
return source;
}
@Primary
@Bean(name = "bossEntityManager")
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.api.*.entity.clf")
.persistenceUnit(uniquename)
.build();
}
@Primary
@Bean(name = "bossTransactionManager")
public PlatformTransactionManager transactionManager(@Qualifier("bossEntityManager") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
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