Commit 2b1552f3 authored by Hsinli's avatar Hsinli

add

parent 6b9bafd0
Pipeline #13481 passed with stage
in 9 seconds
'use strict';
const Service = require('egg').Service;
const moment = require('moment');
const _ = require('lodash');
class ApplyService extends Service {
async applyBlacklist() {
//demo
let params = {
sign: "",
signParams: {
appKey: this.config.BLACKLIST_APPLY_APPKEY,
timestamp: String(new Date().getTime()),
},
phone: "18912345678",
name: "李四",
idcard: "150981197202284550"
}
ctx.logger.info(params);
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.BLACKLIST_APPLY_APPSECRET);
ctx.logger.info(params);
let url = this.config.BLACKLIST_APPLY_URL;
let result = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info(result);
}
}
module.exports = ApplyService;
......@@ -38,7 +38,7 @@ const DeviceConfig = {
class BlacklistService extends Service {
/**
*
* 获取黑名单报告
* @param {*} id 报告编号
*/
async getReport(id) {
......
......@@ -38,6 +38,32 @@ class CommonService extends Service {
return prefix + suffix;
}
/**
* 签名函数
* @param {*} params 需要签名的参数
*/
async sign(params, appSecret) {
const { ctx } = this;
let sign = '';
if (!params) {
return sign;
}
//键名排序
const sortParamsKey = Object.keys(params).sort();
//键值拼接-升序
let sortValues = '';
for (let i in sortParamsKey) {
if (sortParamsKey[i] === 'sign') {
continue;
}
sortValues += sortParamsKey[i] + '=' + params[sortParamsKey[i]] + '&';
}
sortValues += 'appSecret=' + appSecret;
sign = await ctx.helper.md5(sortValues).toUpperCase();
ctx.logger.info({ sign: sign });
return sign;
}
}
module.exports = CommonService;
......@@ -18,7 +18,7 @@ module.exports = appInfo => {
};
// config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
config.middleware = [ ];
config.middleware = [];
exports.multipart = {
// 不用steam用file
......@@ -127,6 +127,10 @@ module.exports = appInfo => {
config.USER_CENTER_API_URI = 'https://uat-nginx.jianbing.com/usercenter-service';
config.BLACKLIST_APPLY_APPKEY = 'F4E0CA710F484CFFB1756741696E29A3';
config.BLACKLIST_APPLY_APPSECRET = '233B8E10E31B4C899EE6FEB3AEC22F140B6528BF';
config.BLACKLIST_APPLY_URL = 'http://47.96.253.64:8049/mycredit/blackList';
return config;
};
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