Authored by 李奇

有货用户基础信息服务添加

/**
*aes加解密
* @author: qi.li@yoho.cn
* @date: 2017/10/10
*/
'use strict';
const crypto = global.yoho.crypto;
/**
* uid加密
**/
const encryptUid = (uid) => {
return crypto.encryption('yoho9646abcdefgh', uid + '');
};
/**
* uid解密
**/
const decryptUid = (uid) => {
return crypto.decrypt('yoho9646abcdefgh', uid + '');
};
module.exports = {
encryptUid,
decryptUid
};
... ...
const moment = require('moment');
const _ = require('lodash');
const aes = require('./aes');
const {yoho} = global.yoho.utils;
const {yohoSecret} = global.yoho.config;
const UserModel = require('../models/user');
... ... @@ -64,6 +65,26 @@ const user = {
return res.json({code: 200});
}).catch(next);
},
/**
* 有货用户基础信息
* @param req
* @param res
* @param next
*/
userBaseInfo(req, res, next) {
let uid = req.body.uid;
let encryptUid = req.body.encryptUid;
if (encryptUid) {
uid = parseInt(aes.decryptUid(encryptUid), 10);
}
return req.ctx(UserModel).userBaseInfo(uid)
.then(result => {
return res.json(result);
}).catch(next);
}
};
... ...
... ... @@ -18,6 +18,15 @@ class UserModel extends global.yoho.BaseModel {
}
);
}
userBaseInfo(uid) {
return this.get({
data: {
uid,
method: 'app.passport.getUserBase'
},
api: global.yoho.API
});
}
}
module.exports = UserModel;
... ...
... ... @@ -9,5 +9,6 @@ const user = require('./controllers/user');
router.get('/getLoginUrl', user.getLoginUrl);
router.post('/loginLog', user.loginLog);
router.post('/getUserBaseInfo', user.userBaseInfo);
module.exports = router;
... ...
/**
*aes加解密
* @author: qi.li@yoho.cn
* @date: 2017/10/10
*/
'use strict';
const crypto = global.yoho.crypto;
/**
* uid加密
**/
const encryptUid = (uid) => {
return crypto.encryption('yoho9646abcdefgh', uid + '');
};
/**
* uid解密
**/
const decryptUid = (uid) => {
return crypto.decrypt('yoho9646abcdefgh', uid + '');
};
module.exports = {
encryptUid,
decryptUid
};
... ...