Commit 5e1e00f2 by 王昆

gsb

parent 73b49ae9
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
var settings = require("../../../../config/settings");
const crypto = require('crypto'); const crypto = require('crypto');
const xlsx = require('node-xlsx'); const xlsx = require('node-xlsx');
const moment = require("moment"); const moment = require("moment");
class LaoActionApi extends APIBase { class LaoActionApi extends APIBase {
constructor() { constructor() {
super(); super();
...@@ -81,8 +84,99 @@ class LaoActionApi extends APIBase { ...@@ -81,8 +84,99 @@ class LaoActionApi extends APIBase {
29: this.companyConfig.yd, 29: this.companyConfig.yd,
30: this.companyConfig.tfb 30: this.companyConfig.tfb
} }
}
async testAES(pobj) {
let str = "{a:1,b2:'2', c:333, d:\"北京公司宝\"}";
console.log("str: " + str);
let encry = this.encryption(str);
console.log("encry: " + encry);
let decry = this.decryption(encry);
console.log("decry: " + decry);
return 1;
} }
async SmartLogin(obj) {
let data = obj.data || "";
if(!data) {
return system.getResult(-1, `参数错误`);
}
data = this.decryption(data);
try {
data = JSON.parse(data);
if(!data.mobile) {
return system.getResult(-1, `手机号码错误${data.mobile}`);
}
if(!data.companyName) {
return system.getResult(-1, `企业名称错误${data.companyName}`);
}
var parm = {
phone_no: data.mobile
}
var result = await this.usersSve.findUserInfoByPhone(parm);
if (result.status == -1) {
parm = {
phone_no: data.mobile,
user_type: "招人方",
status_type: 1,
status_name: "正常",
reg_time: (new Date()).Format("yyyy-MM-dd"),
com_type: 2,
com_name: data.companyName,
};
result = await this.usersSve.SaveUserInfo(parm);
}
var user_id = result.data.id;
//var user_id = 1;
parm = {
user_id: user_id,
oper_type: 0,
oper_name: "发薪系统自动登录",
oper_date: (new Date()).Format("yyyy-MM-dd hh:mm:ss")
};
await this.logSve.SaveLogInfo(parm);
return result;
} catch (error) {
console.log(e);
return system.getResult(-1, `a${data}解析错误`);
}
}
encryption(data) {
if(!data) {
return "";
}
let AES_conf = settings.apiconfig.AES;
let key = AES_conf.key;
let iv = AES_conf.iv;
// let padding = AES_conf.padding;
var cipherChunks = [];
var cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
cipher.setAutoPadding(true);
cipherChunks.push(cipher.update(data, 'utf8', 'base64'));
cipherChunks.push(cipher.final('base64'));
return cipherChunks.join('');
}
decryption(data){
if(!data) {
return "";
}
let AES_conf = settings.apiconfig.AES;
let key = AES_conf.key;
let iv = AES_conf.iv;
// let padding = AES_conf.padding;
var cipherChunks = [];
var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
decipher.setAutoPadding(true);
cipherChunks.push(decipher.update(data, 'base64', 'utf8'));
cipherChunks.push(decipher.final('utf8'));
return cipherChunks.join('');
}
async test(pobj, query) { async test(pobj, query) {
return system.getResultSuccess({ return system.getResultSuccess({
hello: "ok" hello: "ok"
......
...@@ -9,20 +9,16 @@ var settings={ ...@@ -9,20 +9,16 @@ var settings={
dbname : "laowubao", dbname : "laowubao",
// user : "root", // user : "root",
// password : "root", // password : "root",
// dbname : "laowubao",
user: "write", user: "write",
password: "write", password: "write",
config : { config : {
host: '192.168.18.237',
// dbname : "laowubao",
// user: "write",
// password: "write",
// config: {
// host: '43.247.184.35',
port: 3306,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
pool: { host: '43.247.184.35',
port: 8899,
// host: '192.168.18.237',
// port: 3306,
pool: {
max: 5, max: 5,
min: 0, min: 0,
acquire: 90000000, acquire: 90000000,
......
...@@ -235,6 +235,12 @@ var settings = { ...@@ -235,6 +235,12 @@ var settings = {
bossWithdrawApplyingKey: function () { //提现发放key bossWithdrawApplyingKey: function () { //提现发放key
return "3898EFhijklmCDEFGHIJKLMN"; return "3898EFhijklmCDEFGHIJKLMN";
}, },
AES: {
key: "qUPsMflPfgpPP1Ua", //密钥
iv: '1012133205963708', //偏移向量
padding: 'PKCS7Padding' //补全值
}
}, },
homePage: function () { homePage: function () {
......
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