Commit 2e74830c by Sxy

fix: 代码规范

parent 13e166f4
...@@ -3,7 +3,7 @@ FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2 ...@@ -3,7 +3,7 @@ FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com" MAINTAINER jy "jiangyong@gongsibao.com"
ADD tx-fi-tax /apps/tx-fi-tax/ ADD tx-fi-tax /apps/tx-fi-tax/
WORKDIR /apps/tx-fi-tax/ WORKDIR /apps/tx-fi-tax/
RUN cnpm install -S RUN cnpm install -S --production
CMD ["node","/apps/tx-fi-tax/main.js"] CMD ["node","/apps/tx-fi-tax/main.js"]
......
{
"lockfileVersion": 1
}
module.exports = {
root: true,
extends: [
// 'plugin:vue/essential',
'@tencent/eslint-config-tencent',
// '@vue/standard'
],
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/no-parsing-error': [2, {
'x-invalid-end-tag': false,
}],
'no-undef': 'off',
camelcase: 'off',
},
parserOptions: {
parser: 'babel-eslint',
},
env: {
jquery: true,
node: true,
},
};
const system = require("../system"); const system = require('../system');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const settings = require("../../config/settings"); const settings = require('../../config/settings');
class APIBase { class APIBase {
constructor() { constructor() {
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject('db.common.cacheManager');
this.logClient = system.getObject("util.logClient"); this.logClient = system.getObject('util.logClient');
} }
async setContextParams(pobj, qobj, req) { async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null; const custtags = req.headers['x-consumetag'] ? req.headers['x-consumetag'].split('|') : null;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值 // 当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = { req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色 appkey: req.headers.xappkey, // 用于系统管理区分应用,比如角色
companyid: custtags ? custtags[0].split("_")[1] : null, companyid: custtags ? custtags[0].split('_')[1] : null,
password: custtags ? custtags[1].split("_")[1] : null, password: custtags ? custtags[1].split('_')[1] : null,
username: req.headers["x-consumer-username"], username: req.headers['x-consumer-username'],
userid: req.headers["x-consumer-custom-id"], userid: req.headers['x-consumer-custom-id'],
credid: req.headers["x-credential-identifier"], credid: req.headers['x-credential-identifier'],
companykey: req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司 companykey: req.headers['x-company-key'], // 专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath: req.headers['xopath'], opath: req.headers.xopath,
ptags: req.headers['xptags'], ptags: req.headers.xptags,
} };
//添加组织结构路径,如果是上级,取上级 // 添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") { if (req.xctx.ptags && req.xctx.ptags != '') {
pobj.opath = req.xctx.ptags pobj.opath = req.xctx.ptags;
} else { } else {
pobj.opath = req.xctx.opath pobj.opath = req.xctx.opath;
} }
if (req.xctx.userid) {//在请求传递数据对象注入公司id if (req.xctx.userid) { // 在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid; pobj.userid = req.xctx.userid;
pobj.username = req.xctx.username pobj.username = req.xctx.username;
} }
if (!req.xctx.appkey) { if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"] return [-200, '请求头缺少应用x-app-key'];
} else {
// let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
// req.xctx.appid = app.id;
// pobj.app_id = app.id;//传递参数对象里注入app_id
} }
//平台注册时,companyid,companykey都为空 // let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
//自由注册时,companykey不能为空 // req.xctx.appid = app.id;
// pobj.app_id = app.id;//传递参数对象里注入app_id
// 平台注册时,companyid,companykey都为空
// 自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){ // if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"] // return [-200,"请求头缺少应用x-app-key"]
// } // }
if (!req.xctx.companyid && req.xctx.companykey && req.xctx.companykey != 'null' && req.xctx.companykey != 'undefined') { if (!req.xctx.companyid && req.xctx.companykey && req.xctx.companykey != 'null' && req.xctx.companykey != 'undefined') {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.companykey); const comptmp = await this.cacheManager.CompanyCache.cache(req.xctx.companykey);
req.xctx.companyid = comptmp.id; req.xctx.companyid = comptmp.id;
} }
if (req.xctx.companyid) {//在请求传递数据对象注入公司id if (req.xctx.companyid) { // 在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid; pobj.company_id = req.xctx.companyid;
} }
} }
async doexec(gname, methodname, pobj, query, req) { async doexec(gname, methodname, pobj, query, req) {
try { try {
let xarg = await this.setContextParams(pobj, query, req); const xarg = await this.setContextParams(pobj, query, req);
if (xarg && xarg[0] < 0) { if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg); return system.getResultFail(...xarg);
} }
var rtn = await this[methodname](pobj, query, req); const rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn) this.logClient.log(pobj, req, rtn);
return rtn; return rtn;
} catch (e) { } catch (e) {
this.logClient.log(pobj, req, null, e.stack); this.logClient.log(pobj, req, null, e.stack);
console.log(e.stack, "api调用异常--error..................."); console.log(e.stack, 'api调用异常--error...................');
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员"); const rtnerror = system.getResultFail(-200, '出现异常,请联系管理员');
return rtnerror; return rtnerror;
} }
} }
......
const system = require("../system"); const system = require('../system');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class DocBase { class DocBase {
constructor() { constructor() {
this.apiDoc = { this.apiDoc = {
group: "逻辑分组", group: '逻辑分组',
groupDesc: "", groupDesc: '',
name: "", name: '',
desc: "请对当前类进行描述", desc: '请对当前类进行描述',
exam: "概要示例", exam: '概要示例',
methods: [] methods: [],
}; };
this.initClassDoc(); this.initClassDoc();
} }
initClassDoc() { initClassDoc() {
this.descClass(); this.descClass();
this.descMethods(); this.descMethods();
} }
descClass() { descClass() {
var classDesc = this.classDesc(); const classDesc = this.classDesc();
this.apiDoc.group = classDesc.groupName; this.apiDoc.group = classDesc.groupName;
this.apiDoc.groupDesc = this.examDescHtml(classDesc.groupDesc); this.apiDoc.groupDesc = this.examDescHtml(classDesc.groupDesc);
this.apiDoc.name = classDesc.name; this.apiDoc.name = classDesc.name;
this.apiDoc.desc = this.examDescHtml(classDesc.desc); this.apiDoc.desc = this.examDescHtml(classDesc.desc);
this.apiDoc.exam = this.examHtml(); this.apiDoc.exam = this.examHtml();
} }
examDescHtml(desc) { examDescHtml(desc) {
// var tmpDesc = desc.replace(/\\/g, "<br/>"); // var tmpDesc = desc.replace(/\\/g, "<br/>");
return desc; return desc;
} }
examHtml() { examHtml() {
var exam = this.exam(); let exam = this.exam();
exam = exam.replace(/\\/g, "<br/>"); exam = exam.replace(/\\/g, '<br/>');
return exam; return exam;
} }
exam() { exam() {
throw new Error("请在子类中定义类操作示例"); throw new Error('请在子类中定义类操作示例');
} }
classDesc() { classDesc() {
throw new Error(` throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构 请重写classDesc对当前的类进行描述,返回如下数据结构
{ {
groupName:"auth", groupName:"auth",
...@@ -46,19 +46,21 @@ class DocBase { ...@@ -46,19 +46,21 @@ class DocBase {
exam:"", exam:"",
} }
`); `);
}
descMethods() {
const methoddescs = this.methodDescs();
for (const methoddesc of methoddescs) {
for (const paramdesc of methoddesc.paramdescs) {
this.descMethod(
methoddesc.methodDesc, methoddesc.methodName
, paramdesc.paramDesc, paramdesc.paramName, paramdesc.paramType,
paramdesc.defaultValue, methoddesc.rtnTypeDesc, methoddesc.rtnType,
);
}
} }
descMethods() { }
var methoddescs = this.methodDescs(); methodDescs() {
for (var methoddesc of methoddescs) { throw new Error(`
for (var paramdesc of methoddesc.paramdescs) {
this.descMethod(methoddesc.methodDesc, methoddesc.methodName
, paramdesc.paramDesc, paramdesc.paramName, paramdesc.paramType,
paramdesc.defaultValue, methoddesc.rtnTypeDesc, methoddesc.rtnType);
}
}
}
methodDescs() {
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构 请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[ [
{ {
...@@ -83,35 +85,32 @@ class DocBase { ...@@ -83,35 +85,32 @@ class DocBase {
} }
] ]
`); `);
}
descMethod(methodDesc, methodName, paramDesc, paramName, paramType, defaultValue, rtnTypeDesc, rtnType) {
const mobj = this.apiDoc.methods.filter((m) => {
if (m.name == methodName) {
return true;
}
return false;
})[0];
const param = {
pname: paramName,
ptype: paramType,
pdesc: paramDesc,
pdefaultValue: defaultValue,
};
if (mobj != null) {
mobj.params.push(param);
} else {
this.apiDoc.methods.push({
methodDesc: methodDesc ? methodDesc : '',
name: methodName,
params: [param],
rtnTypeDesc,
rtnType,
});
} }
descMethod(methodDesc, methodName, paramDesc, paramName, paramType, defaultValue, rtnTypeDesc, rtnType) { }
var mobj = this.apiDoc.methods.filter((m) => {
if (m.name == methodName) {
return true;
} else {
return false;
}
})[0];
var param = {
pname: paramName,
ptype: paramType,
pdesc: paramDesc,
pdefaultValue: defaultValue,
};
if (mobj != null) {
mobj.params.push(param);
} else {
this.apiDoc.methods.push(
{
methodDesc: methodDesc ? methodDesc : "",
name: methodName,
params: [param],
rtnTypeDesc: rtnTypeDesc,
rtnType: rtnType
}
);
}
}
} }
module.exports = DocBase; module.exports = DocBase;
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class AccessAuthAPI extends APIBase { class AccessAuthAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.appS = system.getObject("service.common.appSve"); this.appS = system.getObject('service.common.appSve');
this.apitradeSvr = system.getObject("service.common.apitradeSve"); this.apitradeSvr = system.getObject('service.common.apitradeSve');
this.authUtils = system.getObject("util.businessManager.authUtils"); this.authUtils = system.getObject('util.businessManager.authUtils');
this.userSve = system.getObject("service.auth.userSve"); this.userSve = system.getObject('service.auth.userSve');
} }
//不从平台应用列表入口登录时 // 不从平台应用列表入口登录时
//先要调用平台登录接口 // 先要调用平台登录接口
//返回token,利用这个token再去登录某个具体APP // 返回token,利用这个token再去登录某个具体APP
//会话存储具体APP的用户信息 // 会话存储具体APP的用户信息
//每个前端应用打开时,先检查是否存在token // 每个前端应用打开时,先检查是否存在token
//如果存在,就去访问获取用户信息,---调用本接口--即刻 // 如果存在,就去访问获取用户信息,---调用本接口--即刻
//进入或登录某个具体应用 // 进入或登录某个具体应用
//前提是已经具备了统一管理的账号,并且已经在统一管理账号登录,客户端具备了token // 前提是已经具备了统一管理的账号,并且已经在统一管理账号登录,客户端具备了token
//进入某个具体应用时,需要指定 x-appkey请求头 // 进入某个具体应用时,需要指定 x-appkey请求头
// //
async loginToApp(p,q,req){ async loginToApp(p, q, req) {
let appkey=req.xctx.appkey; const { appkey } = req.xctx;
}
} classDesc() {
classDesc() { return {
return { groupName: 'auth',
groupName: "auth", groupDesc: '认证相关的包',
groupDesc: "认证相关的包", name: 'AccessAuthAPI',
name: "AccessAuthAPI", desc: '关于认证的类',
desc: "关于认证的类", exam: `
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey post http://p.apps.com/api/auth/accessAuth/getAccessKey
{ {
appKey:xxxxx, appKey:xxxxx,
secret:yyyyyy secret:yyyyyy
} }
`, `,
}; };
} }
methodDescs() { methodDescs() {
return [ return [
{ {
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中", methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: "getAccessKey", methodName: 'getAccessKey',
paramdescs: [ paramdescs: [
{ {
paramDesc: "访问appkey", paramDesc: '访问appkey',
paramName: "appkey", paramName: 'appkey',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
}, },
{ {
paramDesc: "访问secret", paramDesc: '访问secret',
paramName: "secret", paramName: 'secret',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
} },
], ],
rtnTypeDesc: "返回JSON对象字符串", rtnTypeDesc: '返回JSON对象字符串',
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例" rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
}, },
]; ];
} }
exam() { exam() {
return `` return ``;
} }
} }
module.exports = AccessAuthAPI; module.exports = AccessAuthAPI;
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class RoleAuthAPI extends APIBase { class RoleAuthAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.authS=system.getObject("service.auth.authSve"); this.authS = system.getObject('service.auth.authSve');
} }
async findAuthsByRole(p,q,req){ async findAuthsByRole(p, q, req) {
var tmpRoles=p.roles; const tmpRoles = p.roles;
var appid=p.appid; const { appid } = p;
var comid=p.companyid; const comid = p.companyid;
var auths=await this.authS.findAuthsByRole(tmpRoles,appid,comid); const auths = await this.authS.findAuthsByRole(tmpRoles, appid, comid);
return system.getResult(auths); return system.getResult(auths);
} }
exam(){ exam() {
return ` return `
xxxxxxxxx xxxxxxxxx
yyyyyyyyy yyyyyyyyy
zzzzzzzzz zzzzzzzzz
ooooooo ooooooo
`; `;
} }
classDesc() { classDesc() {
return { return {
groupName: "auth", groupName: 'auth',
groupDesc: "角色授权相关的API", groupDesc: '角色授权相关的API',
name: "RoleAuthAPI", name: 'RoleAuthAPI',
desc: "角色授权相关的API", desc: '角色授权相关的API',
exam: "", exam: '',
}; };
} }
methodDescs() {
return [
{
methodDesc: "按照角色获取权限,访问地址:/api/auth/roleAuth/findAuthsByRole",
methodName: "findAuthsByRole",
paramdescs: [
{
paramDesc: "应用的ID",
paramName: "appid",
paramType: "int",
defaultValue: "x",
},
{
paramDesc: "角色列表",
paramName: "roles",
paramType: "array",
defaultValue: null,
}
],
rtnTypeDesc: "逗号分隔的",
rtnType: "string"
}
];
}
methodDescs() {
return [
{
methodDesc: '按照角色获取权限,访问地址:/api/auth/roleAuth/findAuthsByRole',
methodName: 'findAuthsByRole',
paramdescs: [
{
paramDesc: '应用的ID',
paramName: 'appid',
paramType: 'int',
defaultValue: 'x',
},
{
paramDesc: '角色列表',
paramName: 'roles',
paramType: 'array',
defaultValue: null,
},
],
rtnTypeDesc: '逗号分隔的',
rtnType: 'string',
},
];
}
} }
module.exports = RoleAuthAPI; module.exports = RoleAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class BizChanceAPI extends APIBase { class BizChanceAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.bizChanceS = system.getObject("service.bizchance.bizoptSve"); this.bizChanceS = system.getObject('service.bizchance.bizoptSve');
this.dateUtil = system.getObject("util.dateClient"); this.dateUtil = system.getObject('util.dateClient');
} }
/** /**
* 按照服务商进行分组统计 * 按照服务商进行分组统计
* @param {*} p * @param {*} p
* @param {*} q * @param {*} q
* @param {*} req * @param {*} req
*/ */
async statBizChanceCountBySp(p, q, req) { async statBizChanceCountBySp(p, q, req) {
let bizStatus = p.bizStatus const { bizStatus } = p;
let betweenTime = this.dateUtil.betweenTime(p.dateType); const betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime) const rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime);
return system.getResult(rtn) return system.getResult(rtn);
} }
/** /**
* 待处理商机beforeSubmission * 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation * 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭 *累计处理商机 包括成单和关闭
* @param {*} p * @param {*} p
* @param {*} q * @param {*} q
* @param {*} req * @param {*} req
*/ */
async statBizChance(p, q, req) { async statBizChance(p, q, req) {
let companyId = p.company_id const companyId = p.company_id;
let userid = p.userid const { userid } = p;
let username = p.username const { username } = p;
let opath = p.opath const { opath } = p;
let betweenTime = this.dateUtil.betweenTime(p.dateType); const betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime); const rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn) return system.getResult(rtn);
} }
classDesc() { classDesc() {
return { return {
groupName: "auth", groupName: 'auth',
groupDesc: "认证相关的包", groupDesc: '认证相关的包',
name: "AccessAuthAPI", name: 'AccessAuthAPI',
desc: "关于认证的类", desc: '关于认证的类',
exam: ` exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey post http://p.apps.com/api/auth/accessAuth/getAccessKey
{ {
appKey:xxxxx, appKey:xxxxx,
secret:yyyyyy secret:yyyyyy
} }
`, `,
}; };
} }
methodDescs() { methodDescs() {
return [ return [
{ {
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中", methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: "getAccessKey", methodName: 'getAccessKey',
paramdescs: [ paramdescs: [
{ {
paramDesc: "访问appkey", paramDesc: '访问appkey',
paramName: "appkey", paramName: 'appkey',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
}, },
{ {
paramDesc: "访问secret", paramDesc: '访问secret',
paramName: "secret", paramName: 'secret',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
} },
], ],
rtnTypeDesc: "返回JSON对象字符串", rtnTypeDesc: '返回JSON对象字符串',
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例" rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
}, },
]; ];
} }
exam() { exam() {
return `` return ``;
} }
} }
module.exports = BizChanceAPI; module.exports = BizChanceAPI;
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class BizDeliverAPI extends APIBase { class BizDeliverAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.bizDeliveryS = system.getObject("service.bizchance.deliverybillSve") this.bizDeliveryS = system.getObject('service.bizchance.deliverybillSve');
this.dateUtil = system.getObject("util.dateClient"); this.dateUtil = system.getObject('util.dateClient');
} }
async statBizDeliveryCountBySp(p, q, req) { async statBizDeliveryCountBySp(p, q, req) {
let bizStatus = p.bizStatus; const { bizStatus } = p;
let betweenTime = this.dateUtil.betweenTime(p.dateType); const betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime) const rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime);
return system.getResult(rtn) return system.getResult(rtn);
} }
async statBizDeliverySettleAmountBySp(p, q, req) { async statBizDeliverySettleAmountBySp(p, q, req) {
let bizStatus = p.bizStatus const { bizStatus } = p;
let rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus) const rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus);
return system.getResult(rtn) return system.getResult(rtn);
} }
/** /**
* 待处理商机beforeSubmission * 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation * 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭 *累计处理商机 包括成单和关闭
* @param {*} p * @param {*} p
* @param {*} q * @param {*} q
* @param {*} req * @param {*} req
*/ */
async statBizDelivery(p, q, req) { async statBizDelivery(p, q, req) {
let companyId = p.company_id const companyId = p.company_id;
let userid = p.userid const { userid } = p;
let username = p.username const { username } = p;
let opath = p.opath const { opath } = p;
let betweenTime = this.dateUtil.betweenTime(p.dateType); const betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime) const rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn) return system.getResult(rtn);
} }
classDesc() { classDesc() {
return { return {
groupName: "auth", groupName: 'auth',
groupDesc: "认证相关的包", groupDesc: '认证相关的包',
name: "AccessAuthAPI", name: 'AccessAuthAPI',
desc: "关于认证的类", desc: '关于认证的类',
exam: ` exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey post http://p.apps.com/api/auth/accessAuth/getAccessKey
{ {
appKey:xxxxx, appKey:xxxxx,
secret:yyyyyy secret:yyyyyy
} }
`, `,
}; };
} }
methodDescs() { methodDescs() {
return [ return [
{ {
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中", methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: "getAccessKey", methodName: 'getAccessKey',
paramdescs: [ paramdescs: [
{ {
paramDesc: "访问appkey", paramDesc: '访问appkey',
paramName: "appkey", paramName: 'appkey',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
}, },
{ {
paramDesc: "访问secret", paramDesc: '访问secret',
paramName: "secret", paramName: 'secret',
paramType: "string", paramType: 'string',
defaultValue: "", defaultValue: '',
} },
], ],
rtnTypeDesc: "返回JSON对象字符串", rtnTypeDesc: '返回JSON对象字符串',
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例" rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
}, },
]; ];
} }
exam() { exam() {
return `` return ``;
} }
} }
module.exports = BizDeliverAPI; module.exports = BizDeliverAPI;
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class AppAPI extends APIBase { class AppAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.appS = system.getObject("service.common.appSve"); this.appS = system.getObject('service.common.appSve');
} }
async create(pobj,q,req){ async create(pobj, q, req) {
console.log("oooooooooooooooooooooooooooooooooooooooooooooooo") console.log('oooooooooooooooooooooooooooooooooooooooooooooooo');
console.log(req.xctx) console.log(req.xctx);
let rtn=this.appS.create(pobj,q,req); const rtn = this.appS.create(pobj, q, req);
return system.getResult(rtn); return system.getResult(rtn);
} }
async del(pobj,q,req){ async del(pobj, q, req) {
let rtn=this.appS.delete(pobj,q,req); const rtn = this.appS.delete(pobj, q, req);
return system.getResult(rtn); return system.getResult(rtn);
} }
classDesc() { classDesc() {
return { return {
groupName: "auth", groupName: 'auth',
groupDesc: "认证相关的包", groupDesc: '认证相关的包',
name: "AccessAuthAPI", name: 'AccessAuthAPI',
desc: "关于认证的类", desc: '关于认证的类',
exam: ` exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey post http://p.apps.com/api/auth/accessAuth/getAccessKey
{ {
appKey:xxxxx, appKey:xxxxx,
secret:yyyyyy secret:yyyyyy
} }
`, `,
}; };
} }
methodDescs() { methodDescs() {
return [ return [
]; ];
} }
exam() { exam() {
return `` return ``;
} }
} }
module.exports = AppAPI; module.exports = AppAPI;
var APIBase = require("../../api.base"); const APIBase = require('../../api.base');
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const crypto = require('crypto'); const crypto = require('crypto');
var fs=require("fs"); const fs = require('fs');
var accesskey='3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5'; const accesskey = '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
var accessKeyId='LTAI4GC5tSKvqsH2hMqj6pvd'; const accessKeyId = 'LTAI4GC5tSKvqsH2hMqj6pvd';
var url="https://gsb-zc.oss-cn-beijing.aliyuncs.com"; const url = 'https://gsb-zc.oss-cn-beijing.aliyuncs.com';
class OSSAPI extends APIBase{ class OSSAPI extends APIBase {
constructor(){ constructor() {
super() super();
} }
async getOssConfig(){ async getOssConfig() {
var policyText = { const policyText = {
"expiration":"2119-12-31T16:00:00.000Z", expiration: '2119-12-31T16:00:00.000Z',
"conditions":[ conditions: [
["content-length-range",0,1048576000], ['content-length-range', 0, 1048576000],
["starts-with","$key","zc"] ['starts-with', '$key', 'zc'],
] ],
}; };
var b = new Buffer(JSON.stringify(policyText)); const b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64'); const policyBase64 = b.toString('base64');
var signature= crypto.createHmac('sha1',accesskey).update(policyBase64).digest().toString('base64'); //base64 const signature = crypto.createHmac('sha1', accesskey).update(policyBase64)
.digest()
.toString('base64'); // base64
var data={ const data = {
OSSAccessKeyId:accessKeyId, OSSAccessKeyId: accessKeyId,
policy:policyBase64, policy: policyBase64,
Signature:signature, Signature: signature,
Bucket:'gsb-zc', Bucket: 'gsb-zc',
success_action_status:201, success_action_status: 201,
url:url url,
}; };
return system.getResult(data); return system.getResult(data);
};
async upfile(srckey, dest) {
const oss = System.getObject('util.ossClient');
const result = await oss.upfile(srckey, `/tmp/${dest}`);
return result;
};
async downfile(srckey) {
const oss = System.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`;
return downfile;
});
return downfile;
}; };
async upfile(srckey,dest){
var oss=System.getObject("util.ossClient");
var result=await oss.upfile(srckey,"/tmp/"+dest);
return result;
};
async downfile(srckey){
var oss=System.getObject("util.ossClient");
var downfile=await oss.downfile(srckey).then(function(){
downfile="/tmp/"+srckey;
return downfile;
});
return downfile;
};
} }
module.exports=OSSAPI; module.exports = OSSAPI;
const system = require("../system"); const system = require('../system');
const settings = require("../../config/settings"); const settings = require('../../config/settings');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class CtlBase { class CtlBase {
constructor(gname, sname) { constructor(gname, sname) {
this.serviceName = sname; this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname); this.service = system.getObject(`service.${gname}.${sname}`);
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject('db.common.cacheManager');
this.logClient = system.getObject("util.logClient"); this.logClient = system.getObject('util.logClient');
} }
static getServiceName(ClassObj) { static getServiceName(ClassObj) {
return `${ClassObj.name.substring(0, ClassObj.name.lastIndexOf('Ctl')).toLowerCase()}Sve`;
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
} }
async update(pobj, qobj, req) { async update(pobj, qobj, req) {
const up = await this.service.update(pobj); const up = await this.service.update(pobj);
...@@ -25,79 +24,79 @@ class CtlBase { ...@@ -25,79 +24,79 @@ class CtlBase {
return system.getResult(up); return system.getResult(up);
} }
async findAndCountAll(pobj, qobj, req) { async findAndCountAll(pobj, qobj, req) {
//设置查询条件 // 设置查询条件
console.log(pobj) console.log(pobj);
const rs = await this.service.findAndCountAll(pobj); const rs = await this.service.findAndCountAll(pobj);
return system.getResult(rs); return system.getResult(rs);
} }
async refQuery(pobj, qobj, req) { async refQuery(pobj, qobj, req) {
pobj.refwhere.app_id = pobj.app_id; pobj.refwhere.app_id = pobj.app_id;
pobj.refwhere.company_id = pobj.company_id; pobj.refwhere.company_id = pobj.company_id;
let rtn = await this.service.refQuery(pobj); const rtn = await this.service.refQuery(pobj);
return rtn return rtn;
} }
async setContextParams(pobj, qobj, req) { async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null; const custtags = req.headers['x-consumetag'] ? req.headers['x-consumetag'].split('|') : null;
let lastindex = custtags ? custtags.length - 1 : 0; const lastindex = custtags ? custtags.length - 1 : 0;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值 // 当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = { req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色 appkey: req.headers.xappkey, // 用于系统管理区分应用,比如角色
fromappkey: req.headers["xfromappkey"],//来源APP,如果没有来源与appkey相同 fromappkey: req.headers.xfromappkey, // 来源APP,如果没有来源与appkey相同
companyid: custtags ? custtags[0].split("_")[1] : null, companyid: custtags ? custtags[0].split('_')[1] : null,
fromcompanykey: req.headers["xfromcompanykey"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司 fromcompanykey: req.headers.xfromcompanykey, // 专用于自由用户注册,自由用户用于一定属于某个存在的公司
password: custtags ? custtags[lastindex].split("_")[1] : null, password: custtags ? custtags[lastindex].split('_')[1] : null,
username: req.headers["x-consumer-username"], username: req.headers['x-consumer-username'],
userid: req.headers["x-consumer-custom-id"], userid: req.headers['x-consumer-custom-id'],
credid: req.headers["x-credential-identifier"], credid: req.headers['x-credential-identifier'],
regrole: req.headers["xregrole"], regrole: req.headers.xregrole,
bizpath: req.headers["xbizpath"], bizpath: req.headers.xbizpath,
opath: req.headers['xopath'], opath: req.headers.xopath,
ptags: req.headers['xptags'], ptags: req.headers.xptags,
codename: req.headers["xcodename"], codename: req.headers.xcodename,
codetitle: req.headers["xcodetitle"] ? decodeURI(req.headers["xcodetitle"]) : '', codetitle: req.headers.xcodetitle ? decodeURI(req.headers.xcodetitle) : '',
} };
//添加组织结构路径,如果是上级,取上级 // 添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") { if (req.xctx.ptags && req.xctx.ptags != '') {
pobj.opath = req.xctx.ptags pobj.opath = req.xctx.ptags;
pobj.isPrincipal = true pobj.isPrincipal = true;
} else { } else {
pobj.opath = req.xctx.opath pobj.opath = req.xctx.opath;
pobj.isPrincipal = false pobj.isPrincipal = false;
} }
if (!req.xctx.appkey) { if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"] return [-200, '请求头缺少应用x-app-key'];
} else {
// let app=await this.cacheManager["AppCache"].cache(req.xctx.fromappkey);
// req.xctx.appid=app.id;
// if(!pobj.app_id){
// pobj.app_id=app.id;//传递参数对象里注入app_id
// }
} }
//平台注册时,companyid,companykey都为空 // let app=await this.cacheManager["AppCache"].cache(req.xctx.fromappkey);
//自由注册时,companykey不能为空 // req.xctx.appid=app.id;
// if(!pobj.app_id){
// pobj.app_id=app.id;//传递参数对象里注入app_id
// }
// 平台注册时,companyid,companykey都为空
// 自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){ // if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"] // return [-200,"请求头缺少应用x-app-key"]
// } // }
if (!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey != "null" && req.xctx.fromcompanykey != 'undefined') { if (!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey != 'null' && req.xctx.fromcompanykey != 'undefined') {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey); const comptmp = await this.cacheManager.CompanyCache.cache(req.xctx.fromcompanykey);
req.xctx.companyid = comptmp.id; req.xctx.companyid = comptmp.id;
} }
if (req.xctx.companyid) {//在请求传递数据对象注入公司id if (req.xctx.companyid) { // 在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid; pobj.company_id = req.xctx.companyid;
} }
if (req.xctx.userid) {//在请求传递数据对象注入公司id if (req.xctx.userid) { // 在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid; pobj.userid = req.xctx.userid;
pobj.username = req.xctx.username pobj.username = req.xctx.username;
} }
pobj.bizpath = req.xctx.bizpath; pobj.bizpath = req.xctx.bizpath;
} }
async doexec(methodname, pobj, query, req) { async doexec(methodname, pobj, query, req) {
try { try {
let xarg = await this.setContextParams(pobj, query, req); const xarg = await this.setContextParams(pobj, query, req);
if (xarg && xarg[0] < 0) { if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg); return system.getResultFail(...xarg);
} }
//从请求头里面取appkey_consumename // 从请求头里面取appkey_consumename
// var consumeName=req.headers[""] // var consumeName=req.headers[""]
// var appkey= // var appkey=
// if( this.session["appkey_consumename"]) { // if( this.session["appkey_consumename"]) {
...@@ -107,15 +106,15 @@ class CtlBase { ...@@ -107,15 +106,15 @@ class CtlBase {
// //appkey_consumename // //appkey_consumename
// this.session={}; // this.session={};
// } // }
//req.session=redis缓存的上下文对象 // req.session=redis缓存的上下文对象
console.log(`调用方法为 ----- ${methodname}`); console.log(`调用方法为 ----- ${methodname}`);
var rtn = await this[methodname](pobj, query, req); const rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn) this.logClient.log(pobj, req, rtn);
return rtn; return rtn;
} catch (e) { } catch (e) {
this.logClient.log(pobj, req, null, e.stack); this.logClient.log(pobj, req, null, e.stack);
console.log(e.stack, "出现异常,请联系管理员......."); console.log(e.stack, '出现异常,请联系管理员.......');
return system.getResultFail(-200, "出现异常,请联系管理员"); return system.getResultFail(-200, '出现异常,请联系管理员');
} }
} }
} }
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
class AuthCtl extends CtlBase{ class AuthCtl extends CtlBase {
constructor(){ constructor() {
super("auth",CtlBase.getServiceName(AuthCtl)); super('auth', CtlBase.getServiceName(AuthCtl));
} }
async saveAuths(pobj,query,req){ async saveAuths(pobj, query, req) {
var auths=pobj.auths; const { auths } = pobj;
var xrtn=await this.service.saveAuths(auths,pobj.app_id,pobj.company_id); const xrtn = await this.service.saveAuths(auths, pobj.app_id, pobj.company_id);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
async findAuthsByRoles(pobj,query,req){ async findAuthsByRoles(pobj, query, req) {
var roleids=pobj.roleids; const { roleids } = pobj;
var xrtn=await this.service.findAuthsByRole(roleids,pobj.app_id,pobj.company_id); const xrtn = await this.service.findAuthsByRole(roleids, pobj.app_id, pobj.company_id);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
} }
module.exports=AuthCtl; module.exports = AuthCtl;
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const logCtl = system.getObject("web.common.oplogCtl"); const logCtl = system.getObject('web.common.oplogCtl');
class DataauthCtl extends CtlBase{ class DataauthCtl extends CtlBase {
constructor(){ constructor() {
super("auth",CtlBase.getServiceName(DataauthCtl)); super('auth', CtlBase.getServiceName(DataauthCtl));
}
async saveauth(qobj,querybij,req){
var arys=qobj.arys;
var uid=qobj.uid;
var refmodel=qobj.modelname;
var u=await this.service.saveauth({
user_id:uid,
modelname:refmodel,
auths:arys.join(","),
app_id:req.appid,
});
return system.getResult(u);
} }
async fetchInitAuth(qobj,querybij,req){ async saveauth(qobj, querybij, req) {
var uid=qobj.uid; const { arys } = qobj;
var refmodel=qobj.modelname; const { uid } = qobj;
var authtmp=await this.service.findOne({user_id:uid,modelname:refmodel,app_id:req.appid}); const refmodel = qobj.modelname;
if(authtmp){ const u = await this.service.saveauth({
var auths= authtmp.auths; user_id: uid,
var arys=auths.split(","); modelname: refmodel,
auths: arys.join(','),
app_id: req.appid,
});
return system.getResult(u);
}
async fetchInitAuth(qobj, querybij, req) {
const { uid } = qobj;
const refmodel = qobj.modelname;
const authtmp = await this.service.findOne({ user_id: uid, modelname: refmodel, app_id: req.appid });
if (authtmp) {
const { auths } = authtmp;
const arys = auths.split(',');
return system.getResult(arys); return system.getResult(arys);
}else{
return system.getResultSuccess([]);
} }
return system.getResultSuccess([]);
} }
} }
module.exports=DataauthCtl; module.exports = DataauthCtl;
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const logCtl = system.getObject("web.common.oplogCtl"); const logCtl = system.getObject('web.common.oplogCtl');
class OrgCtl extends CtlBase{ class OrgCtl extends CtlBase {
constructor(){ constructor() {
super("auth",CtlBase.getServiceName(OrgCtl)); super('auth', CtlBase.getServiceName(OrgCtl));
// this.compSvr=system.getObject("service.common.companySve"); // this.compSvr=system.getObject("service.common.companySve");
} }
//检查是否已经存在主要岗位 // 检查是否已经存在主要岗位
async checkMainPosition(p,q,req){ async checkMainPosition(p, q, req) {
return this.service.checkMainPosition(p,q,req); return this.service.checkMainPosition(p, q, req);
} }
async changePos(p,q,req){ async changePos(p, q, req) {
var toorgid=p.orgid; const toorgid = p.orgid;
var uid=p.uid; const { uid } = p;
var rtn= await this.service.changePos(toorgid,uid); const rtn = await this.service.changePos(toorgid, uid);
return system.getResult(rtn); return system.getResult(rtn);
} }
async create(p,q,req){ async create(p, q, req) {
return super.create(p, q, req);
return super.create(p,q,req); }
} async delete(p, q, req) {
async delete(p,q,req){ return super.delete(p, q, req);
return super.delete(p,q,req); }
} async update(p, q, req) {
async update(p,q,req){ return super.update(p, q, req);
return super.update(p,q,req); }
} async initOrgs(p, q, req) {
async initOrgs(p,q,req){ let { tocompany } = req.session;
var tocompany=req.session.tocompany; const cmkey = p.comkey;
var cmkey=p.comkey; if (cmkey) {
if(cmkey){ tocompany = await this.compSvr.findOne({ companykey: cmkey });
tocompany =await this.compSvr.findOne({companykey:cmkey});
} }
//按照公司名称查询,是否存在节点,不存在,就创建根节点 // 按照公司名称查询,是否存在节点,不存在,就创建根节点
//如果存在就按照名称查询出当前和她的字节点 // 如果存在就按照名称查询出当前和她的字节点
var rtn=await this.service.initOrgs(tocompany,req.appid); const rtn = await this.service.initOrgs(tocompany, req.appid);
return system.getResult(rtn);
}
async findOrgById(p,q,req){
var rtn=await this.service.findOrgById(p.id);
return system.getResult(rtn); return system.getResult(rtn);
} }
async findOrgById(p, q, req) {
const rtn = await this.service.findOrgById(p.id);
return system.getResult(rtn);
}
} }
module.exports=OrgCtl; module.exports = OrgCtl;
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const logCtl = system.getObject("web.common.oplogCtl"); const logCtl = system.getObject('web.common.oplogCtl');
var cacheBaseComp = null; const cacheBaseComp = null;
class RoleCtl extends CtlBase { class RoleCtl extends CtlBase {
constructor() { constructor() {
super("auth",CtlBase.getServiceName(RoleCtl)); super('auth', CtlBase.getServiceName(RoleCtl));
this.redisClient=system.getObject("util.redisClient"); this.redisClient = system.getObject('util.redisClient');
} }
async initNewInstance(pobj,queryobj, req) { async initNewInstance(pobj, queryobj, req) {
var rtn = {}; const rtn = {};
rtn.roles = []; rtn.roles = [];
return system.getResultSuccess(rtn); return system.getResultSuccess(rtn);
} }
async create(pobj,queryobj, req) { async create(pobj, queryobj, req) {
let r=await super.create(pobj,queryobj, req) const r = await super.create(pobj, queryobj, req);
return system.getResult(r); return system.getResult(r);
} }
} }
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
class UserCtl extends CtlBase { class UserCtl extends CtlBase {
constructor() { constructor() {
super("auth", CtlBase.getServiceName(UserCtl)); super('auth', CtlBase.getServiceName(UserCtl));
} }
async resetPassword(pobj, qobj, req){ async resetPassword(pobj, qobj, req) {
await this.service.resetPassword(req.xctx.username,pobj.onepassword) await this.service.resetPassword(req.xctx.username, pobj.onepassword);
return system.getResult({}); return system.getResult({});
} }
async allowOrNot(pobj, qobj, req){ async allowOrNot(pobj, qobj, req) {
await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{company_id:pobj.company_id}) await this.service.updateByWhere({ isEnabled: !pobj.isEnabled }, { company_id: pobj.company_id });
return system.getResult({}); return system.getResult({});
} }
async initNewInstance(queryobj, req) { async initNewInstance(queryobj, req) {
var rtn = {}; const rtn = {};
rtn.roles = []; rtn.roles = [];
return system.getResultSuccess(rtn); return system.getResultSuccess(rtn);
} }
//获取验证码,发送给指定手机 // 获取验证码,发送给指定手机
// async sendVCode(pobj, qobj, req) { // async sendVCode(pobj, qobj, req) {
// var mobile = pobj.mobile; // var mobile = pobj.mobile;
// let v = await this.smsS.sendVCode(mobile); // let v = await this.smsS.sendVCode(mobile);
...@@ -30,82 +30,82 @@ class UserCtl extends CtlBase { ...@@ -30,82 +30,82 @@ class UserCtl extends CtlBase {
async exit(pobj, qobj, req) { async exit(pobj, qobj, req) {
} }
//应用的自由用户注册,无需验证,需要前端头设置公司KEY // 应用的自由用户注册,无需验证,需要前端头设置公司KEY
async pmregisterByFreeUser(p, q, req) { async pmregisterByFreeUser(p, q, req) {
//检查是否有用户名和密码 // 检查是否有用户名和密码
if (!pobj.userName || !pobj.password) { if (!pobj.userName || !pobj.password) {
return system.getResult(null, "请检查用户名和密码是否存在") return system.getResult(null, '请检查用户名和密码是否存在');
} }
//p.company_id = req.xctx.companyid;//控制基类里已经添加 // p.company_id = req.xctx.companyid;//控制基类里已经添加
if (!p.company_id) { if (!p.company_id) {
return system.getResultFail(-201, "自有用户创建需要提供公司KEY"); return system.getResultFail(-201, '自有用户创建需要提供公司KEY');
} }
let rtn = await this.service.pmregisterByFreeUser(p, q); const rtn = await this.service.pmregisterByFreeUser(p, q);
return rtn; return rtn;
} }
async create(p, q, req){ async create(p, q, req) {
//检查是否有用户名和密码 // 检查是否有用户名和密码
if (!p.userName) { if (!p.userName) {
return system.getResult(null, "请检查用户名和密码是否存在") return system.getResult(null, '请检查用户名和密码是否存在');
} }
let rtn = await this.service.registerByTantent(p, q); const rtn = await this.service.registerByTantent(p, q);
return system.getResult(rtn); return system.getResult(rtn);
} }
//登录后的租户创建属于租户的用户 // 登录后的租户创建属于租户的用户
//需要在控制器里取出公司ID // 需要在控制器里取出公司ID
//和租户绑定同一家公司 // 和租户绑定同一家公司
//按照用户名和密码进行注册 // 按照用户名和密码进行注册
//控制器端检查用户名和密码非空 // 控制器端检查用户名和密码非空
async registerByTantent(p, q, req) { async registerByTantent(p, q, req) {
//检查是否有用户名和密码 // 检查是否有用户名和密码
if (!pobj.userName) { if (!pobj.userName) {
return system.getResult(null, "请检查用户名和密码是否存在") return system.getResult(null, '请检查用户名和密码是否存在');
} }
let rtn = await this.service.registerByTantent(p, q); const rtn = await this.service.registerByTantent(p, q);
return rtn; return rtn;
} }
//租户用户名和密码的租户注册 // 租户用户名和密码的租户注册
async pmregister(pobj, qobj, req) { async pmregister(pobj, qobj, req) {
//平台注册设置平台的应用ID // 平台注册设置平台的应用ID
pobj.app_id = settings.pmappid; pobj.app_id = settings.pmappid;
//检查是否有用户名和密码 // 检查是否有用户名和密码
if (!pobj.userName || !pobj.password) { if (!pobj.userName || !pobj.password) {
return system.getResult(null, "请检查用户名和密码是否存在") return system.getResult(null, '请检查用户名和密码是否存在');
} }
var rtn = await this.service.pmregister(pobj); const rtn = await this.service.pmregister(pobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
async pmlogin(pobj, qobj, req) { async pmlogin(pobj, qobj, req) {
//平台注册设置平台的应用ID // 平台注册设置平台的应用ID
let rtn = await this.service.pmlogin(pobj, qobj, req); const rtn = await this.service.pmlogin(pobj, qobj, req);
return system.getResult(rtn); return system.getResult(rtn);
} }
async getUserInfo(pobj, qobj, req) { async getUserInfo(pobj, qobj, req) {
let uname = req.xctx.username; const uname = req.xctx.username;
let rtn = await this.service.getUserInfo(uname); const rtn = await this.service.getUserInfo(uname);
return system.getResult(rtn); return system.getResult(rtn);
} }
//按照电话创建自由用户 // 按照电话创建自由用户
async pmloginByVCodeForFreeUser(p, q, req) { async pmloginByVCodeForFreeUser(p, q, req) {
if (!pobj.mobile || !pobj.vcode) { if (!pobj.mobile || !pobj.vcode) {
return system.getResult(null, "请检查手机号和验证码是否存在") return system.getResult(null, '请检查手机号和验证码是否存在');
} }
p.companykey = req.xctx.companykey; p.companykey = req.xctx.companykey;
if (!p.companykey) { if (!p.companykey) {
return system.getResult(null, "自有用户创建需要提供公司KEY"); return system.getResult(null, '自有用户创建需要提供公司KEY');
} }
let rtn = await this.service.pmloginByVCodeForFreeUser(p, q); const rtn = await this.service.pmloginByVCodeForFreeUser(p, q);
return rtn; return rtn;
} }
async pmloginByVCode(pobj, qobj, req) { async pmloginByVCode(pobj, qobj, req) {
let rtn = await this.service.pmloginByVCode(pobj, qobj); const rtn = await this.service.pmloginByVCode(pobj, qobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
async pmSendVCode(pobj, qobj, req) { async pmSendVCode(pobj, qobj, req) {
let rtn = await this.service.sendVCode(pobj, qobj); const rtn = await this.service.sendVCode(pobj, qobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
} }
......
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class FitaxcompanyCtl extends CtlBase { class FitaxcompanyCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(FitaxcompanyCtl)); super('bizchance', CtlBase.getServiceName(FitaxcompanyCtl));
} }
/** /**
* 根据需求编号查询企业信息 * 根据需求编号查询企业信息
* @param {*} mobj * @param {*} mobj
*/ */
async findOne(mobj, qobj, req) { async findOne(mobj, qobj, req) {
let pobj = mobj.d; const pobj = mobj.d;
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/findOne 缺少需求编号!"); return system.getResultError('fitaxschemeCtl/findOne 缺少需求编号!');
} }
let res = await this.service.findInfo(pobj); const res = await this.service.findInfo(pobj);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log("fitaxschemeCtl/findOne " + error); console.log(`fitaxschemeCtl/findOne ${error}`);
return system.getResultError("fitaxschemeCtl/findOne 查询企业失败!"); return system.getResultError('fitaxschemeCtl/findOne 查询企业失败!');
}
} }
}
/** /**
* 新建&更新企业信息 * 新建&更新企业信息
* @param {*} mobj * @param {*} mobj
*/ */
async insertOrUpdateInfo(mobj, qobj, req) { async insertOrUpdateInfo(mobj, qobj, req) {
let pobj = mobj.d; const pobj = mobj.d;
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!"); return system.getResultError('fitaxschemeCtl/insertInfo 缺少需求编号!');
} }
let findRes = await this.service.findInfo(pobj); const findRes = await this.service.findInfo(pobj);
if (!findRes) { if (!findRes) {
let insertRes = await this.service.insertInfo(pobj); const insertRes = await this.service.insertInfo(pobj);
return system.getResult("添加企业成功!"); return system.getResult('添加企业成功!');
} }
let updateRes = await this.service.updateInfo(pobj); const updateRes = await this.service.updateInfo(pobj);
return system.getResult("修改企业信息成功!"); return system.getResult('修改企业信息成功!');
} catch (error) { } catch (error) {
console.log("fitaxschemeCtl/insertOrUpdateInfo " + error); console.log(`fitaxschemeCtl/insertOrUpdateInfo ${error}`);
return system.getResultError("fitaxschemeCtl/insertOrUpdateInfo 添加&修改企业信息失败!"); return system.getResultError('fitaxschemeCtl/insertOrUpdateInfo 添加&修改企业信息失败!');
}
} }
}
} }
module.exports = FitaxcompanyCtl; module.exports = FitaxcompanyCtl;
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const { json, JSON } = require("sequelize"); const { json, JSON } = require('sequelize');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class FitaxpushqueueCtl extends CtlBase { class FitaxpushqueueCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(FitaxpushqueueCtl)); super('bizchance', CtlBase.getServiceName(FitaxpushqueueCtl));
this.rysUrl = settings.rysUrl(); this.rysUrl = settings.rysUrl();
} }
/** /**
* 新建信息 * 新建信息
* @param {*} mobj * @param {*} mobj
*/ */
async insertInfo(pobj, qobj, req) { async insertInfo(pobj, qobj, req) {
try { try {
if (!pobj.delivery_code || !pobj.current_period) { if (!pobj.delivery_code || !pobj.current_period) {
return system.getResultError("FitaxpushqueueCtl/insertInfo 缺少必要参数!"); return system.getResultError('FitaxpushqueueCtl/insertInfo 缺少必要参数!');
} }
let res = await this.service.insertInfo(pobj); const res = await this.service.insertInfo(pobj);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log("FitaxpushqueueCtl/insertInfo---------------------------------------------------------------- " + error); console.log(`FitaxpushqueueCtl/insertInfo---------------------------------------------------------------- ${error}`);
return system.getResultError("FitaxpushqueueCtl/insertInfo 新建方案出错!"); return system.getResultError('FitaxpushqueueCtl/insertInfo 新建方案出错!');
}
} }
}
/** /**
* @param {*} pobj * @param {*} pobj
* @param {*} qobj * @param {*} qobj
* @param {*} req * @param {*} req
*/ */
async updateInfo(pobj, qobj, req) { async updateInfo(pobj, qobj, req) {
let obj = {}; const obj = {};
if (pobj.actionBody.bizNo) { if (pobj.actionBody.bizNo) {
obj.demand_code = pobj.actionBody.bizNo; obj.demand_code = pobj.actionBody.bizNo;
} }
if (pobj.actionBody.accountDate) { if (pobj.actionBody.accountDate) {
obj.current_period = pobj.actionBody.pobj.actionBody.accountDate; obj.current_period = pobj.actionBody.pobj.actionBody.accountDate;
} }
if (pobj.actionBody.dataType){ if (pobj.actionBody.dataType) {
obj.data_type = pobj.actionBody.dataType; obj.data_type = pobj.actionBody.dataType;
} }
if (pobj.actionBody.reqData){ if (pobj.actionBody.reqData) {
obj.req_data = pobj.actionBody.reqData; obj.req_data = pobj.actionBody.reqData;
} }
if (pobj.actionBody.resData){ if (pobj.actionBody.resData) {
obj.res_data = pobj.actionBody.resData; obj.res_data = pobj.actionBody.resData;
} }
if (pobj.actionBody.rysCheck){ if (pobj.actionBody.rysCheck) {
obj.rys_check = pobj.actionBody.rysCheck; obj.rys_check = pobj.actionBody.rysCheck;
} }
if (pobj.actionBody.pushStatus){ if (pobj.actionBody.pushStatus) {
obj.push_status = pobj.actionBody.pushStatus; obj.push_status = pobj.actionBody.pushStatus;
} }
if (pobj.actionBody.checkDate){ if (pobj.actionBody.checkDate) {
obj.check_date = pobj.actionBody.checkDate; obj.check_date = pobj.actionBody.checkDate;
} }
try { try {
let res = await this.service.updateInfo(obj); const res = await this.service.updateInfo(obj);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log("fitaxschemeCtl/updateInfo error: " + error); console.log(`fitaxschemeCtl/updateInfo error: ${error}`);
return system.getResultError("updateInfo error: " + error) return system.getResultError(`updateInfo error: ${error}`);
}
} }
}
} }
module.exports = FitaxpushqueueCtl; module.exports = FitaxpushqueueCtl;
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class OperationrecordCtl extends CtlBase { class OperationrecordCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(OperationrecordCtl)); super('bizchance', CtlBase.getServiceName(OperationrecordCtl));
this.bizoptSve = system.getObject("service.bizchance.bizoptSve"); this.bizoptSve = system.getObject('service.bizchance.bizoptSve');
} }
/** /**
* 查询记录信息 * 查询记录信息
* @param {*} mobj * @param {*} mobj
* { * {
...@@ -16,21 +16,21 @@ class OperationrecordCtl extends CtlBase { ...@@ -16,21 +16,21 @@ class OperationrecordCtl extends CtlBase {
operation_type: ""//可选,操作类型 operation_type: ""//可选,操作类型
} }
*/ */
async findAllInfo(mobj, qobj, req) { async findAllInfo(mobj, qobj, req) {
let pobj = mobj.d; const pobj = mobj.d;
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("operationrecordCtl/findAllInfo 缺少需求编号!"); return system.getResultError('operationrecordCtl/findAllInfo 缺少需求编号!');
} }
let res = await this.service.findAllInfo(pobj); const res = await this.service.findAllInfo(pobj);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log("operationrecordCtl/findAllInfo " + error); console.log(`operationrecordCtl/findAllInfo ${error}`);
return system.getResultError("operationrecordCtl/findAllInfo 查询企业失败!"); return system.getResultError('operationrecordCtl/findAllInfo 查询企业失败!');
}
} }
}
/** /**
* 新建记录信息 * 新建记录信息
* @param {*} mobj * @param {*} mobj
* { * {
...@@ -39,37 +39,37 @@ class OperationrecordCtl extends CtlBase { ...@@ -39,37 +39,37 @@ class OperationrecordCtl extends CtlBase {
operation_details: {}//操作详细记录 operation_details: {}//操作详细记录
} }
*/ */
async insertInfo(mobj, qobj, req) { async insertInfo(mobj, qobj, req) {
let pobj = mobj.d; const pobj = mobj.d;
//取请求头中的userid和name // 取请求头中的userid和name
pobj.operator = { pobj.operator = {
id: mobj.userid ? mobj.userid : "", id: mobj.userid ? mobj.userid : '',
name: mobj.username ? mobj.username : "" name: mobj.username ? mobj.username : '',
} };
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!"); return system.getResultError('fitaxschemeCtl/insertInfo 缺少需求编号!');
} }
if (pobj.operation_type == "followUp") { if (pobj.operation_type == 'followUp') {
if (pobj.operation_details.intention) { if (pobj.operation_details.intention) {
let obj = { demand_code: pobj.demand_code } const obj = { demand_code: pobj.demand_code };
if (pobj.operation_details.intention == "方案") { if (pobj.operation_details.intention == '方案') {
//状态修改为 '待确认方案' // 状态修改为 '待确认方案'
obj.business_status = "beforeSubmission"; obj.business_status = 'beforeSubmission';
} else { } else {
//状态修改为'跟进中' // 状态修改为'跟进中'
obj.business_status = "followingUp"; obj.business_status = 'followingUp';
} }
let bizoptRes = await this.bizoptSve.updateStatusByDemandCode(obj); const bizoptRes = await this.bizoptSve.updateStatusByDemandCode(obj);
}
}
let insertRes = await this.service.insertInfo(pobj);
return system.getResult("添加记录信息成功!");
} catch (error) {
console.log("operationrecordCtl/insertInfo " + error);
return system.getResultError("operationrecordCtl/insertInfo 添加记录信息失败!");
} }
}
const insertRes = await this.service.insertInfo(pobj);
return system.getResult('添加记录信息成功!');
} catch (error) {
console.log(`operationrecordCtl/insertInfo ${error}`);
return system.getResultError('operationrecordCtl/insertInfo 添加记录信息失败!');
} }
}
} }
module.exports = OperationrecordCtl; module.exports = OperationrecordCtl;
var system = require("../../../system"); const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class SettleBillCtl extends CtlBase { class SettleBillCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(SettleBillCtl)); super('bizchance', CtlBase.getServiceName(SettleBillCtl));
} }
async advice(p,q,req){ async advice(p, q, req) {
let sid= p.advice.settleId const sid = p.advice.settleId;
let msg=p.advice.memo const msg = p.advice.memo;
let userid=p.userid const { userid } = p;
let userName=p.username const userName = p.username;
let rtn=await this.service.advice(sid,msg,userid,userName) const rtn = await this.service.advice(sid, msg, userid, userName);
return system.getResult(rtn) return system.getResult(rtn);
} }
async auditPass(p,q,req){ async auditPass(p, q, req) {
let sid= p.pass.settleId const sid = p.pass.settleId;
let rtn=await this.service.auditPass(sid,p.userid,p.username) const rtn = await this.service.auditPass(sid, p.userid, p.username);
return system.getResult(rtn) return system.getResult(rtn);
} }
async pay(p,q,req){ async pay(p, q, req) {
let sid= p.pay.settleId const sid = p.pay.settleId;
let rtn=await this.service.pay(sid,p.userid,p.username) const rtn = await this.service.pay(sid, p.userid, p.username);
return system.getResult(rtn) return system.getResult(rtn);
} }
} }
module.exports = SettleBillCtl; module.exports = SettleBillCtl;
......
var system = require("../../../system"); const system = require('../../../system');
const http = require("http"); const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const moment = require('moment'); const moment = require('moment');
class StatusLogCtl extends CtlBase { class StatusLogCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(StatusLogCtl)); super('bizchance', CtlBase.getServiceName(StatusLogCtl));
} }
/*插入缓存信息 */ /* 插入缓存信息 */
async insertInfo(mobj,qobj,req){ async insertInfo(mobj, qobj, req) {
var pobj = mobj.d; const pobj = mobj.d;
if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined' if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined'
&& pobj.statusCode && pobj.statusCode != 'undefined'){ && pobj.statusCode && pobj.statusCode != 'undefined') {
try{ try {
var res = await this.service.insertInfo(pobj); const res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!"); return system.getResult('插入成功!');
} } catch (error) {
catch (error){ return system.getResultError(error);
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
} }
} else {
return system.getResultError('参数错误!');
}
} }
timeFormat(date) { timeFormat(date) {
let localTime = moment.utc(date).toDate(); let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD"); localTime = moment(localTime).format('YYYY-MM-DD');
return localTime; return localTime;
} }
} }
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
var cacheBaseComp = null; const cacheBaseComp = null;
class AppCtl extends CtlBase { class AppCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(AppCtl)); super('common', CtlBase.getServiceName(AppCtl));
this.userCtl = system.getObject("service.auth.userSve"); this.userCtl = system.getObject('service.auth.userSve');
} }
async findAllApps(p, q, req) { async findAllApps(p, q, req) {
var rtns = await this.service.findAllApps(p.userid); const rtns = await this.service.findAllApps(p.userid);
return system.getResult(rtns); return system.getResult(rtns);
} }
async getApp(p,q,req) { async getApp(p, q, req) {
let app= await this.cacheManager["AppCache"].cache(p.appkey, null); const app = await this.cacheManager.AppCache.cache(p.appkey, null);
return system.getResult({funcJson:JSON.parse(app.functionJSON)}); return system.getResult({ funcJson: JSON.parse(app.functionJSON) });
} }
async translateToRouter(funarray,results,parent){ async translateToRouter(funarray, results, parent) {
funarray.forEach(item=>{ funarray.forEach((item) => {
let result={} const result = {};
result.path=item.code result.path = item.code;
result.name=item.code result.name = item.code;
result.meta={ result.meta = {
hideInMenu: false, hideInMenu: false,
hideInBread:false, hideInBread: false,
notCache: true, notCache: true,
title:item.title, title: item.title,
icon:'replaceIconName' icon: 'replaceIconName',
} };
result.component="replaceRightPath" result.component = 'replaceRightPath';
if(parent){ if (parent) {
parent.children.push(result) parent.children.push(result);
}else{ } else {
results.push(result) results.push(result);
} }
if(item.children && item.children.length>0){ if (item.children && item.children.length > 0) {
result.children=[] result.children = [];
this.translateToRouter(item.children,results,result) this.translateToRouter(item.children, results, result);
} }
}) });
} }
async buildFrontRouter(p,q,req){ async buildFrontRouter(p, q, req) {
let appkey=p.appkey const { appkey } = p;
let app= await this.cacheManager["AppCache"].cache(appkey, null); const app = await this.cacheManager.AppCache.cache(appkey, null);
let funobj=JSON.parse(app.functionJSON) const funobj = JSON.parse(app.functionJSON);
let results=[] const results = [];
await this.translateToRouter(funobj,results,null) await this.translateToRouter(funobj, results, null);
let rtns=await this.service.upFrontRoute(results,app.id) const rtns = await this.service.upFrontRoute(results, app.id);
await this.cacheManager["AppCache"].invalidate(appkey, null); await this.cacheManager.AppCache.invalidate(appkey, null);
return system.getResult({url:rtns.url}) return system.getResult({ url: rtns.url });
} }
async getFuncs(p,q,req){ async getFuncs(p, q, req) {
let appkey=p.appkey const { appkey } = p;
let app= await this.cacheManager["AppCache"].cache(appkey, null); const app = await this.cacheManager.AppCache.cache(appkey, null);
return system.getResult({funcJson:JSON.parse(app.functionJSON)}) return system.getResult({ funcJson: JSON.parse(app.functionJSON) });
//return system.getResult({funcJson:[]}) // return system.getResult({funcJson:[]})
} }
async saveFuncTree(p,q,req){ async saveFuncTree(p, q, req) {
let rtn=await this.service.saveFuncTree(p) const rtn = await this.service.saveFuncTree(p);
return system.getResult(rtn) return system.getResult(rtn);
} }
async create(pobj, queryobj, req) { async create(pobj, queryobj, req) {
pobj.creator_id = pobj.userid;//设置创建者 pobj.creator_id = pobj.userid;// 设置创建者
return super.create(pobj, queryobj, req) return super.create(pobj, queryobj, req);
} }
async update(pobj, queryobj, req) { async update(pobj, queryobj, req) {
return super.update(pobj, queryobj, req); return super.update(pobj, queryobj, req);
} }
async initNewInstance(pobj, queryobj, req) { async initNewInstance(pobj, queryobj, req) {
var rtn = {}; const rtn = {};
rtn.appkey = this.getUUID(); rtn.appkey = this.getUUID();
rtn.secret = this.getUUID(); rtn.secret = this.getUUID();
return system.getResult(rtn); return system.getResult(rtn);
} }
async resetPass(pobj, queryobj, req) { async resetPass(pobj, queryobj, req) {
pobj.password = await super.encryptPasswd(settings.defaultpwd); pobj.password = await super.encryptPasswd(settings.defaultpwd);
var rtn = this.service.resetPass(pobj); const rtn = this.service.resetPass(pobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
async createAdminUser(pobj, queryobj, req) { async createAdminUser(pobj, queryobj, req) {
pobj.password = settings.defaultpwd; pobj.password = settings.defaultpwd;
var rtn = this.service.createAdminUser(pobj); const rtn = this.service.createAdminUser(pobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
async create(pobj, queryobj, req) { async create(pobj, queryobj, req) {
//设置创建者,需要同时创建app管理员、默认密码、电话 // 设置创建者,需要同时创建app管理员、默认密码、电话
pobj.creator_id = pobj.userid; pobj.creator_id = pobj.userid;
// pobj.password=super.encryptPasswd(settings.defaultpwd); // pobj.password=super.encryptPasswd(settings.defaultpwd);
//构造默认的应用相关的URL // 构造默认的应用相关的URL
pobj.authUrl = settings.protocalPrefix + pobj.domainName + "/auth"; pobj.authUrl = `${settings.protocalPrefix + pobj.domainName}/auth`;
pobj.docUrl = settings.protocalPrefix + pobj.domainName + "/web/common/metaCtl/getApiDoc"; pobj.docUrl = `${settings.protocalPrefix + pobj.domainName}/web/common/metaCtl/getApiDoc`;
pobj.uiconfigUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/config/fetchAppConfig"; pobj.uiconfigUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/config/fetchAppConfig`;
pobj.opCacheUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/opCache/opCacheData"; pobj.opCacheUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/opCache/opCacheData`;
pobj.notifyCacheCountUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/opCache/recvNotificationForCacheCount"; pobj.notifyCacheCountUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/opCache/recvNotificationForCacheCount`;
var app = await super.create(pobj, queryobj, req); const app = await super.create(pobj, queryobj, req);
return system.getResult(app); return system.getResult(app);
} }
async fetchApiCallData(pobj, queryobj, req) { async fetchApiCallData(pobj, queryobj, req) {
var curappkey = pobj.curappkey; const { curappkey } = pobj;
//检索出作为访问时的app呼出调用数据 // 检索出作为访问时的app呼出调用数据
var rtn = await this.service.fetchApiCallData(curappkey); const rtn = await this.service.fetchApiCallData(curappkey);
return system.getResultSuccess(rtn); return system.getResultSuccess(rtn);
} }
//接受缓存计数通知接口 // 接受缓存计数通知接口
async recvNotificationForCacheCount(p, q, req) { async recvNotificationForCacheCount(p, q, req) {
return this.service.recvNotificationForCacheCount(p); return this.service.recvNotificationForCacheCount(p);
} }
...@@ -115,9 +114,9 @@ class AppCtl extends CtlBase { ...@@ -115,9 +114,9 @@ class AppCtl extends CtlBase {
module.exports = AppCtl; module.exports = AppCtl;
var p={"appkey":"08cb8300-ef1e-4e35-ba49-3de36ba497d2"} const p = { appkey: '08cb8300-ef1e-4e35-ba49-3de36ba497d2' };
let acl=new AppCtl() const acl = new AppCtl();
acl.buildFrontRouter(p).then(res=>{ acl.buildFrontRouter(p).then((res) => {
console.log(res.data) console.log(res.data);
}) });
\ No newline at end of file
var system = require("../../../system") const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class CachSearchesCtl extends CtlBase { class CachSearchesCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(CachSearchesCtl)); super('common', CtlBase.getServiceName(CachSearchesCtl));
} }
async initNewInstance(queryobj, qobj) { async initNewInstance(queryobj, qobj) {
return system.getResultSuccess({}); return system.getResultSuccess({});
...@@ -15,11 +15,11 @@ class CachSearchesCtl extends CtlBase { ...@@ -15,11 +15,11 @@ class CachSearchesCtl extends CtlBase {
return await this.service.findAndCountAllCache(pobj); return await this.service.findAndCountAllCache(pobj);
} }
async delCache(queryobj, qobj, req) { async delCache(queryobj, qobj, req) {
var param = { key: queryobj.key, appid: req.appid, opCacheUrl: req.session.app.opCacheUrl }; const param = { key: queryobj.key, appid: req.appid, opCacheUrl: req.session.app.opCacheUrl };
return await this.service.delCache(param); return await this.service.delCache(param);
} }
async clearAllCache(queryobj, qobj, req) { async clearAllCache(queryobj, qobj, req) {
var param = { appid: req.appid, opCacheUrl: req.session.app.opCacheUrl }; const param = { appid: req.appid, opCacheUrl: req.session.app.opCacheUrl };
return await this.service.clearAllCache(param); return await this.service.clearAllCache(param);
} }
} }
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
class CompanyCtl extends CtlBase { class CompanyCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(CompanyCtl)); super('common', CtlBase.getServiceName(CompanyCtl));
} }
async update(p,q,req){ async update(p, q, req) {
let u= await super.update(p,q,req) const u = await super.update(p, q, req);
//缓存失效 // 缓存失效
await this.cacheManager["CompanyCache"].invalidate(p.companykey) await this.cacheManager.CompanyCache.invalidate(p.companykey);
let company=await this.cacheManager["CompanyCache"].cache(p.companykey) const company = await this.cacheManager.CompanyCache.cache(p.companykey);
return system.getResult(company) return system.getResult(company);
} }
async setOrgs(p,q,req){ async setOrgs(p, q, req) {
let orgs=await this.service.setOrgs(p,req.xctx.fromcompanykey) const orgs = await this.service.setOrgs(p, req.xctx.fromcompanykey);
return system.getResult(orgs) return system.getResult(orgs);
} }
async getOrgs(p,q,req){ async getOrgs(p, q, req) {
let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey) const companynew = await this.cacheManager.CompanyCache.cache(req.xctx.fromcompanykey);
return system.getResult({orgJson:JSON.parse(companynew.orgJson)}) return system.getResult({ orgJson: JSON.parse(companynew.orgJson) });
} }
} }
module.exports = CompanyCtl; module.exports = CompanyCtl;
var system = require("../../../system") const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
var cacheBaseComp = null; const cacheBaseComp = null;
class MetaCtl extends CtlBase { class MetaCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(MetaCtl)); super('common', CtlBase.getServiceName(MetaCtl));
} }
} }
module.exports = MetaCtl; module.exports = MetaCtl;
var system = require("../../../system") const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
var moment = require("moment"); const moment = require('moment');
class OplogCtl extends CtlBase { class OplogCtl extends CtlBase {
constructor() { constructor() {
super("common",CtlBase.getServiceName(OplogCtl)); super('common', CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve"); // this.appS=system.getObject("service.appSve");
} }
async initNewInstance(qobj) { async initNewInstance(qobj) {
var u = uuidv4(); const u = uuidv4();
var aid = u.replace(/\-/g, ""); const aid = u.replace(/\-/g, '');
var rd = { name: "", appid: aid } const rd = { name: '', appid: aid };
return system.getResult(rd); return system.getResult(rd);
} }
async debug(obj) { async debug(obj) {
obj.logLevel = "debug"; obj.logLevel = 'debug';
return this.create(obj); return this.create(obj);
} }
async info(obj) { async info(obj) {
obj.logLevel = "info"; obj.logLevel = 'info';
return this.create(obj); return this.create(obj);
} }
async warn(obj) { async warn(obj) {
obj.logLevel = "warn"; obj.logLevel = 'warn';
return this.create(obj); return this.create(obj);
} }
async error(obj) { async error(obj) {
obj.logLevel = "error"; obj.logLevel = 'error';
return this.create(obj); return this.create(obj);
} }
async fatal(obj) { async fatal(obj) {
obj.logLevel = "fatal"; obj.logLevel = 'fatal';
return this.create(obj); return this.create(obj);
} }
...@@ -41,17 +41,17 @@ class OplogCtl extends CtlBase { ...@@ -41,17 +41,17 @@ class OplogCtl extends CtlBase {
prefix:业务前缀 prefix:业务前缀
*/ */
async getBusUid_Ctl(prefix) { async getBusUid_Ctl(prefix) {
prefix = (prefix || ""); prefix = (prefix || '');
if (prefix) { if (prefix) {
prefix = prefix.toUpperCase(); prefix = prefix.toUpperCase();
} }
var prefixlength = prefix.length; const prefixlength = prefix.length;
var subLen = 8 - prefixlength; const subLen = 8 - prefixlength;
var uidStr = ""; let uidStr = '';
if (subLen > 0) { if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60); uidStr = await this.getUidInfo_Ctl(subLen, 60);
} }
var timStr = moment().format("YYYYMMDDHHmm"); const timStr = moment().format('YYYYMMDDHHmm');
return prefix + timStr + uidStr; return prefix + timStr + uidStr;
} }
/* /*
...@@ -59,13 +59,13 @@ prefix:业务前缀 ...@@ -59,13 +59,13 @@ prefix:业务前缀
radix:参与计算的长度,最大为62 radix:参与计算的长度,最大为62
*/ */
async getUidInfo_Ctl(len, radix) { async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36 const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
var uuid = [], i; const uuid = []; let i;
radix = radix || chars.length; radix = radix || chars.length;
if (len) { if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else { } else {
var r; let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4'; uuid[14] = '4';
for (i = 0; i < 36; i++) { for (i = 0; i < 36; i++) {
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
var cacheBaseComp = null; const cacheBaseComp = null;
class PConfigCtl extends CtlBase { class PConfigCtl extends CtlBase {
constructor() { constructor() {
super("common",CtlBase.getServiceName(PConfigCtl)); super('common', CtlBase.getServiceName(PConfigCtl));
this.userCtl = system.getObject("service.auth.userSve"); this.userCtl = system.getObject('service.auth.userSve');
} }
async initNewInstance(pobj,queryobj, req) { async initNewInstance(pobj, queryobj, req) {
var rtn = {}; const rtn = {};
return system.getResult(rtn); return system.getResult(rtn);
} }
async create(pobj,queryobj, req) { async create(pobj, queryobj, req) {
pobj.app_id=req.appid; pobj.app_id = req.appid;
pobj.appkey=req.appkey; pobj.appkey = req.appkey;
var rtn=await super.create(pobj,queryobj, req); const rtn = await super.create(pobj, queryobj, req);
return system.getResult(rtn); return system.getResult(rtn);
} }
async update(pobj,queryobj, req) { async update(pobj, queryobj, req) {
pobj.app_id=req.appid; pobj.app_id = req.appid;
pobj.appkey=req.appkey; pobj.appkey = req.appkey;
var rtn=await super.update(pobj); const rtn = await super.update(pobj);
return system.getResult(rtn); return system.getResult(rtn);
} }
} }
......
var system = require("../../../system") const system = require('../../../system');
const http = require("http") const http = require('http');
const querystring = require('querystring'); const querystring = require('querystring');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
var cacheBaseComp = null; const cacheBaseComp = null;
class RouteCtl extends CtlBase { class RouteCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(RouteCtl)); super('common', CtlBase.getServiceName(RouteCtl));
this.appS=system.getObject("service.common.appSve") this.appS = system.getObject('service.common.appSve');
} }
async create(p,q,req){ async create(p, q, req) {
let appid=p.app_id; const appid = p.app_id;
let apptmp= await this.appS.findById(appid) const apptmp = await this.appS.findById(appid);
let routedata={ const routedata = {
name:p.name, name: p.name,
hosts:p.shosts.split(","), hosts: p.shosts.split(','),
paths:p.spaths.split(","), paths: p.spaths.split(','),
isstrip:false, isstrip: false,
app_id:appid, app_id: appid,
shosts:p.shosts, shosts: p.shosts,
spaths:p.spaths spaths: p.spaths,
} };
let rtn= await this.service.create(apptmp.name, routedata, req); const rtn = await this.service.create(apptmp.name, routedata, req);
return system.getResult(rtn) return system.getResult(rtn);
} }
} }
module.exports = RouteCtl; module.exports = RouteCtl;
var system = require("../../../system") const system = require('../../../system');
var settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
class SocketNotifyCtl{ class SocketNotifyCtl {
constructor(){ constructor() {
} }
setSocketServer(s){ setSocketServer(s) {
this.socketServer=s; this.socketServer = s;
} }
//异步推送消息到客户端 // 异步推送消息到客户端
notifyClientMsg(user,msg){ notifyClientMsg(user, msg) {
var uk= this.buildPrivateChannel(user); const uk = this.buildPrivateChannel(user);
var msgHandler=this.socketServer.users[uk]; const msgHandler = this.socketServer.users[uk];
msgHandler.notifyClient(uk,msg); msgHandler.notifyClient(uk, msg);
} }
buildPrivateChannel(user){ buildPrivateChannel(user) {
var ukchannel= user.app_id+"¥"+user.id; const ukchannel = `${user.app_id}${user.id}`;
return ukchannel; return ukchannel;
} }
buildMsgTarget(user){ buildMsgTarget(user) {
var ukchannel= user.app_id+"¥"+user.id; const ukchannel = `${user.app_id}${user.id}`;
var nickName=user.nickName; const { nickName } = user;
var imgUrl=user.imgUrl; const { imgUrl } = user;
var rtn=ukchannel+"¥"+nickName+"¥"+imgUrl; const rtn = `${ukchannel}${nickName}${imgUrl}`;
return rtn; return rtn;
} }
} }
module.exports=SocketNotifyCtl; module.exports = SocketNotifyCtl;
var system=require("../../../system") const system = require('../../../system');
const CtlBase = require("../../ctl.base"); const CtlBase = require('../../ctl.base');
const crypto = require('crypto'); const crypto = require('crypto');
var fs=require("fs"); const fs = require('fs');
var accesskey='3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5'; const accesskey = '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
var accessKeyId='LTAI4GC5tSKvqsH2hMqj6pvd'; const accessKeyId = 'LTAI4GC5tSKvqsH2hMqj6pvd';
var url="https://gsb-zc.oss-cn-beijing.aliyuncs.com"; const url = 'https://gsb-zc.oss-cn-beijing.aliyuncs.com';
class UploadCtl extends CtlBase{ class UploadCtl extends CtlBase {
constructor(){ constructor() {
super("common",CtlBase.getServiceName(UploadCtl)); super('common', CtlBase.getServiceName(UploadCtl));
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'"; this.cmdPdf2HtmlPattern = 'docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 \'{fileName}\'';
this.restS=system.getObject("util.execClient"); this.restS = system.getObject('util.execClient');
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'"; this.cmdInsertToFilePattern = 'sed -i \'s/id="page-container"/id="page-container" contenteditable="true"/\'';
//sed -i 's/1111/&BBB/' /tmp/input.txt // sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path} // sed 's/{position}/{content}/g' {path}
} }
async getOssConfig(){ async getOssConfig() {
var policyText = { const policyText = {
"expiration":"2119-12-31T16:00:00.000Z", expiration: '2119-12-31T16:00:00.000Z',
"conditions":[ conditions: [
["content-length-range",0,1048576000], ['content-length-range', 0, 1048576000],
["starts-with","$key","zc"] ['starts-with', '$key', 'zc'],
] ],
}; };
var b = new Buffer(JSON.stringify(policyText)); const b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64'); const policyBase64 = b.toString('base64');
var signature= crypto.createHmac('sha1',accesskey).update(policyBase64).digest().toString('base64'); //base64 const signature = crypto.createHmac('sha1', accesskey).update(policyBase64)
.digest()
.toString('base64'); // base64
var data={ const data = {
OSSAccessKeyId:accessKeyId, OSSAccessKeyId: accessKeyId,
policy:policyBase64, policy: policyBase64,
Signature:signature, Signature: signature,
Bucket:'gsb-zc', Bucket: 'gsb-zc',
success_action_status:201, success_action_status: 201,
url:url url,
}; };
return data; return data;
};
async upfile(srckey, dest) {
const oss = system.getObject('util.ossClient');
const result = await oss.upfile(srckey, `/tmp/${dest}`);
return result;
};
async downfile(srckey) {
const oss = system.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`;
return downfile;
});
return downfile;
};
async pdf2html(obj) {
const srckey = obj.key;
const downfile = await this.downfile(srckey);
const cmd = this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
const rtn = await this.restS.exec(cmd);
const path = `/tmp/${srckey.split('.pdf')[0]}.html`;
const a = await this.insertToFile(path);
fs.unlink(`/tmp/${srckey}`);
const result = await this.upfile(`${srckey.split('.pdf')[0]}.html`, `${srckey.split('.pdf')[0]}.html`);
return result.url;
};
async insertToFile(path) {
const cmd = `${this.cmdInsertToFilePattern} ${path}`;
return await this.restS.exec(cmd);
}; };
async upfile(srckey,dest){
var oss=system.getObject("util.ossClient");
var result=await oss.upfile(srckey,"/tmp/"+dest);
return result;
};
async downfile(srckey){
var oss=system.getObject("util.ossClient");
var downfile=await oss.downfile(srckey).then(function(){
downfile="/tmp/"+srckey;
return downfile;
});
return downfile;
};
async pdf2html(obj){
var srckey=obj.key;
var downfile=await this.downfile(srckey);
var cmd=this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
var rtn=await this.restS.exec(cmd);
var path="/tmp/"+srckey.split(".pdf")[0]+".html";
var a=await this.insertToFile(path);
fs.unlink("/tmp/"+srckey);
var result=await this.upfile(srckey.split(".pdf")[0]+".html",srckey.split(".pdf")[0]+".html");
return result.url;
};
async insertToFile(path){
var cmd=this.cmdInsertToFilePattern+" "+path;
return await this.restS.exec(cmd);
};
} }
module.exports=UploadCtl; module.exports = UploadCtl;
const system = require("../../../system"); const system = require('../../../system');
const settings = require("../../../../config/settings"); const settings = require('../../../../config/settings');
function exp(db, DataTypes) { function exp(db, DataTypes) {
var base = { const base = {
code: { code: {
type: DataTypes.STRING(50), type: DataTypes.STRING(50),
unique: true unique: true,
}, },
name: DataTypes.STRING(1000), name: DataTypes.STRING(1000),
}; };
......
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
function exp(db, DataTypes) { function exp(db, DataTypes) {
var base = { const base = {
//继承的表引用用户信息user_id // 继承的表引用用户信息user_id
code: DataTypes.STRING(100), code: DataTypes.STRING(100),
name: DataTypes.STRING(500), name: DataTypes.STRING(500),
creator: DataTypes.STRING(100),//创建者 creator: DataTypes.STRING(100), // 创建者
updator: DataTypes.STRING(100),//更新者 updator: DataTypes.STRING(100), // 更新者
auditor: DataTypes.STRING(100),//审核者 auditor: DataTypes.STRING(100), // 审核者
opNotes: DataTypes.STRING(500),//操作备注 opNotes: DataTypes.STRING(500), // 操作备注
auditStatusName: { auditStatusName: {
type:DataTypes.STRING(50), type: DataTypes.STRING(50),
defaultValue:"待审核", defaultValue: '待审核',
}, },
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过" auditStatus: { // 审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(appconfig.pdict.audit_status), values: Object.keys(appconfig.pdict.audit_status),
set: function (val) { set(val) {
this.setDataValue("auditStatus", val); this.setDataValue('auditStatus', val);
this.setDataValue("auditStatusName", appconfig.pdict.audit_status[val]); this.setDataValue('auditStatusName', appconfig.pdict.audit_status[val]);
}, },
defaultValue:"dsh", defaultValue: 'dsh',
}, },
sourceTypeName: DataTypes.STRING(50), sourceTypeName: DataTypes.STRING(50),
sourceType: {//来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单" sourceType: { // 来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单"
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.source_type), values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) { set(val) {
this.setDataValue("sourceType", val); this.setDataValue('sourceType', val);
this.setDataValue("sourceTypeName", appconfig.pdict.source_type[val]); this.setDataValue('sourceTypeName', appconfig.pdict.source_type[val]);
} },
}, },
sourceOrderNo: DataTypes.STRING(100),//来源单号 sourceOrderNo: DataTypes.STRING(100), // 来源单号
}; };
return base; return base;
} }
......
const system = require("../system") const system = require('../system');
const settings = require("../../config/settings.js"); const settings = require('../../config/settings.js');
class CacheBase { class CacheBase {
constructor() { constructor() {
this.db = system.getObject("db.common.connection").getCon(); this.db = system.getObject('db.common.connection').getCon();
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject('util.redisClient');
this.desc = this.desc(); this.desc = this.desc();
this.prefix = this.prefix(); this.prefix = this.prefix();
this.cacheCacheKeyPrefix = "sadd_base:cachekey"; this.cacheCacheKeyPrefix = 'sadd_base:cachekey';
this.isdebug = this.isdebug(); this.isdebug = this.isdebug();
} }
isdebug() { isdebug() {
return false; return false;
} }
desc() { desc() {
throw new Error("子类需要定义desc方法,返回缓存描述"); throw new Error('子类需要定义desc方法,返回缓存描述');
} }
prefix() { prefix() {
throw new Error("子类需要定义prefix方法,返回本缓存的前缀"); throw new Error('子类需要定义prefix方法,返回本缓存的前缀');
} }
async cache(inputkey, val, ex, ...items) { async cache(inputkey, val, ex, ...items) {
const cachekey = this.prefix + inputkey; const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey); const cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) { if (!cacheValue || cacheValue == 'undefined' || cacheValue == 'null' || this.isdebug) {
var objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items); const objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objvalstr) { if (!objvalstr) {
return null; return null;
} }
...@@ -31,25 +31,23 @@ class CacheBase { ...@@ -31,25 +31,23 @@ class CacheBase {
} else { } else {
await this.redisClient.set(cachekey, objvalstr); await this.redisClient.set(cachekey, objvalstr);
} }
//缓存当前应用所有的缓存key及其描述 // 缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]); this.redisClient.sadd(this.cacheCacheKeyPrefix, [`${cachekey}|${this.desc}`]);
return JSON.parse(objvalstr); return JSON.parse(objvalstr);
} else {
// this.redisClient.setWithEx(cachekey, cacheValue, ex);
return JSON.parse(cacheValue);
} }
// this.redisClient.setWithEx(cachekey, cacheValue, ex);
return JSON.parse(cacheValue);
} }
async getCache(inputkey, ex) { async getCache(inputkey, ex) {
const cachekey = this.prefix + inputkey; const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey); const cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null") { if (!cacheValue || cacheValue == 'undefined' || cacheValue == 'null') {
return null; return null;
} else {
if (ex) {
this.redisClient.set(cachekey, cacheValue, ex);
}
return JSON.parse(cacheValue);
} }
if (ex) {
this.redisClient.set(cachekey, cacheValue, ex);
}
return JSON.parse(cacheValue);
} }
async invalidate(inputkey) { async invalidate(inputkey) {
const cachekey = this.prefix + inputkey; const cachekey = this.prefix + inputkey;
...@@ -57,7 +55,7 @@ class CacheBase { ...@@ -57,7 +55,7 @@ class CacheBase {
return 0; return 0;
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
throw new Error("子类中实现构建缓存值的方法,返回字符串"); throw new Error('子类中实现构建缓存值的方法,返回字符串');
} }
} }
module.exports = CacheBase; module.exports = CacheBase;
const CacheBase=require("../cache.base"); const CacheBase = require('../cache.base');
const system=require("../../system"); const system = require('../../system');
//缓存首次登录的赠送的宝币数量 // 缓存首次登录的赠送的宝币数量
class CacheLocker extends CacheBase{ class CacheLocker extends CacheBase {
constructor(){ constructor() {
super(); super();
this.prefix="locker_"; this.prefix = 'locker_';
} }
desc(){ desc() {
} }
prefix(){ prefix() {
} }
async init(tradekey){ async init(tradekey) {
const key=this.prefix+tradekey; const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key,"1",1800); return this.redisClient.rpushWithEx(key, '1', 1800);
} }
async enter(tradekey){ async enter(tradekey) {
const key=this.prefix+tradekey; const key = this.prefix + tradekey;
return this.redisClient.rpop(key); return this.redisClient.rpop(key);
} }
async release(tradekey){ async release(tradekey) {
const key=this.prefix+tradekey; const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key,"1",1800); return this.redisClient.rpushWithEx(key, '1', 1800);
} }
} }
module.exports=CacheLocker; module.exports = CacheLocker;
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
class AppCache extends CacheBase{ class AppCache extends CacheBase {
constructor(){ constructor() {
super(); super();
this.prefix="g_centerappkey:"; this.prefix = 'g_centerappkey:';
this.appDao=system.getObject("db.common.appDao"); this.appDao = system.getObject('db.common.appDao');
}
isdebug() {
return settings.env == 'dev';
}
desc() {
return '缓存本地应用对象';
}
prefix() {
return 'g_applocal_';
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.appDao.findOne({ appkey: inputkey });
if (configValue) {
return JSON.stringify(configValue);
}
return null;
} }
isdebug(){
return settings.env=="dev";
}
desc(){
return "缓存本地应用对象";
}
prefix(){
return "g_applocal_"
}
async buildCacheVal(cachekey,inputkey, val, ex, ...items) {
const configValue=await this.appDao.findOne({appkey:inputkey});
if (configValue) {
return JSON.stringify(configValue);
}
return null;
}
} }
module.exports=AppCache; module.exports = AppCache;
\ No newline at end of file
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
class CompanyCache extends CacheBase{ class CompanyCache extends CacheBase {
constructor(){ constructor() {
super(); super();
this.prefix="g_centercompanykey:"; this.prefix = 'g_centercompanykey:';
this.companyDao=system.getObject("db.common.companyDao"); this.companyDao = system.getObject('db.common.companyDao');
}
isdebug() {
return settings.env == 'dev';
}
desc() {
return '缓存统一公司对象';
}
prefix() {
return 'gc_companylocal_';
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.companyDao.findOne({ companykey: inputkey });
if (configValue) {
return JSON.stringify(configValue);
}
return null;
} }
isdebug(){
return settings.env=="dev";
}
desc(){
return "缓存统一公司对象";
}
prefix(){
return "gc_companylocal_"
}
async buildCacheVal(cachekey,inputkey, val, ex, ...items) {
const configValue=await this.companyDao.findOne({companykey:inputkey});
if (configValue) {
return JSON.stringify(configValue);
}
return null;
}
} }
module.exports=CompanyCache; module.exports = CompanyCache;
\ No newline at end of file
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
class MagCache extends CacheBase { class MagCache extends CacheBase {
constructor() { constructor() {
super(); super();
this.prefix = "magCache"; this.prefix = 'magCache';
} }
desc() { desc() {
return "管理当前缓存的key"; return '管理当前缓存的key';
} }
prefix() { prefix() {
return "g_magcache:"; return 'g_magcache:';
} }
async getCacheSmembersByKey(key) { async getCacheSmembersByKey(key) {
return this.redisClient.smembers(key); return this.redisClient.smembers(key);
} }
async delCacheBySrem(key, value) { async delCacheBySrem(key, value) {
return this.redisClient.srem(key, value) return this.redisClient.srem(key, value);
} }
async keys(p) { async keys(p) {
return this.redisClient.keys(p); return this.redisClient.keys(p);
...@@ -28,7 +28,7 @@ class MagCache extends CacheBase { ...@@ -28,7 +28,7 @@ class MagCache extends CacheBase {
return this.redisClient.delete(k); return this.redisClient.delete(k);
} }
async clearAll() { async clearAll() {
console.log("xxxxxxxxxxxxxxxxxxxclearAll............"); console.log('xxxxxxxxxxxxxxxxxxxclearAll............');
return this.redisClient.flushall(); return this.redisClient.flushall();
} }
} }
......
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
class TxCache extends CacheBase { class TxCache extends CacheBase {
constructor() { constructor() {
super(); super();
//this.userDao = system.getObject("db.auth.userDao"); // this.userDao = system.getObject("db.auth.userDao");
} }
isdebug() { isdebug() {
return settings.env == "dev"; return settings.env == 'dev';
} }
desc() { desc() {
return "缓存缓存腾讯队列信息"; return '缓存缓存腾讯队列信息';
} }
prefix() { prefix() {
return "g_txInfo_cm:" return 'g_txInfo_cm:';
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
if (val) { if (val) {
return val; return val;
}
return null;
} }
return null;
}
} }
module.exports = TxCache; module.exports = TxCache;
\ No newline at end of file
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
class UserCache extends CacheBase{ class UserCache extends CacheBase {
constructor(){ constructor() {
super(); super();
this.userDao=system.getObject("db.auth.userDao"); this.userDao = system.getObject('db.auth.userDao');
}
isdebug() {
return settings.env == 'dev';
}
desc() {
return '缓存本地应用对象';
}
prefix() {
return 'g_userlocal_';
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.userDao.model.findAll({
where: { userName: inputkey, app_id: settings.pmappid },
attributes: ['id', 'userName', 'nickName', 'headUrl', 'jwtkey', 'jwtsecret', 'created_at', 'isSuper', 'isAdmin', 'mail'],
include: [
{ model: this.db.models.company, raw: true },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'] },
],
});
if (configValue && configValue[0]) {
return JSON.stringify(configValue[0]);
}
return null;
} }
isdebug(){
return settings.env=="dev";
}
desc(){
return "缓存本地应用对象";
}
prefix(){
return "g_userlocal_"
}
async buildCacheVal(cachekey,inputkey, val, ex, ...items) {
const configValue = await this.userDao.model.findAll({
where: { userName: inputkey, app_id: settings.pmappid },
attributes: ['id','userName', 'nickName','headUrl','jwtkey','jwtsecret','created_at','isSuper','isAdmin','mail'],
include: [
{ model: this.db.models.company,raw:true},
{model:this.db.models.role,as:"Roles",attributes:["id","code"],}
],
});
if (configValue && configValue[0]) {
return JSON.stringify(configValue[0]);
}
return null;
}
} }
module.exports=UserCache; module.exports = UserCache;
\ No newline at end of file
const CacheBase = require("../cache.base"); const CacheBase = require('../cache.base');
const system = require("../../system"); const system = require('../../system');
const settings = require("../../../config/settings"); const settings = require('../../../config/settings');
//缓存首次登录的赠送的宝币数量 // 缓存首次登录的赠送的宝币数量
class VCodeCache extends CacheBase { class VCodeCache extends CacheBase {
constructor() { constructor() {
super(); super();
this.smsUtil = system.getObject("util.smsClient"); this.smsUtil = system.getObject('util.smsClient');
} }
// isdebug() { // isdebug() {
// return settings.env == "dev"; // return settings.env == "dev";
// } // }
desc() { desc() {
return "缓存给手机发送的验证码60妙"; return '缓存给手机发送的验证码60妙';
} }
prefix() { prefix() {
return "g_vcode_" return 'g_vcode_';
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
//inputkey采用appkey_mobile的形式 // inputkey采用appkey_mobile的形式
var mobile = inputkey; const mobile = inputkey;
var tmplCode = val; const tmplCode = val;
var signName = items ? items[0] : ""; const signName = items ? items[0] : '';
var vcode = await this.smsUtil.getUidStr(6, 10); const vcode = await this.smsUtil.getUidStr(6, 10);
if (!tmplCode && !signName) { if (!tmplCode && !signName) {
this.smsUtil.sendMsg(mobile, vcode); this.smsUtil.sendMsg(mobile, vcode);
} //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码 } // tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else { else {
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode })); this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode }));
} }
return JSON.stringify({ vcode: vcode }); return JSON.stringify({ vcode });
} }
} }
module.exports = VCodeCache; module.exports = VCodeCache;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class AuthDao extends Dao{ class AuthDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(AuthDao)); super(Dao.getModelName(AuthDao));
} }
extraWhere(qobj,qw,qc){ extraWhere(qobj, qw, qc) {
qc.raw=true; qc.raw = true;
return qw; return qw;
} }
} }
module.exports=AuthDao; module.exports = AuthDao;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class DataauthDao extends Dao{ class DataauthDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(DataauthDao)); super(Dao.getModelName(DataauthDao));
} }
extraWhere(qobj,qw,qc){ extraWhere(qobj, qw, qc) {
qc.raw=true; qc.raw = true;
return qw; return qw;
} }
} }
module.exports=DataauthDao; module.exports = DataauthDao;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class OrgDao extends Dao{ class OrgDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(OrgDao)); super(Dao.getModelName(OrgDao));
} }
extraWhere(qobj,qw,qc){ extraWhere(qobj, qw, qc) {
qc.raw=true; qc.raw = true;
return qw; return qw;
} }
} }
module.exports=OrgDao; module.exports = OrgDao;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class RoleDao extends Dao{ class RoleDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(RoleDao)); super(Dao.getModelName(RoleDao));
} }
async findOne(paramappid,t){ async findOne(paramappid, t) {
var app= await this.model.findOne({where:{appid:paramappid}},{transaction:t}); const app = await this.model.findOne({ where: { appid: paramappid } }, { transaction: t });
return app; return app;
} }
extraWhere(obj,w,qc,linkAttrs){ extraWhere(obj, w, qc, linkAttrs) {
// if(obj.codepath && obj.codepath!=""){ // if(obj.codepath && obj.codepath!=""){
// // if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询 // // if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// // console.log(obj); // // console.log(obj);
// // w["app_id"]=obj.appid; // // w["app_id"]=obj.appid;
// // } // // }
// } // }
w["app_id"]=obj.app_id; w.app_id = obj.app_id;
w["company_id"]=obj.company_id; w.company_id = obj.company_id;
return w; return w;
}
extraModelFilter(){
return {"key":"include","value":[{model:this.db.models.app,}]};
} }
async preUpdate(u){ extraModelFilter() {
return { key: 'include', value: [{ model: this.db.models.app }] };
}
async preUpdate(u) {
return u; return u;
} }
async update(obj){ async update(obj) {
var obj2=await this.preUpdate(obj); const obj2 = await this.preUpdate(obj);
await this.model.update(obj2,{where:{id:obj2.id}}); await this.model.update(obj2, { where: { id: obj2.id } });
var role=await this.model.findOne({where:{id:obj2.id}}); const role = await this.model.findOne({ where: { id: obj2.id } });
return role; return role;
} }
async preCreate(u){ async preCreate(u) {
return u; return u;
} }
async create(u,t){ async create(u, t) {
var self=this; const self = this;
var u2= await this.preCreate(u); const u2 = await this.preCreate(u);
if(t){ if (t) {
var role= await this.model.create(u2,{transaction: t}); var role = await this.model.create(u2, { transaction: t });
return role; return role;
}else{ }
var role= await this.model.create(u2); var role = await this.model.create(u2);
return role; return role;
}
} }
} }
module.exports=RoleDao; module.exports = RoleDao;
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class DeliverybillDao extends Dao { class DeliverybillDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(DeliverybillDao)); super(Dao.getModelName(DeliverybillDao));
} }
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件 extraWhere(qobj, qw, qc) { // 根据业务员id获取交付单信息的组装条件
qc.raw = true; qc.raw = true;
let filters = [] const filters = [];
// 公司数据过滤 // 公司数据过滤
filters.push({ filters.push({
facilitator_id: Number(qobj.company_id || -1) facilitator_id: Number(qobj.company_id || -1),
}); });
/** /**
* 数据权限过滤 * 数据权限过滤
* 1. 管理员 (opath 为空)、 销售主管(isPrincipal = true) 、 销售 (isPrincipal = false && opath不为空) * 1. 管理员 (opath 为空)、 销售主管(isPrincipal = true) 、 销售 (isPrincipal = false && opath不为空)
*/ */
if (!qobj.opath) { // 管理员 不做处理 if (!qobj.opath) { // 管理员 不做处理
} else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的 } else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的
filters.push({ filters.push({
$or: [ $or: [
{ {
delivery_man_opcode: { delivery_man_opcode: {
$eq: null $eq: null,
} },
}, { }, {
delivery_man_opcode: { $like: `%${qobj.opath}%` } delivery_man_opcode: { $like: `%${qobj.opath}%` },
} },
] ],
}); });
} else { // 销售 查询自己的 } else { // 销售 查询自己的
filters.push({ filters.push({
delivery_man_opcode: { $like: `%${qobj.opath}%` } delivery_man_opcode: { $like: `%${qobj.opath}%` },
}); });
} }
// 产品类型过滤 // 产品类型过滤
filters.push({ filters.push({
product_code: system.SERVICECODE.FT product_code: system.SERVICECODE.FT,
}) });
// 根据 页面 过滤 交付状态 // 根据 页面 过滤 交付状态
switch (qobj.bizpath) { switch (qobj.bizpath) {
case "/deliveryManage/deliveryRecord": // 交付单记录 case '/deliveryManage/deliveryRecord': // 交付单记录
// filters.push({ // filters.push({
// delivery_status: { // delivery_status: {
// $in: [ // $in: [
...@@ -48,8 +48,8 @@ class DeliverybillDao extends Dao { ...@@ -48,8 +48,8 @@ class DeliverybillDao extends Dao {
// ] // ]
// }, // },
// }); // });
break break;
case "/deliveryManage/deliveryDealWith": //交付单处理 case '/deliveryManage/deliveryDealWith': // 交付单处理
// filters.push({ // filters.push({
// $or: [{ // $or: [{
// delivery_status: { // delivery_status: {
...@@ -73,49 +73,49 @@ class DeliverybillDao extends Dao { ...@@ -73,49 +73,49 @@ class DeliverybillDao extends Dao {
// } // }
// ], // ],
// }); // });
break break;
} }
/** /**
* 筛选 条件 * 筛选 条件
* company_name、v_coname、v_cophone、delivery_code * company_name、v_coname、v_cophone、delivery_code
*/ */
if (qc.where.companyName) { if (qc.where.companyName) {
filters.push({ filters.push({
company_name: qc.where.companyName company_name: qc.where.companyName,
}); });
delete qc.where.companyName; delete qc.where.companyName;
} }
if (qc.where.contactsName) { if (qc.where.contactsName) {
filters.push({ filters.push({
v_coname: qc.where.contactsName v_coname: qc.where.contactsName,
}); });
delete qc.where.contactsName; delete qc.where.contactsName;
} }
if (qc.where.contactsPhone) { if (qc.where.contactsPhone) {
filters.push({ filters.push({
v_cophone: qc.where.contactsPhone v_cophone: qc.where.contactsPhone,
}); });
delete qc.where.contactsPhone; delete qc.where.contactsPhone;
} }
if (qc.where.deliveryNumber) { if (qc.where.deliveryNumber) {
filters.push({ filters.push({
delivery_code: qc.where.deliveryNumber delivery_code: qc.where.deliveryNumber,
}); });
delete qc.where.deliveryNumber; delete qc.where.deliveryNumber;
} }
if (qc.where.deliveryStatus) { if (qc.where.deliveryStatus) {
filters.push({ filters.push({
delivery_status: qc.where.deliveryStatus delivery_status: qc.where.deliveryStatus,
}); });
delete qc.where.deliveryStatus; delete qc.where.deliveryStatus;
} }
if (qc.where.owner) { if (qc.where.owner) {
filters.push({ filters.push({
delivery_man_name: qc.where.owner delivery_man_name: qc.where.owner,
}); });
delete qc.where.owner; delete qc.where.owner;
} }
...@@ -123,27 +123,27 @@ class DeliverybillDao extends Dao { ...@@ -123,27 +123,27 @@ class DeliverybillDao extends Dao {
if (qc.where.setupStatus) { if (qc.where.setupStatus) {
if (qobj && qobj.search && qobj.search.setupStatus && qobj.search.setupStatus === system.SERVERSESTATUS.SETUP) { if (qobj && qobj.search && qobj.search.setupStatus && qobj.search.setupStatus === system.SERVERSESTATUS.SETUP) {
filters.push({ filters.push({
v_setup_status: qc.where.setupStatus v_setup_status: qc.where.setupStatus,
}); });
} else { } else {
filters.push({ filters.push({
$or: [ $or: [
{ {
v_setup_status: qc.where.setupStatus v_setup_status: qc.where.setupStatus,
}, },
{ {
v_setup_status: { v_setup_status: {
$eq: null $eq: null,
} },
} },
] ],
}); });
} }
delete qc.where.setupStatus; delete qc.where.setupStatus;
} }
qc.where["$and"] = filters; qc.where.$and = filters;
return qw; return qw;
} }
...@@ -152,8 +152,8 @@ class DeliverybillDao extends Dao { ...@@ -152,8 +152,8 @@ class DeliverybillDao extends Dao {
} }
async updateServer(qobj, t) { async updateServer(qobj, t) {
var setobj = { "delivery_info": qobj.delivery_info }; const setobj = { delivery_info: qobj.delivery_info };
var whereobj = { "biz_id": qobj.biz_id }; const whereobj = { biz_id: qobj.biz_id };
if (qobj.delivery_code && qobj.delivery_code != 'undefined') { if (qobj.delivery_code && qobj.delivery_code != 'undefined') {
whereobj.delivery_code = qobj.delivery_code; whereobj.delivery_code = qobj.delivery_code;
} }
...@@ -161,7 +161,7 @@ class DeliverybillDao extends Dao { ...@@ -161,7 +161,7 @@ class DeliverybillDao extends Dao {
} }
async findOneByDeliveryCodeAndBizId(qobj) { async findOneByDeliveryCodeAndBizId(qobj) {
var qcwhere = { "biz_id": qobj.biz_id }; const qcwhere = { biz_id: qobj.biz_id };
if (qobj.delivery_code && qobj.delivery_code != 'undefined') { if (qobj.delivery_code && qobj.delivery_code != 'undefined') {
qcwhere.delivery_code = qobj.delivery_code; qcwhere.delivery_code = qobj.delivery_code;
} }
...@@ -171,14 +171,14 @@ class DeliverybillDao extends Dao { ...@@ -171,14 +171,14 @@ class DeliverybillDao extends Dao {
* 根据服务实例id查找服务所有信息 * 根据服务实例id查找服务所有信息
*/ */
async findByBizId(pobj) { async findByBizId(pobj) {
var oid = pobj.bizId; const oid = pobj.bizId;
return await this.findOne({ biz_id: oid }); return await this.findOne({ biz_id: oid });
} }
/** /**
* 根据客户ID(帐套)查找服务所有信息 * 根据客户ID(帐套)查找服务所有信息
*/ */
async findByClientId(pobj) { async findByClientId(pobj) {
var oid = pobj.vftClientId; const oid = pobj.vftClientId;
return await this.findOne({ v_ftClientId: oid }); return await this.findOne({ v_ftClientId: oid });
} }
} }
......
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class FitaxcompanyDao extends Dao { class FitaxcompanyDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(FitaxcompanyDao)); super(Dao.getModelName(FitaxcompanyDao));
...@@ -10,56 +10,56 @@ class FitaxcompanyDao extends Dao { ...@@ -10,56 +10,56 @@ class FitaxcompanyDao extends Dao {
*@param {*} qobj *@param {*} qobj
*/ */
async findInfo(qobj) { async findInfo(qobj) {
let obj = { const obj = {
"demand_code": qobj.demand_code// 需求编码 demand_code: qobj.demand_code, // 需求编码
} };
return await this.findOne(obj); return await this.findOne(obj);
} }
/** /**
*修改 *修改
*@param {*} qobj *@param {*} qobj
* @param {*} t * @param {*} t
*/ */
async updateInfo(qobj, t) { async updateInfo(qobj, t) {
let obj = this.buildObj(qobj); const obj = this.buildObj(qobj);
let whereObj = { "demand_code": obj.demand_code }; const whereObj = { demand_code: obj.demand_code };
return await this.updateByWhere(obj, whereObj, t); return await this.updateByWhere(obj, whereObj, t);
} }
/** /**
* 插入信息 * 插入信息
* @param {*} qobj * @param {*} qobj
* @param {*} t * @param {*} t
*/ */
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
let obj = this.buildObj(qobj); const obj = this.buildObj(qobj);
return await this.create(obj, t); return await this.create(obj, t);
} }
buildObj(qobj) { buildObj(qobj) {
let obj = { const obj = {
"demand_code": qobj.demand_code,// 需求编码 demand_code: qobj.demand_code, // 需求编码
} };
if (qobj.company_name) {// 企业名称 if (qobj.company_name) { // 企业名称
obj.company_name = qobj.company_name; obj.company_name = qobj.company_name;
} }
if (qobj.legal_person) {// 法人姓名 if (qobj.legal_person) { // 法人姓名
obj.legal_person = qobj.legal_person; obj.legal_person = qobj.legal_person;
} }
if (qobj.tax_number) {// 税号 if (qobj.tax_number) { // 税号
obj.tax_number = qobj.tax_number; obj.tax_number = qobj.tax_number;
} }
if (qobj.taxpayer_type) {// 纳税人类型 if (qobj.taxpayer_type) { // 纳税人类型
obj.taxpayer_type = qobj.taxpayer_type; obj.taxpayer_type = qobj.taxpayer_type;
} }
if (qobj.engaged_industry) {// 所属行业 if (qobj.engaged_industry) { // 所属行业
obj.engaged_industry = qobj.engaged_industry; obj.engaged_industry = qobj.engaged_industry;
} }
if (qobj.region) {// 地区 if (qobj.region) { // 地区
obj.region = qobj.region; obj.region = qobj.region;
} }
if (qobj.address) {// 企业地址 if (qobj.address) { // 企业地址
obj.address = qobj.address; obj.address = qobj.address;
} }
return obj; return obj;
......
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class FitaxpushqueueDao extends Dao { class FitaxpushqueueDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(FitaxpushqueueDao)); super(Dao.getModelName(FitaxpushqueueDao));
...@@ -7,39 +7,38 @@ class FitaxpushqueueDao extends Dao { ...@@ -7,39 +7,38 @@ class FitaxpushqueueDao extends Dao {
/** /**
*查询 *查询
*@param {*} qobj *@param {*} qobj
*/ */
async findInfo(qobj) { async findInfo(qobj) {
let obj = { const obj = {
"delivery_code": qobj.delivery_code// 交付单id delivery_code: qobj.delivery_code, // 交付单id
} };
return await this.findOne(obj); return await this.findOne(obj);
} }
/** /**
* 插入信息 * 插入信息
* @param {*} qobj * @param {*} qobj
* @param {*} t * @param {*} t
*/ */
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
try { try {
let obj = this.buildObj(qobj); const obj = this.buildObj(qobj);
console.log("obj------------------------------" + obj); console.log(`obj------------------------------${obj}`);
return await this.create(obj, t); return await this.create(obj, t);
} } catch (error) {
catch (error) { console.log(`error-------------------------${error}`);
console.log("error-------------------------" + error);
return error; return error;
} }
} }
/** /**
*更新方案信息(主要是添加方案编号) *更新方案信息(主要是添加方案编号)
*@param {*} qobj *@param {*} qobj
* @param {*} t * @param {*} t
*/ */
async updateInfo(qobj, t) { async updateInfo(qobj, t) {
var obj = {}; const obj = {};
if (qobj.req_data) { if (qobj.req_data) {
obj.req_data = qobj.req_data; obj.req_data = qobj.req_data;
} }
...@@ -52,24 +51,24 @@ class FitaxpushqueueDao extends Dao { ...@@ -52,24 +51,24 @@ class FitaxpushqueueDao extends Dao {
if (qobj.rys_check) { if (qobj.rys_check) {
obj.rys_check = qobj.rys_check; obj.rys_check = qobj.rys_check;
} }
if (qobj.data_type){ if (qobj.data_type) {
obj.data_type = qobj.data_type; obj.data_type = qobj.data_type;
} }
if (qobj.check_date) { if (qobj.check_date) {
obj.check_date = qobj.check_date; obj.check_date = qobj.check_date;
} }
let whereObj = { "delivery_code": qobj.delivery_code,"current_period": qobj.current_period}; const whereObj = { delivery_code: qobj.delivery_code, current_period: qobj.current_period };
return await this.updateByWhere(obj, whereObj, t); return await this.updateByWhere(obj, whereObj, t);
} }
buildObj(qobj) { buildObj(qobj) {
let obj = { const obj = {
"delivery_code": qobj.delivery_code delivery_code: qobj.delivery_code,
} };
if (qobj.current_period) { if (qobj.current_period) {
obj.current_period = qobj.current_period; obj.current_period = qobj.current_period;
} }
if (qobj.data_type){ if (qobj.data_type) {
obj.data_type = qobj.data_type; obj.data_type = qobj.data_type;
} }
if (qobj.req_data) { if (qobj.req_data) {
......
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class FitaxschemeDao extends Dao { class FitaxschemeDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(FitaxschemeDao)); super(Dao.getModelName(FitaxschemeDao));
...@@ -7,87 +7,86 @@ class FitaxschemeDao extends Dao { ...@@ -7,87 +7,86 @@ class FitaxschemeDao extends Dao {
/** /**
*查询 *查询
*@param {*} qobj *@param {*} qobj
*/ */
async findInfo(qobj) { async findInfo(qobj) {
let obj = { const obj = {
"demand_code": qobj.demand_code,// 需求编码 demand_code: qobj.demand_code, // 需求编码
} };
return await this.findOne(obj); return await this.findOne(obj);
} }
/** /**
* 插入方案信息 * 插入方案信息
* @param {*} qobj * @param {*} qobj
* @param {*} t * @param {*} t
*/ */
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
try { try {
let obj = this.buildObj(qobj); const obj = this.buildObj(qobj);
console.log("obj------------------------------" + obj); console.log(`obj------------------------------${obj}`);
return await this.create(obj, t); return await this.create(obj, t);
} } catch (error) {
catch (error) { console.log(`error-------------------------${error}`);
console.log("error-------------------------" + error);
return error; return error;
} }
} }
/** /**
*更新方案信息(主要是添加方案编号) *更新方案信息(主要是添加方案编号)
*@param {*} qobj *@param {*} qobj
* @param {*} t * @param {*} t
*/ */
async updateInfo(qobj, t) { async updateInfo(qobj, t) {
let obj = {}; const obj = {};
if (qobj.solution_bizid) {// 方案编号 if (qobj.solution_bizid) { // 方案编号
obj.solution_bizid = qobj.solution_bizid; obj.solution_bizid = qobj.solution_bizid;
} }
let whereObj = { "demand_code": qobj.demand_code }; const whereObj = { demand_code: qobj.demand_code };
return await this.updateByWhere(obj, whereObj, t); return await this.updateByWhere(obj, whereObj, t);
} }
buildObj(qobj) { buildObj(qobj) {
let obj = { const obj = {
"demand_code": qobj.demand_code,// 需求编码 demand_code: qobj.demand_code, // 需求编码
} };
if (qobj.solution_bizid) {// 方案编号 if (qobj.solution_bizid) { // 方案编号
obj.solution_bizid = qobj.solution_bizid; obj.solution_bizid = qobj.solution_bizid;
} }
if (qobj.service_type) {// 服务类型 if (qobj.service_type) { // 服务类型
obj.service_type = qobj.service_type; obj.service_type = qobj.service_type;
} }
if (qobj.company_type) {// 公司类型 if (qobj.company_type) { // 公司类型
obj.company_type = qobj.company_type; obj.company_type = qobj.company_type;
} }
if (qobj.taxpayer_type) {// 纳税人类型 if (qobj.taxpayer_type) { // 纳税人类型
obj.taxpayer_type = qobj.taxpayer_type; obj.taxpayer_type = qobj.taxpayer_type;
} }
if (qobj.service_name) {// 服务地区 if (qobj.service_name) { // 服务地区
obj.service_name = qobj.service_name; obj.service_name = qobj.service_name;
} }
if (qobj.service_code) {// 服务地区编码 if (qobj.service_code) { // 服务地区编码
obj.service_code = qobj.service_code; obj.service_code = qobj.service_code;
} }
if (qobj.buy_duration) {// 购买时长 if (qobj.buy_duration) { // 购买时长
obj.buy_duration = qobj.buy_duration; obj.buy_duration = qobj.buy_duration;
} }
if (qobj.number) {// 数量 if (qobj.number) { // 数量
obj.number = qobj.number; obj.number = qobj.number;
} }
if (qobj.total_cost) {// 总计费用 if (qobj.total_cost) { // 总计费用
obj.total_cost = qobj.total_cost; obj.total_cost = qobj.total_cost;
} }
if (qobj.remarks) {// 备注 if (qobj.remarks) { // 备注
obj.remarks = qobj.remarks; obj.remarks = qobj.remarks;
} }
return obj; return obj;
} }
async findInfoByBizid(qobj) { async findInfoByBizid(qobj) {
let obj = { const obj = {
"solution_bizid": qobj.bizId solution_bizid: qobj.bizId,
} };
return await this.findOne(obj); return await this.findOne(obj);
} }
} }
......
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class OperationrecordDao extends Dao { class OperationrecordDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(OperationrecordDao)); super(Dao.getModelName(OperationrecordDao));
...@@ -10,27 +10,27 @@ class OperationrecordDao extends Dao { ...@@ -10,27 +10,27 @@ class OperationrecordDao extends Dao {
*@param {*} qobj *@param {*} qobj
*/ */
async findAllInfo(qobj) { async findAllInfo(qobj) {
qobj.order_type = "BIZ";//数据类型需求|订单 qobj.order_type = 'BIZ';// 数据类型需求|订单
return await this.model.findAll({ where: qobj, order: [["created_at","DESC"]] }); return await this.model.findAll({ where: qobj, order: [['created_at', 'DESC']] });
} }
/** /**
* 插入状态信息 * 插入状态信息
* @param {*} qobj * @param {*} qobj
* @param {*} t * @param {*} t
*/ */
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
let obj = { const obj = {
"demand_code": qobj.demand_code,// 需求编码 demand_code: qobj.demand_code, // 需求编码
"order_type": "BIZ", order_type: 'BIZ',
} };
if (qobj.operator) {// 操作人 if (qobj.operator) { // 操作人
obj.operator = qobj.operator; obj.operator = qobj.operator;
} }
if (qobj.operation_type) {// 操作类型 if (qobj.operation_type) { // 操作类型
obj.operation_type = qobj.operation_type; obj.operation_type = qobj.operation_type;
} }
if (qobj.operation_details) {// 操作详细记录json if (qobj.operation_details) { // 操作详细记录json
obj.operation_details = qobj.operation_details; obj.operation_details = qobj.operation_details;
} }
return await this.create(obj, t); return await this.create(obj, t);
...@@ -47,4 +47,4 @@ module.exports = OperationrecordDao; ...@@ -47,4 +47,4 @@ module.exports = OperationrecordDao;
// async function start(a) { // async function start(a) {
// let res = await test.findAllInfo(a); // let res = await test.findAllInfo(a);
// console.log("结果:" + JSON.stringify(res)); // console.log("结果:" + JSON.stringify(res));
// } // }
\ No newline at end of file
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class SalesmanhisDao extends Dao { class SalesmanhisDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(SalesmanhisDao)); super(Dao.getModelName(SalesmanhisDao));
} }
/*插入状态信息信息*/ /* 插入状态信息信息*/
async insertInfo(qobj,t){ async insertInfo(qobj, t) {
var obj = { const obj = {
"flow_type":qobj.flowType, flow_type: qobj.flowType,
"flow_id":qobj.flowId, flow_id: qobj.flowId,
"flow_code":qobj.flowCode, flow_code: qobj.flowCode,
"salesman_info":qobj.salesmanInfo salesman_info: qobj.salesmanInfo,
}; };
return await this.create(obj,t); return await this.create(obj, t);
} }
} }
module.exports = SalesmanhisDao; module.exports = SalesmanhisDao;
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class SchemeDao extends Dao { class SchemeDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(SchemeDao)); super(Dao.getModelName(SchemeDao));
} }
/*根据商机编号获取方案信息详情*/ /* 根据商机编号获取方案信息详情*/
async findInfoByDemandCode(qobj){ async findInfoByDemandCode(qobj) {
var qcwhere = {"demand_code":qobj.businessMode}; const qcwhere = { demand_code: qobj.businessMode };
return await this.findOne(qcwhere); return await this.findOne(qcwhere);
} }
/*根据方案编号更新方案状态及原因*/ /* 根据方案编号更新方案状态及原因*/
async updateStatusByDemandCode(qobj,t){ async updateStatusByDemandCode(qobj, t) {
var setobj = {"scheme_status":qobj.currentStatus}; const setobj = { scheme_status: qobj.currentStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj["reject_reason"] = qobj.statusReason; setobj.reject_reason = qobj.statusReason;
} else {
setobj.reject_reason = '';
} }
else{ const whereobj = { demand_code: qobj.businessMode };
setobj["reject_reason"] = ""; return await this.updateByWhere(setobj, whereobj, t);
}
var whereobj = {"demand_code":qobj.businessMode};
return await this.updateByWhere(setobj,whereobj,t);
} }
/*根据商机编号更新方案详情*/ /* 根据商机编号更新方案详情*/
async updateInfoByDemandCode(qobj,t){ async updateInfoByDemandCode(qobj, t) {
var whereobj = {"demand_code":qobj.businessMode}; const whereobj = { demand_code: qobj.businessMode };
var setobj = {"scheme_info":qobj.baseInfo,"scheme_status":qobj.currentStatus}; const setobj = { scheme_info: qobj.baseInfo, scheme_status: qobj.currentStatus };
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){ if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
setobj.scheme_number = qobj.schemeNumber; setobj.scheme_number = qobj.schemeNumber;
} }
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.reject_reason = qobj.statusReason; setobj.reject_reason = qobj.statusReason;
} else {
setobj.reject_reason = '';
} }
else{ return await this.updateByWhere(setobj, whereobj, t);
setobj.reject_reason = "";
}
return await this.updateByWhere(setobj,whereobj,t);
} }
/*根据方案编号更新方案编号*/ /* 根据方案编号更新方案编号*/
async updateSchemeNumberByDemandCode(qobj,t){ async updateSchemeNumberByDemandCode(qobj, t) {
var setobj = {"scheme_number":qobj.schemeNumber}; const setobj = { scheme_number: qobj.schemeNumber };
var whereobj = {"demand_code":qobj.businessMode}; const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj,whereobj,t); return await this.updateByWhere(setobj, whereobj, t);
} }
/*插入方案信息*/ /* 插入方案信息*/
async insertInfo(qobj,t){ async insertInfo(qobj, t) {
var obj = { const obj = {
"demand_code":qobj.businessMode, demand_code: qobj.businessMode,
"scheme_info":qobj.baseInfo scheme_info: qobj.baseInfo,
}; };
if (qobj.currentStatus && qobj.currentStatus != 'undefined'){ if (qobj.currentStatus && qobj.currentStatus != 'undefined') {
obj["scheme_status"] = qobj.currentStatus; obj.scheme_status = qobj.currentStatus;
} }
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){ if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
obj["scheme_number"] = qobj.schemeNumber; obj.scheme_number = qobj.schemeNumber;
} }
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj["reject_reason"] = qobj.statusReason; obj.reject_reason = qobj.statusReason;
} }
if (qobj.memoInfo && qobj.memoInfo != 'undefined'){ if (qobj.memoInfo && qobj.memoInfo != 'undefined') {
obj["remark_info"] = qobj.memoInfo; obj.remark_info = qobj.memoInfo;
} }
if (qobj.businessId && qobj.businessId != 'undefined'){ if (qobj.businessId && qobj.businessId != 'undefined') {
obj["bizopt_id"] = qobj.businessId; obj.bizopt_id = qobj.businessId;
} }
if (qobj.servicerCode && qobj.servicerCode != 'undefined'){ if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj["facilitator_id"] = qobj.servicerCode; obj.facilitator_id = qobj.servicerCode;
} }
if (qobj.servicerName && qobj.servicerName != 'undefined'){ if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj["facilitator_name"] = qobj.servicerName; obj.facilitator_name = qobj.servicerName;
} }
if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined'){ if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined') {
obj["salesman_opcode"] = qobj.clerkOpcode; obj.salesman_opcode = qobj.clerkOpcode;
} }
if (qobj.clerkId && qobj.clerkId != 'undefined'){ if (qobj.clerkId && qobj.clerkId != 'undefined') {
obj["salesman_id"] = qobj.clerkId; obj.salesman_id = qobj.clerkId;
} }
if (qobj.clerkName && qobj.clerkName != 'undefined'){ if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj["salesman_name"] = qobj.clerkName; obj.salesman_name = qobj.clerkName;
} }
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined'){ if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') {
obj["salesman_phone"] = qobj.clerkPhone; obj.salesman_phone = qobj.clerkPhone;
} }
return await this.create(obj,t); return await this.create(obj, t);
} }
} }
module.exports = SchemeDao; module.exports = SchemeDao;
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class SettlebillDao extends Dao { class SettlebillDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(SettlebillDao)); super(Dao.getModelName(SettlebillDao));
} }
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件 extraWhere(qobj, qw, qc) { // 根据业务员id获取交付单信息的组装条件
//qc.raw = true; // qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据 // 检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) { if (qobj.company_id == 1) {
return qw return qw;
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
} }
// 需要添加公司查询条件
qw.facilitator_id = Number(qobj.company_id);
return qw; return qw;
} }
} }
......
const system = require("../../../system"); const system = require('../../../system');
const Dao = require("../../dao.base"); const Dao = require('../../dao.base');
class StatuslogDao extends Dao { class StatuslogDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(StatuslogDao)); super(Dao.getModelName(StatuslogDao));
} }
/*插入状态信息信息*/ /* 插入状态信息信息*/
async insertInfo(qobj,t){ async insertInfo(qobj, t) {
var obj = { const obj = {
"flow_type":qobj.flowType, flow_type: qobj.flowType,
"flow_id":qobj.flowId, flow_id: qobj.flowId,
"status_code":qobj.statusCode status_code: qobj.statusCode,
}; };
if (qobj.statusReason && qobj.statusReason != 'undefined'){ if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.status_reason = qobj.statusReason; obj.status_reason = qobj.statusReason;
} else {
obj.status_reason = '';
} }
else{ if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.status_reason = "";
}
if (qobj.clerkName && qobj.clerkName != 'undefined'){
obj.salesman_name = qobj.clerkName; obj.salesman_name = qobj.clerkName;
} }
if (qobj.clerkId && qobj.clerkId != 'undefined'){ if (qobj.clerkId && qobj.clerkId != 'undefined') {
obj.salesman_id = qobj.clerkId; obj.salesman_id = qobj.clerkId;
} }
return await this.create(obj,t); return await this.create(obj, t);
} }
} }
module.exports = StatuslogDao; module.exports = StatuslogDao;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class AppDao extends Dao{ class AppDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(AppDao)); super(Dao.getModelName(AppDao));
} }
extraWhere(obj,w,qc,linkAttrs){ extraWhere(obj, w, qc, linkAttrs) {
if(obj.bizpath && obj.bizpath!=""){ if (obj.bizpath && obj.bizpath != '') {
if(obj.bizpath.indexOf("my_app")>0){//说明是租户查询自己创建的应用 if (obj.bizpath.indexOf('my_app') > 0) { // 说明是租户查询自己创建的应用
w["creator_id"]=obj.userid; w.creator_id = obj.userid;
} }
} }
if(linkAttrs.length>0){ if (linkAttrs.length > 0) {
var search=obj.search; const { search } = obj;
var lnkKey=linkAttrs[0]; const lnkKey = linkAttrs[0];
var strq="$"+lnkKey.replace("~",".")+"$"; const strq = `$${lnkKey.replace('~', '.')}$`;
w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"}; w[strq] = { [this.db.Op.like]: `%${search[lnkKey]}%` };
} }
return w; return w;
} }
} }
module.exports=AppDao; module.exports = AppDao;
// var u=new UserDao(); // var u=new UserDao();
// var roledao=system.getObject("db.roleDao"); // var roledao=system.getObject("db.roleDao");
// (async ()=>{ // (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}}); // var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}}); // var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role); // console.log(role);
// for(var i=0;i<users.length;i++){ // for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]); // await users[i].setRoles([role]);
// console.log(i); // console.log(i);
// } // }
// //
// })(); // })();
const fs=require("fs"); const fs = require('fs');
const settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
class CacheManager{ class CacheManager {
constructor(){ constructor() {
//await this.buildCacheMap(); // await this.buildCacheMap();
this.buildCacheMap(); this.buildCacheMap();
} }
buildCacheMap(){ buildCacheMap() {
var self=this; const self = this;
self.doc={}; self.doc = {};
var cachePath=settings.basepath+"/app/base/db/cache/"; const cachePath = `${settings.basepath}/app/base/db/cache/`;
const files=fs.readdirSync(cachePath); const files = fs.readdirSync(cachePath);
if(files){ if (files) {
files.forEach(function(r){ files.forEach((r) => {
var classObj=require(cachePath+"/"+r); const classObj = require(`${cachePath}/${r}`);
self[classObj.name]=new classObj(); self[classObj.name] = new classObj();
var refTmp=self[classObj.name]; const refTmp = self[classObj.name];
if(refTmp.prefix){ if (refTmp.prefix) {
self.doc[refTmp.prefix]=refTmp.desc; self.doc[refTmp.prefix] = refTmp.desc;
} } else {
else{ console.log(`请在${classObj.name}缓存中定义prefix`);
console.log("请在"+classObj.name+"缓存中定义prefix"); }
} });
}); }
}
} }
} }
module.exports=CacheManager; module.exports = CacheManager;
// var cm= new CacheManager(); // var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){ // cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{ // cm["InitGiftCache"].cacheGlobalVal().then(x=>{
......
const Sequelize = require('sequelize'); const Sequelize = require('sequelize');
const settings = require("../../../../config/settings") const settings = require('../../../../config/settings');
const Op = Sequelize.Op const { Op } = Sequelize;
const fs = require("fs") const fs = require('fs');
const path = require("path"); const path = require('path');
var glob = require("glob"); const glob = require('glob');
class DbFactory { class DbFactory {
constructor() { constructor() {
const dbConfig = settings.database(); const dbConfig = settings.database();
this.db = new Sequelize(dbConfig.dbname, this.db = new Sequelize(
dbConfig.dbname,
dbConfig.user, dbConfig.user,
dbConfig.password, dbConfig.password,
{ {
...@@ -46,42 +47,43 @@ class DbFactory { ...@@ -46,42 +47,43 @@ class DbFactory {
$any: Op.any, $any: Op.any,
$all: Op.all, $all: Op.all,
$values: Op.values, $values: Op.values,
$col: Op.col $col: Op.col,
} },
}); },
);
this.db.Sequelize = Sequelize; this.db.Sequelize = Sequelize;
this.db.Op = Op; this.db.Op = Op;
this.initModels(); this.initModels();
this.initRelations(); this.initRelations();
} }
async initModels() { async initModels() {
var self = this; const self = this;
var modelpath = path.normalize(path.join(__dirname, '../..')) + "/models/"; const modelpath = `${path.normalize(path.join(__dirname, '../..'))}/models/`;
var models = glob.sync(modelpath + "/**/*.js"); const models = glob.sync(`${modelpath}/**/*.js`);
console.log(models.length); console.log(models.length);
models.forEach(function (m) { models.forEach((m) => {
console.log(m); console.log(m);
self.db.import(m); self.db.import(m);
}); });
console.log("init models...."); console.log('init models....');
} }
async initRelations() { async initRelations() {
} }
//async getCon(){,用于使用替换table模型内字段数据使用 // async getCon(){,用于使用替换table模型内字段数据使用
getCon() { getCon() {
var that = this; const that = this;
// await this.db.authenticate().then(()=>{ // await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.'); // console.log('Connection has been established successfully.');
// }).catch(err => { // }).catch(err => {
// console.error('Unable to connect to the database:', err); // console.error('Unable to connect to the database:', err);
// throw err; // throw err;
// }); // });
//同步模型 // 同步模型
if (settings.env == "dev") { if (settings.env == 'dev') {
//console.log(pa); // console.log(pa);
// pconfigObjs.forEach(p=>{ // pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true})); // console.log(p.get({plain:true}));
// }); // });
...@@ -96,4 +98,4 @@ class DbFactory { ...@@ -96,4 +98,4 @@ class DbFactory {
return this.db; return this.db;
} }
} }
module.exports = DbFactory; module.exports = DbFactory;
\ No newline at end of file
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class MsgHistoryDao extends Dao{ class MsgHistoryDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(MsgHistoryDao)); super(Dao.getModelName(MsgHistoryDao));
} }
extraWhere(obj,w){ extraWhere(obj, w) {
if(obj.ukstr && obj.ukstr!=""){ if (obj.ukstr && obj.ukstr != '') {
// w={[this.db.Op.or]:[ // w={[this.db.Op.or]:[
// {[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]}, // {[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
// {[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]}, // {[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
// ] // ]
// }; // };
w[this.db.Op.or]=[ w[this.db.Op.or] = [
{[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]}, { [this.db.Op.and]: [{ sender: obj.ukstr }, { target: obj.extra }] },
{[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]}, { [this.db.Op.and]: [{ sender: obj.extra }, { target: obj.ukstr }] },
]; ];
} }
return w; return w;
} }
orderBy(){ orderBy() {
//return {"key":"include","value":{model:this.db.models.app}}; // return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]]; return [['id', 'DESC']];
} }
} }
module.exports=MsgHistoryDao; module.exports = MsgHistoryDao;
const system=require("../../../system"); const system = require('../../../system');
const Dao=require("../../dao.base"); const Dao = require('../../dao.base');
class MsgNoticeDao extends Dao{ class MsgNoticeDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(MsgNoticeDao)); super(Dao.getModelName(MsgNoticeDao));
} }
async saveNotice(msg, t) { async saveNotice(msg, t) {
var noticeFrom = await super.findOne({fromId : msg.senderId, toId : msg.targetId}); let noticeFrom = await super.findOne({ fromId: msg.senderId, toId: msg.targetId });
if(noticeFrom) { if (noticeFrom) {
var set = {lastMsgId:msg.id}; var set = { lastMsgId: msg.id };
if(msg.businessLicense_id) { if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id; set.businessLicense_id = msg.businessLicense_id;
} }
await super.updateByWhere(set, {where:{id:noticeFrom.id}}, t); await super.updateByWhere(set, { where: { id: noticeFrom.id } }, t);
} else { } else {
noticeFrom = { noticeFrom = {
fromuser: msg.sender, fromuser: msg.sender,
fromId:msg.senderId, fromId: msg.senderId,
touser: msg.target, touser: msg.target,
toId:msg.targetId, toId: msg.targetId,
isAccepted:true, isAccepted: true,
lastMsgId:msg.id, lastMsgId: msg.id,
businessLicense_id : msg.businessLicense_id || 0 businessLicense_id: msg.businessLicense_id || 0,
}; };
await super.create(noticeFrom, t); await super.create(noticeFrom, t);
} }
var noticeTo = await super.findOne({fromId : msg.targetId, toId : msg.senderId}); let noticeTo = await super.findOne({ fromId: msg.targetId, toId: msg.senderId });
if(noticeTo) { if (noticeTo) {
var set = {lastMsgId:msg.id}; var set = { lastMsgId: msg.id };
if(msg.businessLicense_id) { if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id; set.businessLicense_id = msg.businessLicense_id;
} }
await super.updateByWhere(set, {where:{id:noticeTo.id}}, t); await super.updateByWhere(set, { where: { id: noticeTo.id } }, t);
} else { } else {
noticeTo = { noticeTo = {
fromuser: msg.target, fromuser: msg.target,
fromId:msg.targetId, fromId: msg.targetId,
touser: msg.sender, touser: msg.sender,
toId:msg.senderId, toId: msg.senderId,
isAccepted:true, isAccepted: true,
lastMsgId:msg.id, lastMsgId: msg.id,
businessLicense_id : msg.businessLicense_id || 0 businessLicense_id: msg.businessLicense_id || 0,
}; };
await super.create(noticeTo, t); await super.create(noticeTo, t);
} }
} }
orderBy(){ orderBy() {
//return {"key":"include","value":{model:this.db.models.app}}; // return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]]; return [['id', 'DESC']];
} }
} }
module.exports=MsgNoticeDao; module.exports = MsgNoticeDao;
const system = require("../system"); const system = require('../system');
const settings = require("../../config/settings.js"); const settings = require('../../config/settings.js');
const reclient = system.getObject("util.redisClient"); const reclient = system.getObject('util.redisClient');
const md5 = require("MD5"); const md5 = require('MD5');
var dbf = system.getObject("db.common.connection"); const dbf = system.getObject('db.common.connection');
var db = dbf.getCon(); const db = dbf.getCon();
db.sync({ force: true }).then(async () => { db.sync({ force: true }).then(async () => {
console.log("init 完毕"); console.log('init 完毕');
}); });
const fs=require("fs"); const fs = require('fs');
const path=require("path"); const path = require('path');
const appPath=path.normalize(__dirname+"/app"); const appPath = path.normalize(`${__dirname}/app`);
const bizsPath=path.normalize(__dirname+"/bizs"); const bizsPath = path.normalize(`${__dirname}/bizs`);
var appJsons={ const appJsons = {
config:require(appPath+"/"+"platform.js").config config: require(`${appPath}/` + 'platform.js').config,
} };
module.exports=appJsons; module.exports = appJsons;
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('auth', {
return db.define("auth", { rolecode: DataTypes.STRING,
rolecode: DataTypes.STRING, bizcode: DataTypes.STRING,
bizcode: DataTypes.STRING, codepath: DataTypes.STRING,
codepath: DataTypes.STRING, authstrs: DataTypes.STRING,
authstrs: DataTypes.STRING }, {
},{ paranoid: true, // 假的删除
paranoid: true,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, // freezeTableName: true,
//freezeTableName: true, // define the table's name
// define the table's name tableName: 'p_auths',
tableName: 'p_auths', validate: {
validate: { },
} });
});
}
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('dataauth', {
return db.define("dataauth", { modelname: DataTypes.STRING,
modelname: DataTypes.STRING, auths: DataTypes.STRING,
auths: DataTypes.STRING, }, {
},{ paranoid: true, // 假的删除
paranoid: true,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, // freezeTableName: true,
//freezeTableName: true, // define the table's name
// define the table's name tableName: 'p_dataauths',
tableName: 'p_dataauths', validate: {
validate: { },
} });
});
}
const system=require("../../../system"); const system = require('../../../system');
const settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const appconfig=system.getSysConfig(); const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('org', {
return db.define("org", { code: {
code: { type: DataTypes.STRING(64),
type:DataTypes.STRING(64), allowNull: false,
allowNull: false, },
}, name: {
name: { type: DataTypes.STRING(64),
type:DataTypes.STRING(64), allowNull: false,
allowNull: false, },
}, isLeaf: {
isLeaf:{ type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: true,
defaultValue: true },
}, orgpath: {
orgpath: { type: DataTypes.STRING,
type:DataTypes.STRING, allowNull: false,
allowNull: false, },
}, nodeType: { // 默认为组织
nodeType: {//默认为组织 type: DataTypes.ENUM,
type:DataTypes.ENUM, allowNull: false,
allowNull: false, values: Object.keys(appconfig.pdict.node_type),
values: Object.keys(appconfig.pdict.node_type), defaultValue: 'org',
defaultValue:'org' },
}, isPosition: { // 是否是岗位
isPosition:{//是否是岗位 type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false },
}, isMain: { // 是否是主岗
isMain:{//是否是主岗 type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false },
}, }, {
},{ paranoid: true, // 假的删除
paranoid: true,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, // freezeTableName: true,
//freezeTableName: true, // define the table's name
// define the table's name tableName: 'p_org',
tableName: 'p_org', validate: {
validate: { },
} });
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('orgrole', {
return db.define("orgrole", {
}, {
},{ paranoid: false, // 假的删除
paranoid: false,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, tableName: 'p_orgrole',
tableName: 'p_orgrole', validate: {
validate: { },
}, });
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('role', {
return db.define("role", { name: DataTypes.STRING,
name: DataTypes.STRING, code: DataTypes.STRING,
code: DataTypes.STRING, description: DataTypes.STRING,
description: DataTypes.STRING, isSystem: { // 是否系统数据,0否,1是
isSystem: {//是否系统数据,0否,1是 type: DataTypes.BOOLEAN,
type: DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false, },
}, }, {
},{ paranoid: true, // 假的删除
paranoid: true,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, // freezeTableName: true,
//freezeTableName: true, // define the table's name
// define the table's name tableName: 'p_role',
tableName: 'p_role', validate: {
validate: { },
} });
});
}
const system=require("../../../system"); const system = require('../../../system');
const settings=require("../../../../config/settings"); const settings = require('../../../../config/settings');
const appconfig=system.getSysConfig(); const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => db.define('user', {
return db.define("user", { userName: {
userName: { type: DataTypes.STRING,
type:DataTypes.STRING, allowNull: false,
allowNull: false, },
}, password: {
password: { type: DataTypes.STRING,
type:DataTypes.STRING, allowNull: false,
allowNull: false, },
}, nickName: {
nickName: { type: DataTypes.STRING,
type:DataTypes.STRING, allowNull: true,
allowNull: true, },
}, sex: {
sex: { type: DataTypes.ENUM,
type:DataTypes.ENUM, allowNull: true,
allowNull: true, values: Object.keys(appconfig.pdict.sex),
values: Object.keys(appconfig.pdict.sex), },
}, mobile: DataTypes.STRING,
mobile:DataTypes.STRING, mail: {
mail: { type: DataTypes.STRING,
type:DataTypes.STRING, allowNull: true,
allowNull: true, },
}, headUrl: DataTypes.STRING,
headUrl: DataTypes.STRING, isAdmin: {
isAdmin:{ type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false },
}, isSuper: {
isSuper:{ type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false },
}, isSystem: {
isSystem:{ type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: false,
defaultValue: false },
}, center_id: DataTypes.STRING,
center_id:DataTypes.STRING, jwtkey: DataTypes.STRING,
jwtkey:DataTypes.STRING, jwtsecret: DataTypes.STRING,
jwtsecret:DataTypes.STRING, isEnabled: {
isEnabled:{ type: DataTypes.BOOLEAN,
type:DataTypes.BOOLEAN, defaultValue: true,
defaultValue: true },
}, opath: DataTypes.STRING, // 作业务时,需要在业务表冗余当前处理人的opath
opath:DataTypes.STRING,//作业务时,需要在业务表冗余当前处理人的opath ptags: DataTypes.STRING, // 权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据
ptags:DataTypes.STRING,//权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据 }, {
},{ paranoid: true, // 假的删除
paranoid: true,//假的删除 underscored: true,
underscored: true, version: true,
version: true, freezeTableName: true,
freezeTableName: true, // freezeTableName: true,
//freezeTableName: true, // define the table's name
// define the table's name tableName: 'p_user',
tableName: 'p_user', validate: {
validate: {
}, },
indexes:[ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ],
}); });
}
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