Commit 7705dd95 authored by suntao's avatar suntao

渠道配置

parent 1a577745
package cn.quantgroup.cashloanflowboss.api.channel.controller;
import cn.quantgroup.cashloanflowboss.api.channel.service.ChannelConfService;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* Created with suntao on 2019/8/2
* @author suntao
*/
@RestController
@RequestMapping("channel/cfg")
public class ChannelConfController {
@Autowired
private ChannelConfService channelConfService;
@GetMapping("/info")
public Result channelConfInfo(Integer channelId) {
Map<String, Object> channelConf = channelConfService.getChannelConf(channelId);
if (channelConf == null) {
return new Result();
} else {
// TODO
return null;
}
}
}
package cn.quantgroup.cashloanflowboss.api.channel.entity;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.core.persistence.Primary;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
/**
* date 2019/7/22.
* @author suntao
*/
@Data
@Entity
@Table(name = "channel_conf")
public class ChannelConf extends Primary {
/**
* 渠道id
*/
@Column(name = "channel_id")
private Integer channelId;
/**
* 渠道code
*/
@Column(name = "channel_code")
private String channelCode;
/**
* 渠道code
*/
@Column(name = "channel_name")
private String channelName;
/**
* 联调环境
*/
@Column(name = "env")
private String env;
/**
* 资方id
*/
@Column(name = "fund_id")
private Integer fundId;
/**
* p2p资方id
*/
@Column(name = "p2p_fund_id")
private Integer p2pFundId;
/**
* p2p资方id
*/
@Column(name = "biz_type")
private Integer bizType;
/**
* aesKey
*/
@Column(name = "aes_key")
private String aesKey;
/**
* md5_key
*/
@Column(name = "md5_key")
private String md5Key;
/**
* env_url
*/
@Column(name = "env_url")
private String envUrl;
/**
* channel_ip
*/
@Column(name = "channel_ip")
private String channelIp;
/**
* approveCallBackUrl
*/
@Column(name = "approve_call_back_url")
private String approveCallBackUrl;
/**
* orderStatusCallBackUrl
*/
@Column(name = "order_status_call_back_url")
private String orderStatusCallBackUrl;
/**
* repayResultCallBackUrl
*/
@Column(name = "repay_result_call_back_url")
private String repayResultCallBackUrl;
/**
* repaymentPlanCallBackUrl
*/
@Column(name = "repayment_plan_call_back_url")
private String repaymentPlanCallBackUrl;
/**
* message
*/
@Column(name = "message")
private String message;
/**
* extend_data
*/
@Column(name = "extend_data")
private String extendData;
}
package cn.quantgroup.cashloanflowboss.api.channel.model;
import lombok.Data;
/**
* function:
* date: 2019/8/2
*
* @author: suntao
*/
@Data
public class ChannelConfAddModel {
private String envUrl;
private String channelIp;
private String approveCallBackUrl;
private String orderStatusCallBackUrl;
private String repayResultCallBackUrl;
private String repaymentPlanCallBackUrl;
private String message;
private String extendData;
}
package cn.quantgroup.cashloanflowboss.api.channel.model;
import lombok.Data;
/**
* Created with suntao on 2019/8/2
*/
@Data
public class ChannelConfBaseModel {
private Integer channelId;
private String channelName;
private String channelCode;
private String env;
private String fundId;
private String p2pFundId;
private String bizType;
private String aesKey;
private String md5Key;
}
package cn.quantgroup.cashloanflowboss.api.channel.repository;
import cn.quantgroup.cashloanflowboss.api.channel.entity.ChannelConf;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* Created by WeiWei on 2019/7/22.
*/
@Repository
public interface ChannelConfRepository extends PagingAndSortingRepository<ChannelConf, String> {
/**
* 获取用户
*
* @param channelId 用户名
* @return
*/
ChannelConf getByChannelId(Integer channelId);
}
package cn.quantgroup.cashloanflowboss.api.channel.service;
import cn.quantgroup.cashloanflowboss.api.channel.entity.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.repository.ChannelConfRepository;
import cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* function:
* date: 2019/8/2
*
* @author: suntao
*/
@Service
public class ChannelConfService {
@Autowired
private ChannelConfRepository channelConfRepository;
public Map<String, Object> getChannelConf(Integer channelId) {
ChannelConf channelConf = channelConfRepository.getByChannelId(channelId);
if (channelConf == null) {
return null;
}
return ChannelConfUtil.channelConfConvertVOModel(channelConf);
}
}
package cn.quantgroup.cashloanflowboss.api.channel.util;
import java.util.Date;
import cn.quantgroup.cashloanflowboss.api.channel.entity.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfAddModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfBaseModel;
import org.springframework.beans.BeanUtils;
import java.util.HashMap;
import java.util.Map;
/**
* function:
* date: 2019/8/2
*
* @author: suntao
*/
public class ChannelConfUtil {
public static Map<String, Object> channelConfConvertVOModel(ChannelConf channelConf) {
Map<String, Object> vo = new HashMap<>(4);
ChannelConfBaseModel channelConfBaseModel = new ChannelConfBaseModel();
BeanUtils.copyProperties(channelConf, channelConfBaseModel);
ChannelConfAddModel channelConfAddModel = new ChannelConfAddModel();
BeanUtils.copyProperties(channelConf, channelConfAddModel);
vo.put("basicInfo", channelConfBaseModel);
vo.put("addInfo", channelConfAddModel);
return vo;
}
public static ChannelConf voModelConfConvertChannelConf(ChannelConfBaseModel channelConfBaseModel, ChannelConfAddModel channelConfAddModel) {
Map<String, Object> vo = new HashMap<>(4);
ChannelConf channelConf = new ChannelConf();
BeanUtils.copyProperties(channelConfBaseModel, channelConf);
channelConf.setChannelIp(channelConfAddModel.getChannelIp());
channelConf.setApproveCallBackUrl(channelConfAddModel.getApproveCallBackUrl());
channelConf.setOrderStatusCallBackUrl(channelConfAddModel.getOrderStatusCallBackUrl());
channelConf.setRepayResultCallBackUrl(channelConfAddModel.getRepayResultCallBackUrl());
channelConf.setRepaymentPlanCallBackUrl(channelConfAddModel.getRepaymentPlanCallBackUrl());
channelConf.setCreateTime(new Date());
channelConf.setUpdateTime(new Date());
return channelConf;
}
}
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