Commit 013a49cd authored by Hsinli's avatar Hsinli

addd

parent 192a29a0
Pipeline #6657 passed with stage
in 9 seconds
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE } = app.Sequelize;
const SysUser = app.gjjModel.define('sys_suer', {
sid: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
passport: {
type: STRING,
allowNull: false
},
yys_cid: {
type: INTEGER,
allowNull: true
},
cv: {
type: STRING,
allowNull: true
},
ov: {
type: STRING,
allowNull: false
},
place_cid: {
type: INTEGER,
allowNull: false
},
apns: {
type: STRING,
allowNull: true
},
phone: {
type: STRING,
allowNull: true
},
time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
regtime: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('regtime');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
read_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('read_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
}
}, {
timestamps: false,
tableName: 'sys_user',
});
SysUser.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await SysUser.findOne({
attributes: attributes,
where: where,
});
}
return SysUser;
};
// app/service/user.js
'use strict';
const Service = require('egg').Service;
const moment = require('moment');
class UserService extends Service {
/**
* 通过用户编号获取手机号(校验token)
* @param {*} data user_sid
* @param {*} data token
*/
async get_phone_by_user_sid(data) {
const { ctx } = this;
let ret = {
phone: ''
}
if (!data.user_sid || !data.token) {
return ret;
}
//校验用户和token匹配问题
let userSid = data.user_sid;
let token = data.token;
let authToken = await ctx.helper.md5(String(userSid) + moment().format('MDYYYY') + 'f74jkdsy83sjf', 'utf8');
ctx.logger.info('get_phone_by_user_sid_params:' + JSON.stringify(data));
ctx.logger.info('authToken:' + authToken);
if (token != authToken) {
let authTokenYesterday = await ctx.helper.md5(String(userSid) + moment().subtract(1, 'days').format('MDYYYY') + 'f74jkdsy83sjf', 'utf8');
if (authToken != authTokenYesterday) {
return ret;
}
}
//根据主键查找用户信息
let filter = { where: { sid: userSid } };
let userInfo = await ctx.gjjModel.SysUser.one(filter);
ctx.logger.info('get_phone_by_user_sid:' + JSON.stringify(userInfo));
if (userInfo === null) {
return ret;
}
ret.phone = userInfo.passport;
return ret;
}
}
module.exports = UserService;
\ No newline at end of file
......@@ -66,6 +66,18 @@ module.exports = appInfo => {
password: 'ppD1sDSutHG83T2s1Ue3k',
port: 3306,
},
{
//公积金数据库
timezone: '+08:00',
delegate: 'gjjModel',
baseDir: 'model/gjj',
dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'devgjj',
username: 'devgjj',
password: 'jianbing2014GG',
port: 3306,
},
],
};
......
......@@ -14,7 +14,7 @@ module.exports = appInfo => {
dir: '/jianbing/logs/51business',
};
// add your config here
config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'];
// 是否启用csrf安全
config.security = {
......@@ -40,6 +40,18 @@ module.exports = appInfo => {
password: process.env.MYSQL_BLOCK_PWD,
port: 3306,
},
{
//公积金数据库
timezone: '+08:00',
delegate: 'gjjModel',
baseDir: 'model/gjj',
dialect: 'mysql',
host: process.env.MYSQL_GJJ_HOST,
database: process.env.MYSQL_GJJ_DB_NAME,
username: process.env.MYSQL_GJJ_USER,
password: process.env.MYSQL_GJJ_PWD,
port: 3306,
},
// {
// // 东八时区
// timezone: '+08:00',
......
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