Commit c6350304 authored by Hsinli's avatar Hsinli

add

parent 6fab868b
Pipeline #19288 passed with stage
in 56 seconds
'use strict';
const moment = require('moment');
module.exports = app => {
const { INTEGER, STRING, DATE } = app.Sequelize;
const DuxiaomanLog = app.prometheusModel.define('duxiaoman_log', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
},
user_id: STRING,
app_user_id: STRING,
app_id: STRING,
app_type_id: STRING,
user_sid: INTEGER,
phone: STRING,
is_target_user: INTEGER,
request: STRING,
respones: STRING,
created_at: {
type: DATE,
get() {
const date = this.getDataValue('created_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
}
}, {
timestamps: false,
tableName: 'duxiaoman_log',
});
return DuxiaomanLog;
};
...@@ -63,6 +63,9 @@ class CheckService extends Service { ...@@ -63,6 +63,9 @@ class CheckService extends Service {
async check() { async check() {
const { ctx } = this; const { ctx } = this;
let ret = {
is_target_user: 0//1 true 0 false -1 NOT_FOUND
}
if (!ctx.oldUserId || !ctx.userId) { if (!ctx.oldUserId || !ctx.userId) {
//如果没有登录就不做处理 //如果没有登录就不做处理
ctx.failed('登录异常'); ctx.failed('登录异常');
...@@ -95,7 +98,27 @@ class CheckService extends Service { ...@@ -95,7 +98,27 @@ class CheckService extends Service {
ctx.logger.info('dxmUrl:' + dxmUrl); ctx.logger.info('dxmUrl:' + dxmUrl);
let result = await ctx.helper.send_request(dxmUrl, {}, { method: 'GET' }); let result = await ctx.helper.send_request(dxmUrl, {}, { method: 'GET' });
ctx.logger.info('result:' + JSON.stringify(result)); ctx.logger.info('result:' + JSON.stringify(result));
return result; if (result.status === 200) {
if (result.data.retCode === 0) {
ret.is_target_user = result.data.result.is_target_user;
}
//数据库记录
let addData = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
app_id: ctx.appId,
app_type_id: ctx.appTypeId,
user_sid: ctx.oldUserId,
phone: userInfo.passport,
is_target_user: result.data.result.is_target_user,
request: JSON.stringify(params),
response: JSON.stringify(result.data),
}
await ctx.prometheusModel.DuxiaomanLog.create(addData);
} else {
ctx.failed('服务异常,请稍后再试');
}
return ret;
......
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