Commit 15ec13ec by Sxy

fix : 代码格式

parent 09aeec38
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,
},
};
......@@ -5,7 +5,7 @@ ARG webenv
ADD ic-deliver /apps/ic-deliver/
ADD web/$webenv /apps/ic-deliver/app/front/entry/public/
WORKDIR /apps/ic-deliver/
RUN cnpm install -S
RUN cnpm install -S --production
CMD ["node","/apps/ic-deliver/main.js"]
......
const system = require("../system");
const system = require('../system');
const uuidv4 = require('uuid/v4');
const settings = require("../../config/settings");
const settings = require('../../config/settings');
class APIBase {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
this.logClient = system.getObject("util.logClient");
this.cacheManager = system.getObject('db.common.cacheManager');
this.logClient = system.getObject('util.logClient');
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
const custtags = req.headers['x-consumetag'] ? req.headers['x-consumetag'].split('|') : null;
// 当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
companyid: custtags ? custtags[0].split("_")[1] : null,
password: custtags ? custtags[1].split("_")[1] : null,
username: req.headers["x-consumer-username"],
userid: req.headers["x-consumer-custom-id"],
credid: req.headers["x-credential-identifier"],
companykey: req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath: req.headers['xopath'],
ptags: req.headers['xptags'],
}
//添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags
appkey: req.headers.xappkey, // 用于系统管理区分应用,比如角色
companyid: custtags ? custtags[0].split('_')[1] : null,
password: custtags ? custtags[1].split('_')[1] : null,
username: req.headers['x-consumer-username'],
userid: req.headers['x-consumer-custom-id'],
credid: req.headers['x-credential-identifier'],
companykey: req.headers['x-company-key'], // 专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath: req.headers.xopath,
ptags: req.headers.xptags,
};
// 添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != '') {
pobj.opath = req.xctx.ptags;
} 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.username = req.xctx.username
pobj.username = req.xctx.username;
}
if (!req.xctx.appkey) {
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
return [-200, '请求头缺少应用x-app-key'];
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
// req.xctx.appid = app.id;
// pobj.app_id = app.id;//传递参数对象里注入app_id
// 平台注册时,companyid,companykey都为空
// 自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
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;
}
if (req.xctx.companyid) {//在请求传递数据对象注入公司id
if (req.xctx.companyid) { // 在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid;
}
}
async doexec(gname, methodname, pobj, query, req) {
try {
let xarg = await this.setContextParams(pobj, query, req);
const xarg = await this.setContextParams(pobj, query, req);
if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg);
}
var rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn)
const rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn);
return rtn;
} catch (e) {
this.logClient.log(pobj, req, null, e.stack);
console.log(e.stack, "api调用异常--error...................");
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
console.log(e.stack, 'api调用异常--error...................');
const rtnerror = system.getResultFail(-200, '出现异常,请联系管理员');
return rtnerror;
}
}
......
const system = require("../system");
const system = require('../system');
const uuidv4 = require('uuid/v4');
class DocBase {
constructor() {
this.apiDoc = {
group: "逻辑分组",
groupDesc: "",
name: "",
desc: "请对当前类进行描述",
exam: "概要示例",
methods: []
};
this.initClassDoc();
}
initClassDoc() {
this.descClass();
this.descMethods();
}
descClass() {
var classDesc = this.classDesc();
this.apiDoc.group = classDesc.groupName;
this.apiDoc.groupDesc = this.examDescHtml(classDesc.groupDesc);
this.apiDoc.name = classDesc.name;
this.apiDoc.desc = this.examDescHtml(classDesc.desc);
this.apiDoc.exam = this.examHtml();
}
examDescHtml(desc) {
// var tmpDesc = desc.replace(/\\/g, "<br/>");
return desc;
}
examHtml() {
var exam = this.exam();
exam = exam.replace(/\\/g, "<br/>");
return exam;
}
exam() {
throw new Error("请在子类中定义类操作示例");
}
classDesc() {
throw new Error(`
constructor() {
this.apiDoc = {
group: '逻辑分组',
groupDesc: '',
name: '',
desc: '请对当前类进行描述',
exam: '概要示例',
methods: [],
};
this.initClassDoc();
}
initClassDoc() {
this.descClass();
this.descMethods();
}
descClass() {
const classDesc = this.classDesc();
this.apiDoc.group = classDesc.groupName;
this.apiDoc.groupDesc = this.examDescHtml(classDesc.groupDesc);
this.apiDoc.name = classDesc.name;
this.apiDoc.desc = this.examDescHtml(classDesc.desc);
this.apiDoc.exam = this.examHtml();
}
examDescHtml(desc) {
// var tmpDesc = desc.replace(/\\/g, "<br/>");
return desc;
}
examHtml() {
let exam = this.exam();
exam = exam.replace(/\\/g, '<br/>');
return exam;
}
exam() {
throw new Error('请在子类中定义类操作示例');
}
classDesc() {
throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构
{
groupName:"auth",
......@@ -46,19 +46,21 @@ class DocBase {
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();
for (var methoddesc of methoddescs) {
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() {
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[
{
......@@ -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;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.appS = system.getObject("service.common.appSve");
this.apitradeSvr = system.getObject("service.common.apitradeSve");
this.authUtils = system.getObject("util.businessManager.authUtils");
this.userSve = system.getObject("service.auth.userSve");
}
constructor() {
super();
this.appS = system.getObject('service.common.appSve');
this.apitradeSvr = system.getObject('service.common.apitradeSve');
this.authUtils = system.getObject('util.businessManager.authUtils');
this.userSve = system.getObject('service.auth.userSve');
}
//不从平台应用列表入口登录时
//先要调用平台登录接口
//返回token,利用这个token再去登录某个具体APP
//会话存储具体APP的用户信息
//每个前端应用打开时,先检查是否存在token
//如果存在,就去访问获取用户信息,---调用本接口--即刻
// 不从平台应用列表入口登录时
// 先要调用平台登录接口
// 返回token,利用这个token再去登录某个具体APP
// 会话存储具体APP的用户信息
// 每个前端应用打开时,先检查是否存在token
// 如果存在,就去访问获取用户信息,---调用本接口--即刻
//进入或登录某个具体应用
//前提是已经具备了统一管理的账号,并且已经在统一管理账号登录,客户端具备了token
//进入某个具体应用时,需要指定 x-appkey请求头
//
async loginToApp(p,q,req){
let appkey=req.xctx.appkey;
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
// 进入或登录某个具体应用
// 前提是已经具备了统一管理的账号,并且已经在统一管理账号登录,客户端具备了token
// 进入某个具体应用时,需要指定 x-appkey请求头
//
async loginToApp(p, q, req) {
const { appkey } = req.xctx;
}
classDesc() {
return {
groupName: 'auth',
groupDesc: '认证相关的包',
name: 'AccessAuthAPI',
desc: '关于认证的类',
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
};
}
methodDescs() {
return [
{
methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: 'getAccessKey',
paramdescs: [
{
paramDesc: '访问appkey',
paramName: 'appkey',
paramType: 'string',
defaultValue: '',
},
{
paramDesc: '访问secret',
paramName: 'secret',
paramType: 'string',
defaultValue: '',
},
],
rtnTypeDesc: '返回JSON对象字符串',
rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
},
];
}
exam() {
return ``;
}
}
module.exports = AccessAuthAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
class RoleAuthAPI extends APIBase {
constructor() {
super();
this.authS=system.getObject("service.auth.authSve");
}
async findAuthsByRole(p,q,req){
var tmpRoles=p.roles;
var appid=p.appid;
var comid=p.companyid;
var auths=await this.authS.findAuthsByRole(tmpRoles,appid,comid);
return system.getResult(auths);
}
exam(){
return `
constructor() {
super();
this.authS = system.getObject('service.auth.authSve');
}
async findAuthsByRole(p, q, req) {
const tmpRoles = p.roles;
const { appid } = p;
const comid = p.companyid;
const auths = await this.authS.findAuthsByRole(tmpRoles, appid, comid);
return system.getResult(auths);
}
exam() {
return `
xxxxxxxxx
yyyyyyyyy
zzzzzzzzz
ooooooo
`;
}
classDesc() {
return {
groupName: "auth",
groupDesc: "角色授权相关的API",
name: "RoleAuthAPI",
desc: "角色授权相关的API",
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"
}
];
}
classDesc() {
return {
groupName: 'auth',
groupDesc: '角色授权相关的API',
name: 'RoleAuthAPI',
desc: '角色授权相关的API',
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',
},
];
}
}
module.exports = RoleAuthAPI;
\ No newline at end of file
module.exports = RoleAuthAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
class BizChanceAPI extends APIBase {
constructor() {
super();
this.bizChanceS = system.getObject("service.bizchance.bizoptSve");
this.dateUtil = system.getObject("util.dateClient");
}
/**
constructor() {
super();
this.bizChanceS = system.getObject('service.bizchance.bizoptSve');
this.dateUtil = system.getObject('util.dateClient');
}
/**
* 按照服务商进行分组统计
* @param {*} p
* @param {*} q
* @param {*} req
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizChanceCountBySp(p, q, req) {
let bizStatus = p.bizStatus
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
async statBizChanceCountBySp(p, q, req) {
const { bizStatus } = p;
const betweenTime = this.dateUtil.betweenTime(p.dateType);
const rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime);
return system.getResult(rtn);
}
/**
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizChance(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
async statBizChance(p, q, req) {
const companyId = p.company_id;
const { userid } = p;
const { username } = p;
const { opath } = p;
const betweenTime = this.dateUtil.betweenTime(p.dateType);
const rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn);
}
classDesc() {
return {
groupName: 'auth',
groupDesc: '认证相关的包',
name: 'AccessAuthAPI',
desc: '关于认证的类',
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
};
}
methodDescs() {
return [
{
methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: 'getAccessKey',
paramdescs: [
{
paramDesc: '访问appkey',
paramName: 'appkey',
paramType: 'string',
defaultValue: '',
},
{
paramDesc: '访问secret',
paramName: 'secret',
paramType: 'string',
defaultValue: '',
},
],
rtnTypeDesc: '返回JSON对象字符串',
rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
},
];
}
exam() {
return ``;
}
}
module.exports = BizChanceAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
class BizDeliverAPI extends APIBase {
constructor() {
super();
this.bizDeliveryS = system.getObject("service.bizchance.deliverybillSve")
this.dateUtil = system.getObject("util.dateClient");
}
async statBizDeliveryCountBySp(p, q, req) {
let bizStatus = p.bizStatus;
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
async statBizDeliverySettleAmountBySp(p, q, req) {
let bizStatus = p.bizStatus
let rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus)
return system.getResult(rtn)
}
/**
constructor() {
super();
this.bizDeliveryS = system.getObject('service.bizchance.deliverybillSve');
this.dateUtil = system.getObject('util.dateClient');
}
async statBizDeliveryCountBySp(p, q, req) {
const { bizStatus } = p;
const betweenTime = this.dateUtil.betweenTime(p.dateType);
const rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime);
return system.getResult(rtn);
}
async statBizDeliverySettleAmountBySp(p, q, req) {
const { bizStatus } = p;
const rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus);
return system.getResult(rtn);
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizDelivery(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime)
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
async statBizDelivery(p, q, req) {
const companyId = p.company_id;
const { userid } = p;
const { username } = p;
const { opath } = p;
const betweenTime = this.dateUtil.betweenTime(p.dateType);
const rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn);
}
classDesc() {
return {
groupName: 'auth',
groupDesc: '认证相关的包',
name: 'AccessAuthAPI',
desc: '关于认证的类',
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
};
}
methodDescs() {
return [
{
methodDesc: '生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中',
methodName: 'getAccessKey',
paramdescs: [
{
paramDesc: '访问appkey',
paramName: 'appkey',
paramType: 'string',
defaultValue: '',
},
{
paramDesc: '访问secret',
paramName: 'secret',
paramType: 'string',
defaultValue: '',
},
],
rtnTypeDesc: '返回JSON对象字符串',
rtnType: 'json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例',
},
];
}
exam() {
return ``;
}
}
module.exports = BizDeliverAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
class AppAPI extends APIBase {
constructor() {
super();
this.appS = system.getObject("service.common.appSve");
}
async create(pobj,q,req){
// console.log("oooooooooooooooooooooooooooooooooooooooooooooooo")
// console.log(req.xctx)
let rtn=this.appS.create(pobj,q,req);
return system.getResult(rtn);
}
async del(pobj,q,req){
let rtn=this.appS.delete(pobj,q,req);
return system.getResult(rtn);
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
constructor() {
super();
this.appS = system.getObject('service.common.appSve');
}
async create(pobj, q, req) {
// console.log("oooooooooooooooooooooooooooooooooooooooooooooooo")
// console.log(req.xctx)
const rtn = this.appS.create(pobj, q, req);
return system.getResult(rtn);
}
async del(pobj, q, req) {
const rtn = this.appS.delete(pobj, q, req);
return system.getResult(rtn);
}
classDesc() {
return {
groupName: 'auth',
groupDesc: '认证相关的包',
name: 'AccessAuthAPI',
desc: '关于认证的类',
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
];
}
exam() {
return ``
}
};
}
methodDescs() {
return [
];
}
exam() {
return ``;
}
}
module.exports = AppAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const APIBase = require('../../api.base');
const system = require('../../../system');
const settings = require('../../../../config/settings');
const crypto = require('crypto');
var fs=require("fs");
var accesskey='3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
var accessKeyId='LTAI4GC5tSKvqsH2hMqj6pvd';
var url="https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class OSSAPI extends APIBase{
constructor(){
super()
const fs = require('fs');
const accesskey = '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
const accessKeyId = 'LTAI4GC5tSKvqsH2hMqj6pvd';
const url = 'https://gsb-zc.oss-cn-beijing.aliyuncs.com';
class OSSAPI extends APIBase {
constructor() {
super();
}
async getOssConfig(){
var policyText = {
"expiration":"2119-12-31T16:00:00.000Z",
"conditions":[
["content-length-range",0,1048576000],
["starts-with","$key","zc"]
]
async getOssConfig() {
const policyText = {
expiration: '2119-12-31T16:00:00.000Z',
conditions: [
['content-length-range', 0, 1048576000],
['starts-with', '$key', 'zc'],
],
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature= crypto.createHmac('sha1',accesskey).update(policyBase64).digest().toString('base64'); //base64
const b = new Buffer(JSON.stringify(policyText));
const policyBase64 = b.toString('base64');
const signature = crypto.createHmac('sha1', accesskey).update(policyBase64)
.digest()
.toString('base64'); // base64
var data={
OSSAccessKeyId:accessKeyId,
policy:policyBase64,
Signature:signature,
Bucket:'gsb-zc',
success_action_status:201,
url:url
};
const data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
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 settings = require("../../config/settings");
const system = require('../system');
const settings = require('../../config/settings');
const uuidv4 = require('uuid/v4');
class CtlBase {
constructor(gname, sname) {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager");
this.logClient = system.getObject("util.logClient");
this.service = system.getObject(`service.${gname}.${sname}`);
this.cacheManager = system.getObject('db.common.cacheManager');
this.logClient = system.getObject('util.logClient');
}
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) {
const up = await this.service.update(pobj);
......@@ -25,77 +24,77 @@ class CtlBase {
return system.getResult(up);
}
async findAndCountAll(pobj, qobj, req) {
//设置查询条件
console.log(pobj)
// 设置查询条件
console.log(pobj);
const rs = await this.service.findAndCountAll(pobj);
return system.getResult(rs);
}
async refQuery(pobj, qobj, req) {
pobj.refwhere.app_id = pobj.app_id;
pobj.refwhere.company_id = pobj.company_id;
let rtn = await this.service.refQuery(pobj);
return rtn
const rtn = await this.service.refQuery(pobj);
return rtn;
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null;
let lastindex = custtags ? custtags.length - 1 : 0;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
const custtags = req.headers['x-consumetag'] ? req.headers['x-consumetag'].split('|') : null;
const lastindex = custtags ? custtags.length - 1 : 0;
// 当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
fromappkey: req.headers["xfromappkey"],//来源APP,如果没有来源与appkey相同
companyid: custtags ? custtags[0].split("_")[1] : null,
fromcompanykey: req.headers["xfromcompanykey"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
password: custtags ? custtags[lastindex].split("_")[1] : null,
username: req.headers["x-consumer-username"],
userid: req.headers["x-consumer-custom-id"],
credid: req.headers["x-credential-identifier"],
regrole: req.headers["xregrole"],
bizpath: req.headers["xbizpath"],
opath: req.headers['xopath'],
ptags: req.headers['xptags'],
codename: req.headers["xcodename"],
codetitle: req.headers["xcodetitle"] ? decodeURI(req.headers["xcodetitle"]) : '',
}
//添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags
appkey: req.headers.xappkey, // 用于系统管理区分应用,比如角色
fromappkey: req.headers.xfromappkey, // 来源APP,如果没有来源与appkey相同
companyid: custtags ? custtags[0].split('_')[1] : null,
fromcompanykey: req.headers.xfromcompanykey, // 专用于自由用户注册,自由用户用于一定属于某个存在的公司
password: custtags ? custtags[lastindex].split('_')[1] : null,
username: req.headers['x-consumer-username'],
userid: req.headers['x-consumer-custom-id'],
credid: req.headers['x-credential-identifier'],
regrole: req.headers.xregrole,
bizpath: req.headers.xbizpath,
opath: req.headers.xopath,
ptags: req.headers.xptags,
codename: req.headers.xcodename,
codetitle: req.headers.xcodetitle ? decodeURI(req.headers.xcodetitle) : '',
};
// 添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != '') {
pobj.opath = req.xctx.ptags;
} else {
pobj.opath = req.xctx.opath
pobj.opath = req.xctx.opath;
}
if (!req.xctx.appkey) {
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
// }
return [-200, '请求头缺少应用x-app-key'];
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// 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都为空
// 自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
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);
if (!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey != 'null' && req.xctx.fromcompanykey != 'undefined') {
const comptmp = await this.cacheManager.CompanyCache.cache(req.xctx.fromcompanykey);
req.xctx.companyid = comptmp.id;
}
if (req.xctx.companyid) {//在请求传递数据对象注入公司id
if (req.xctx.companyid) { // 在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid;
}
if (req.xctx.userid) {//在请求传递数据对象注入公司id
if (req.xctx.userid) { // 在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid;
pobj.username = req.xctx.username
pobj.username = req.xctx.username;
}
pobj.bizpath = req.xctx.bizpath;
}
async doexec(methodname, pobj, query, req) {
try {
let xarg = await this.setContextParams(pobj, query, req);
const xarg = await this.setContextParams(pobj, query, req);
if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg);
}
//从请求头里面取appkey_consumename
// 从请求头里面取appkey_consumename
// var consumeName=req.headers[""]
// var appkey=
// if( this.session["appkey_consumename"]) {
......@@ -105,14 +104,14 @@ class CtlBase {
// //appkey_consumename
// this.session={};
// }
//req.session=redis缓存的上下文对象
var rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn)
// req.session=redis缓存的上下文对象
const rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn);
return rtn;
} catch (e) {
this.logClient.log(pobj, req, null, e.stack);
console.log(e.stack, "出现异常,请联系管理员.......");
return system.getResultFail(-200, "出现异常,请联系管理员");
console.log(e.stack, '出现异常,请联系管理员.......');
return system.getResultFail(-200, '出现异常,请联系管理员');
}
}
}
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class AuthCtl extends CtlBase{
constructor(){
super("auth",CtlBase.getServiceName(AuthCtl));
}
async saveAuths(pobj,query,req){
var auths=pobj.auths;
var xrtn=await this.service.saveAuths(auths,pobj.app_id,pobj.company_id);
return system.getResult(xrtn);
}
async findAuthsByRoles(pobj,query,req){
var roleids=pobj.roleids;
var xrtn=await this.service.findAuthsByRole(roleids,pobj.app_id,pobj.company_id);
return system.getResult(xrtn);
}
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
class AuthCtl extends CtlBase {
constructor() {
super('auth', CtlBase.getServiceName(AuthCtl));
}
async saveAuths(pobj, query, req) {
const { auths } = pobj;
const xrtn = await this.service.saveAuths(auths, pobj.app_id, pobj.company_id);
return system.getResult(xrtn);
}
async findAuthsByRoles(pobj, query, req) {
const { roleids } = pobj;
const xrtn = await this.service.findAuthsByRole(roleids, pobj.app_id, pobj.company_id);
return system.getResult(xrtn);
}
}
module.exports=AuthCtl;
module.exports = AuthCtl;
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
class DataauthCtl extends CtlBase{
constructor(){
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);
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const logCtl = system.getObject('web.common.oplogCtl');
class DataauthCtl extends CtlBase {
constructor() {
super('auth', CtlBase.getServiceName(DataauthCtl));
}
async fetchInitAuth(qobj,querybij,req){
var uid=qobj.uid;
var refmodel=qobj.modelname;
var authtmp=await this.service.findOne({user_id:uid,modelname:refmodel,app_id:req.appid});
if(authtmp){
var auths= authtmp.auths;
var arys=auths.split(",");
async saveauth(qobj, querybij, req) {
const { arys } = qobj;
const { uid } = qobj;
const refmodel = qobj.modelname;
const 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) {
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);
}else{
return system.getResultSuccess([]);
}
return system.getResultSuccess([]);
}
}
module.exports=DataauthCtl;
module.exports = DataauthCtl;
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
class OrgCtl extends CtlBase{
constructor(){
super("auth",CtlBase.getServiceName(OrgCtl));
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const logCtl = system.getObject('web.common.oplogCtl');
class OrgCtl extends CtlBase {
constructor() {
super('auth', CtlBase.getServiceName(OrgCtl));
// this.compSvr=system.getObject("service.common.companySve");
}
//检查是否已经存在主要岗位
async checkMainPosition(p,q,req){
return this.service.checkMainPosition(p,q,req);
}
async changePos(p,q,req){
var toorgid=p.orgid;
var uid=p.uid;
var rtn= await this.service.changePos(toorgid,uid);
return system.getResult(rtn);
}
async create(p,q,req){
return super.create(p,q,req);
}
async delete(p,q,req){
return super.delete(p,q,req);
}
async update(p,q,req){
return super.update(p,q,req);
}
async initOrgs(p,q,req){
var tocompany=req.session.tocompany;
var cmkey=p.comkey;
if(cmkey){
tocompany =await this.compSvr.findOne({companykey:cmkey});
}
// 检查是否已经存在主要岗位
async checkMainPosition(p, q, req) {
return this.service.checkMainPosition(p, q, req);
}
async changePos(p, q, req) {
const toorgid = p.orgid;
const { uid } = p;
const rtn = await this.service.changePos(toorgid, uid);
return system.getResult(rtn);
}
async create(p, q, req) {
return super.create(p, q, req);
}
async delete(p, q, req) {
return super.delete(p, q, req);
}
async update(p, q, req) {
return super.update(p, q, req);
}
async initOrgs(p, q, req) {
let { tocompany } = req.session;
const cmkey = p.comkey;
if (cmkey) {
tocompany = await this.compSvr.findOne({ companykey: cmkey });
}
//按照公司名称查询,是否存在节点,不存在,就创建根节点
//如果存在就按照名称查询出当前和她的字节点
var 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);
// 按照公司名称查询,是否存在节点,不存在,就创建根节点
// 如果存在就按照名称查询出当前和她的字节点
const rtn = await this.service.initOrgs(tocompany, req.appid);
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 http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
var cacheBaseComp = null;
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const logCtl = system.getObject('web.common.oplogCtl');
const cacheBaseComp = null;
class RoleCtl extends CtlBase {
constructor() {
super("auth",CtlBase.getServiceName(RoleCtl));
this.redisClient=system.getObject("util.redisClient");
super('auth', CtlBase.getServiceName(RoleCtl));
this.redisClient = system.getObject('util.redisClient');
}
async initNewInstance(pobj,queryobj, req) {
var rtn = {};
async initNewInstance(pobj, queryobj, req) {
const rtn = {};
rtn.roles = [];
return system.getResultSuccess(rtn);
}
async create(pobj,queryobj, req) {
let r=await super.create(pobj,queryobj, req)
async create(pobj, queryobj, req) {
const r = await super.create(pobj, queryobj, req);
return system.getResult(r);
}
}
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
super('auth', CtlBase.getServiceName(UserCtl));
}
async resetPassword(pobj, qobj, req){
await this.service.resetPassword(req.xctx.username,pobj.onepassword)
async resetPassword(pobj, qobj, req) {
await this.service.resetPassword(req.xctx.username, pobj.onepassword);
return system.getResult({});
}
async allowOrNot(pobj, qobj, req){
await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{company_id:pobj.company_id})
async allowOrNot(pobj, qobj, req) {
await this.service.updateByWhere({ isEnabled: !pobj.isEnabled }, { company_id: pobj.company_id });
return system.getResult({});
}
async initNewInstance(queryobj, req) {
var rtn = {};
const rtn = {};
rtn.roles = [];
return system.getResultSuccess(rtn);
}
//获取验证码,发送给指定手机
// 获取验证码,发送给指定手机
// async sendVCode(pobj, qobj, req) {
// var mobile = pobj.mobile;
// let v = await this.smsS.sendVCode(mobile);
......@@ -30,82 +30,82 @@ class UserCtl extends CtlBase {
async exit(pobj, qobj, req) {
}
//应用的自由用户注册,无需验证,需要前端头设置公司KEY
// 应用的自由用户注册,无需验证,需要前端头设置公司KEY
async pmregisterByFreeUser(p, q, req) {
//检查是否有用户名和密码
// 检查是否有用户名和密码
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) {
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;
}
async create(p, q, req){
//检查是否有用户名和密码
async create(p, q, req) {
// 检查是否有用户名和密码
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);
}
//登录后的租户创建属于租户的用户
//需要在控制器里取出公司ID
//和租户绑定同一家公司
//按照用户名和密码进行注册
//控制器端检查用户名和密码非空
// 登录后的租户创建属于租户的用户
// 需要在控制器里取出公司ID
// 和租户绑定同一家公司
// 按照用户名和密码进行注册
// 控制器端检查用户名和密码非空
async registerByTantent(p, q, req) {
//检查是否有用户名和密码
// 检查是否有用户名和密码
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;
}
//租户用户名和密码的租户注册
// 租户用户名和密码的租户注册
async pmregister(pobj, qobj, req) {
//平台注册设置平台的应用ID
// 平台注册设置平台的应用ID
pobj.app_id = settings.pmappid;
//检查是否有用户名和密码
// 检查是否有用户名和密码
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);
}
async pmlogin(pobj, qobj, req) {
//平台注册设置平台的应用ID
let rtn = await this.service.pmlogin(pobj, qobj, req);
// 平台注册设置平台的应用ID
const rtn = await this.service.pmlogin(pobj, qobj, req);
return system.getResult(rtn);
}
async getUserInfo(pobj, qobj, req) {
let uname = req.xctx.username;
let rtn = await this.service.getUserInfo(uname);
const uname = req.xctx.username;
const rtn = await this.service.getUserInfo(uname);
return system.getResult(rtn);
}
//按照电话创建自由用户
// 按照电话创建自由用户
async pmloginByVCodeForFreeUser(p, q, req) {
if (!pobj.mobile || !pobj.vcode) {
return system.getResult(null, "请检查手机号和验证码是否存在")
return system.getResult(null, '请检查手机号和验证码是否存在');
}
p.companykey = req.xctx.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;
}
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);
}
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);
}
}
......
var system = require("../../../system");
const http = require("http");
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const moment = require('moment');
class MaterialCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(MaterialCtl));
super('bizchance', CtlBase.getServiceName(MaterialCtl));
}
/*根据交付单id获取材料信息*/
/* 根据交付单id获取材料信息*/
async findInfoByDeliverId(mobj, qobj, req) {
var pobj = mobj.d;
const pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined') {
try {
var rs = await this.service.findInfoByDeliverId(pobj);
var rarr = {};
const rs = await this.service.findInfoByDeliverId(pobj);
const rarr = {};
if (rs) {
rarr.deliverId = rs.delivery_id;
rarr.deliverNumber = rs.delivery_code;
......@@ -27,86 +27,76 @@ class MaterialCtl extends CtlBase {
rarr.expressInfo = rs.express_info;
}
return system.getResult(rarr);
}
catch (error) {
} catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
} else {
return system.getResultError('参数错误!');
}
}
/*根据交付单id更新交付单编号信息*/
/* 根据交付单id更新交付单编号信息*/
async updateInfoByDeliverId(mobj, qobj, req) {
var pobj = mobj.d;
const pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined' && pobj.deliverNumber && pobj.deliverNumber != 'undefined') {
try {
var res = await this.service.updateInfoByDeliverId(pobj);
return system.getResult("更新成功!");
}
catch (error) {
const res = await this.service.updateInfoByDeliverId(pobj);
return system.getResult('更新成功!');
} catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
} else {
return system.getResultError('参数错误!');
}
}
/*插入缓存信息 */
/* 插入缓存信息 */
async insertInfo(mobj, qobj, req) {
var pobj = mobj.d;
const pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined') {
try {
var res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!");
}
catch (error) {
const res = await this.service.insertInfo(pobj);
return system.getResult('插入成功!');
} catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
} else {
return system.getResultError('参数错误!');
}
}
/* 获取待压缩文件的信息*/
async waitGenerate() {
try {
var res = await this.service.findnoUrlInfo();
const res = await this.service.findnoUrlInfo();
if (res && res != 'undefined') {
return system.getResult(res);
}
else {
return system.getResultError("没有待压缩的数据");
}
}
catch (error) {
return system.getResultError('没有待压缩的数据');
} catch (error) {
return system.getResultError(error);
}
}
/* 根据id更新zip信息 */
async updateZipById(pobj, qobj, req) {
console.log("zip------------------" + JSON.stringify(pobj));
if (pobj.id && pobj.id != 'undefined' && pobj.url && pobj.url != 'undefined'){
try{
console.log(`zip------------------${JSON.stringify(pobj)}`);
if (pobj.id && pobj.id != 'undefined' && pobj.url && pobj.url != 'undefined') {
try {
await this.service.updateZipById(pobj);
return system.getResult("更新压缩信息成功");
}
catch(error){
return system.getResult('更新压缩信息成功');
} catch (error) {
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
} else {
return system.getResultError('参数错误!');
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
localTime = moment(localTime).format('YYYY-MM-DD');
return localTime;
}
}
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const system = require('../../../system');
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const appconfig = system.getSysConfig();
class SettleBillCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(SettleBillCtl));
super('bizchance', CtlBase.getServiceName(SettleBillCtl));
}
async advice(p,q,req){
let sid= p.advice.settleId
let msg=p.advice.memo
let userid=p.userid
let userName=p.username
let rtn=await this.service.advice(sid,msg,userid,userName)
return system.getResult(rtn)
async advice(p, q, req) {
const sid = p.advice.settleId;
const msg = p.advice.memo;
const { userid } = p;
const userName = p.username;
const rtn = await this.service.advice(sid, msg, userid, userName);
return system.getResult(rtn);
}
async auditPass(p,q,req){
let sid= p.pass.settleId
let rtn=await this.service.auditPass(sid,p.userid,p.username)
return system.getResult(rtn)
async auditPass(p, q, req) {
const sid = p.pass.settleId;
const rtn = await this.service.auditPass(sid, p.userid, p.username);
return system.getResult(rtn);
}
async pay(p,q,req){
let sid= p.pay.settleId
let rtn=await this.service.pay(sid,p.userid,p.username)
return system.getResult(rtn)
async pay(p, q, req) {
const sid = p.pay.settleId;
const rtn = await this.service.pay(sid, p.userid, p.username);
return system.getResult(rtn);
}
}
module.exports = SettleBillCtl;
......
var system = require("../../../system");
const http = require("http");
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const moment = require('moment');
class StatusLogCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(StatusLogCtl));
super('bizchance', CtlBase.getServiceName(StatusLogCtl));
}
/*插入缓存信息 */
async insertInfo(mobj,qobj,req){
var pobj = mobj.d;
if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined'
&& pobj.statusCode && pobj.statusCode != 'undefined'){
try{
var res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!");
}
catch (error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
/* 插入缓存信息 */
async insertInfo(mobj, qobj, req) {
const pobj = mobj.d;
if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined'
&& pobj.statusCode && pobj.statusCode != 'undefined') {
try {
const res = await this.service.insertInfo(pobj);
return system.getResult('插入成功!');
} catch (error) {
return system.getResultError(error);
}
} else {
return system.getResultError('参数错误!');
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
localTime = moment(localTime).format('YYYY-MM-DD');
return localTime;
}
}
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
var cacheBaseComp = null;
const cacheBaseComp = null;
class AppCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(AppCtl));
this.userCtl = system.getObject("service.auth.userSve");
super('common', CtlBase.getServiceName(AppCtl));
this.userCtl = system.getObject('service.auth.userSve');
}
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);
}
async getApp(p,q,req) {
let app= await this.cacheManager["AppCache"].cache(p.appkey, null);
return system.getResult({funcJson:JSON.parse(app.functionJSON)});
async getApp(p, q, req) {
const app = await this.cacheManager.AppCache.cache(p.appkey, null);
return system.getResult({ funcJson: JSON.parse(app.functionJSON) });
}
async translateToRouter(funarray,results,parent){
funarray.forEach(item=>{
let result={}
result.path=item.code
result.name=item.code
result.meta={
async translateToRouter(funarray, results, parent) {
funarray.forEach((item) => {
const result = {};
result.path = item.code;
result.name = item.code;
result.meta = {
hideInMenu: false,
hideInBread:false,
hideInBread: false,
notCache: true,
title:item.title,
icon:'replaceIconName'
}
result.component="replaceRightPath"
if(parent){
parent.children.push(result)
}else{
results.push(result)
title: item.title,
icon: 'replaceIconName',
};
result.component = 'replaceRightPath';
if (parent) {
parent.children.push(result);
} else {
results.push(result);
}
if(item.children && item.children.length>0){
result.children=[]
this.translateToRouter(item.children,results,result)
if (item.children && item.children.length > 0) {
result.children = [];
this.translateToRouter(item.children, results, result);
}
})
});
}
async buildFrontRouter(p,q,req){
let appkey=p.appkey
let app= await this.cacheManager["AppCache"].cache(appkey, null);
let funobj=JSON.parse(app.functionJSON)
let results=[]
await this.translateToRouter(funobj,results,null)
let rtns=await this.service.upFrontRoute(results,app.id)
await this.cacheManager["AppCache"].invalidate(appkey, null);
return system.getResult({url:rtns.url})
async buildFrontRouter(p, q, req) {
const { appkey } = p;
const app = await this.cacheManager.AppCache.cache(appkey, null);
const funobj = JSON.parse(app.functionJSON);
const results = [];
await this.translateToRouter(funobj, results, null);
const rtns = await this.service.upFrontRoute(results, app.id);
await this.cacheManager.AppCache.invalidate(appkey, null);
return system.getResult({ url: rtns.url });
}
async getFuncs(p,q,req){
let appkey=p.appkey
let app= await this.cacheManager["AppCache"].cache(appkey, null);
return system.getResult({funcJson:JSON.parse(app.functionJSON)})
//return system.getResult({funcJson:[]})
async getFuncs(p, q, req) {
const { appkey } = p;
const app = await this.cacheManager.AppCache.cache(appkey, null);
return system.getResult({ funcJson: JSON.parse(app.functionJSON) });
// return system.getResult({funcJson:[]})
}
async saveFuncTree(p,q,req){
let rtn=await this.service.saveFuncTree(p)
return system.getResult(rtn)
async saveFuncTree(p, q, req) {
const rtn = await this.service.saveFuncTree(p);
return system.getResult(rtn);
}
async create(pobj, queryobj, req) {
pobj.creator_id = pobj.userid;//设置创建者
return super.create(pobj, queryobj, req)
pobj.creator_id = pobj.userid;// 设置创建者
return super.create(pobj, queryobj, req);
}
async update(pobj, queryobj, req) {
return super.update(pobj, queryobj, req);
}
async initNewInstance(pobj, queryobj, req) {
var rtn = {};
const rtn = {};
rtn.appkey = this.getUUID();
rtn.secret = this.getUUID();
return system.getResult(rtn);
}
async resetPass(pobj, queryobj, req) {
pobj.password = await super.encryptPasswd(settings.defaultpwd);
var rtn = this.service.resetPass(pobj);
const rtn = this.service.resetPass(pobj);
return system.getResult(rtn);
}
async createAdminUser(pobj, queryobj, req) {
pobj.password = settings.defaultpwd;
var rtn = this.service.createAdminUser(pobj);
const rtn = this.service.createAdminUser(pobj);
return system.getResult(rtn);
}
async create(pobj, queryobj, req) {
//设置创建者,需要同时创建app管理员、默认密码、电话
// 设置创建者,需要同时创建app管理员、默认密码、电话
pobj.creator_id = pobj.userid;
// pobj.password=super.encryptPasswd(settings.defaultpwd);
//构造默认的应用相关的URL
pobj.authUrl = settings.protocalPrefix + pobj.domainName + "/auth";
pobj.docUrl = settings.protocalPrefix + pobj.domainName + "/web/common/metaCtl/getApiDoc";
pobj.uiconfigUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/config/fetchAppConfig";
pobj.opCacheUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/opCache/opCacheData";
pobj.notifyCacheCountUrl = settings.protocalPrefix + pobj.domainName + "/api/meta/opCache/recvNotificationForCacheCount";
var app = await super.create(pobj, queryobj, req);
// 构造默认的应用相关的URL
pobj.authUrl = `${settings.protocalPrefix + pobj.domainName}/auth`;
pobj.docUrl = `${settings.protocalPrefix + pobj.domainName}/web/common/metaCtl/getApiDoc`;
pobj.uiconfigUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/config/fetchAppConfig`;
pobj.opCacheUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/opCache/opCacheData`;
pobj.notifyCacheCountUrl = `${settings.protocalPrefix + pobj.domainName}/api/meta/opCache/recvNotificationForCacheCount`;
const app = await super.create(pobj, queryobj, req);
return system.getResult(app);
}
async fetchApiCallData(pobj, queryobj, req) {
var curappkey = pobj.curappkey;
//检索出作为访问时的app呼出调用数据
var rtn = await this.service.fetchApiCallData(curappkey);
const { curappkey } = pobj;
// 检索出作为访问时的app呼出调用数据
const rtn = await this.service.fetchApiCallData(curappkey);
return system.getResultSuccess(rtn);
}
//接受缓存计数通知接口
// 接受缓存计数通知接口
async recvNotificationForCacheCount(p, q, req) {
return this.service.recvNotificationForCacheCount(p);
}
......@@ -115,9 +114,9 @@ class AppCtl extends CtlBase {
module.exports = AppCtl;
var p={"appkey":"08cb8300-ef1e-4e35-ba49-3de36ba497d2"}
let acl=new AppCtl()
const p = { appkey: '08cb8300-ef1e-4e35-ba49-3de36ba497d2' };
const acl = new AppCtl();
acl.buildFrontRouter(p).then(res=>{
console.log(res.data)
})
\ No newline at end of file
acl.buildFrontRouter(p).then((res) => {
console.log(res.data);
});
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const system = require('../../../system');
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const uuidv4 = require('uuid/v4');
class CachSearchesCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(CachSearchesCtl));
super('common', CtlBase.getServiceName(CachSearchesCtl));
}
async initNewInstance(queryobj, qobj) {
return system.getResultSuccess({});
......@@ -15,11 +15,11 @@ class CachSearchesCtl extends CtlBase {
return await this.service.findAndCountAllCache(pobj);
}
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);
}
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);
}
}
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
class CompanyCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(CompanyCtl));
super('common', CtlBase.getServiceName(CompanyCtl));
}
async update(p,q,req){
let u= await super.update(p,q,req)
//缓存失效
await this.cacheManager["CompanyCache"].invalidate(p.companykey)
let company=await this.cacheManager["CompanyCache"].cache(p.companykey)
return system.getResult(company)
async update(p, q, req) {
const u = await super.update(p, q, req);
// 缓存失效
await this.cacheManager.CompanyCache.invalidate(p.companykey);
const company = await this.cacheManager.CompanyCache.cache(p.companykey);
return system.getResult(company);
}
async setOrgs(p,q,req){
let orgs=await this.service.setOrgs(p,req.xctx.fromcompanykey)
return system.getResult(orgs)
}
async getOrgs(p,q,req){
let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
return system.getResult({orgJson:JSON.parse(companynew.orgJson)})
}
async setOrgs(p, q, req) {
const orgs = await this.service.setOrgs(p, req.xctx.fromcompanykey);
return system.getResult(orgs);
}
async getOrgs(p, q, req) {
const companynew = await this.cacheManager.CompanyCache.cache(req.xctx.fromcompanykey);
return system.getResult({ orgJson: JSON.parse(companynew.orgJson) });
}
}
module.exports = CompanyCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
const system = require('../../../system');
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const cacheBaseComp = null;
class MetaCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(MetaCtl));
super('common', CtlBase.getServiceName(MetaCtl));
}
}
module.exports = MetaCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const system = require('../../../system');
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
const uuidv4 = require('uuid/v4');
var moment = require("moment");
const moment = require('moment');
class OplogCtl extends CtlBase {
constructor() {
super("common",CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve");
super('common', CtlBase.getServiceName(OplogCtl));
// this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj) {
var u = uuidv4();
var aid = u.replace(/\-/g, "");
var rd = { name: "", appid: aid }
const u = uuidv4();
const aid = u.replace(/\-/g, '');
const rd = { name: '', appid: aid };
return system.getResult(rd);
}
async debug(obj) {
obj.logLevel = "debug";
obj.logLevel = 'debug';
return this.create(obj);
}
async info(obj) {
obj.logLevel = "info";
obj.logLevel = 'info';
return this.create(obj);
}
async warn(obj) {
obj.logLevel = "warn";
obj.logLevel = 'warn';
return this.create(obj);
}
async error(obj) {
obj.logLevel = "error";
obj.logLevel = 'error';
return this.create(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
obj.logLevel = 'fatal';
return this.create(obj);
}
......@@ -41,17 +41,17 @@ class OplogCtl extends CtlBase {
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
prefix = (prefix || "");
prefix = (prefix || '');
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
const prefixlength = prefix.length;
const subLen = 8 - prefixlength;
let uidStr = '';
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
const timStr = moment().format('YYYYMMDDHHmm');
return prefix + timStr + uidStr;
}
/*
......@@ -59,13 +59,13 @@ prefix:业务前缀
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
const uuid = []; let i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
var cacheBaseComp = null;
const cacheBaseComp = null;
class PConfigCtl extends CtlBase {
constructor() {
super("common",CtlBase.getServiceName(PConfigCtl));
this.userCtl = system.getObject("service.auth.userSve");
super('common', CtlBase.getServiceName(PConfigCtl));
this.userCtl = system.getObject('service.auth.userSve');
}
async initNewInstance(pobj,queryobj, req) {
var rtn = {};
async initNewInstance(pobj, queryobj, req) {
const rtn = {};
return system.getResult(rtn);
}
async create(pobj,queryobj, req) {
pobj.app_id=req.appid;
pobj.appkey=req.appkey;
var rtn=await super.create(pobj,queryobj, req);
async create(pobj, queryobj, req) {
pobj.app_id = req.appid;
pobj.appkey = req.appkey;
const rtn = await super.create(pobj, queryobj, req);
return system.getResult(rtn);
}
async update(pobj,queryobj, req) {
pobj.app_id=req.appid;
pobj.appkey=req.appkey;
var rtn=await super.update(pobj);
async update(pobj, queryobj, req) {
pobj.app_id = req.appid;
pobj.appkey = req.appkey;
const rtn = await super.update(pobj);
return system.getResult(rtn);
}
}
......
var system = require("../../../system")
const http = require("http")
const system = require('../../../system');
const http = require('http');
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const settings = require('../../../../config/settings');
const CtlBase = require('../../ctl.base');
var cacheBaseComp = null;
const cacheBaseComp = null;
class RouteCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(RouteCtl));
this.appS=system.getObject("service.common.appSve")
super('common', CtlBase.getServiceName(RouteCtl));
this.appS = system.getObject('service.common.appSve');
}
async create(p,q,req){
let appid=p.app_id;
let apptmp= await this.appS.findById(appid)
let routedata={
name:p.name,
hosts:p.shosts.split(","),
paths:p.spaths.split(","),
isstrip:false,
app_id:appid,
shosts:p.shosts,
spaths:p.spaths
}
let rtn= await this.service.create(apptmp.name, routedata, req);
return system.getResult(rtn)
async create(p, q, req) {
const appid = p.app_id;
const apptmp = await this.appS.findById(appid);
const routedata = {
name: p.name,
hosts: p.shosts.split(','),
paths: p.spaths.split(','),
isstrip: false,
app_id: appid,
shosts: p.shosts,
spaths: p.spaths,
};
const rtn = await this.service.create(apptmp.name, routedata, req);
return system.getResult(rtn);
}
}
module.exports = RouteCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
class SocketNotifyCtl{
constructor(){
}
setSocketServer(s){
this.socketServer=s;
}
//异步推送消息到客户端
notifyClientMsg(user,msg){
var uk= this.buildPrivateChannel(user);
var msgHandler=this.socketServer.users[uk];
msgHandler.notifyClient(uk,msg);
}
buildPrivateChannel(user){
var ukchannel= user.app_id+"¥"+user.id;
return ukchannel;
}
buildMsgTarget(user){
var ukchannel= user.app_id+"¥"+user.id;
var nickName=user.nickName;
var imgUrl=user.imgUrl;
var rtn=ukchannel+"¥"+nickName+"¥"+imgUrl;
return rtn;
}
const system = require('../../../system');
const settings = require('../../../../config/settings');
class SocketNotifyCtl {
constructor() {
}
setSocketServer(s) {
this.socketServer = s;
}
// 异步推送消息到客户端
notifyClientMsg(user, msg) {
const uk = this.buildPrivateChannel(user);
const msgHandler = this.socketServer.users[uk];
msgHandler.notifyClient(uk, msg);
}
buildPrivateChannel(user) {
const ukchannel = `${user.app_id}${user.id}`;
return ukchannel;
}
buildMsgTarget(user) {
const ukchannel = `${user.app_id}${user.id}`;
const { nickName } = user;
const { imgUrl } = user;
const rtn = `${ukchannel}${nickName}${imgUrl}`;
return rtn;
}
}
module.exports=SocketNotifyCtl;
module.exports = SocketNotifyCtl;
var system=require("../../../system")
const CtlBase = require("../../ctl.base");
const system = require('../../../system');
const CtlBase = require('../../ctl.base');
const crypto = require('crypto');
var fs=require("fs");
var accesskey='3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
var accessKeyId='LTAI4GC5tSKvqsH2hMqj6pvd';
var url="https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class UploadCtl extends CtlBase{
constructor(){
super("common",CtlBase.getServiceName(UploadCtl));
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'";
this.restS=system.getObject("util.execClient");
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'";
//sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path}
const fs = require('fs');
const accesskey = '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
const accessKeyId = 'LTAI4GC5tSKvqsH2hMqj6pvd';
const url = 'https://gsb-zc.oss-cn-beijing.aliyuncs.com';
class UploadCtl extends CtlBase {
constructor() {
super('common', CtlBase.getServiceName(UploadCtl));
this.cmdPdf2HtmlPattern = 'docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 \'{fileName}\'';
this.restS = system.getObject('util.execClient');
this.cmdInsertToFilePattern = 'sed -i \'s/id="page-container"/id="page-container" contenteditable="true"/\'';
// sed -i 's/1111/&BBB/' /tmp/input.txt
// sed 's/{position}/{content}/g' {path}
}
async getOssConfig(){
var policyText = {
"expiration":"2119-12-31T16:00:00.000Z",
"conditions":[
["content-length-range",0,1048576000],
["starts-with","$key","zc"]
]
async getOssConfig() {
const policyText = {
expiration: '2119-12-31T16:00:00.000Z',
conditions: [
['content-length-range', 0, 1048576000],
['starts-with', '$key', 'zc'],
],
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature= crypto.createHmac('sha1',accesskey).update(policyBase64).digest().toString('base64'); //base64
const b = new Buffer(JSON.stringify(policyText));
const policyBase64 = b.toString('base64');
const signature = crypto.createHmac('sha1', accesskey).update(policyBase64)
.digest()
.toString('base64'); // base64
var data={
OSSAccessKeyId:accessKeyId,
policy:policyBase64,
Signature:signature,
Bucket:'gsb-zc',
success_action_status:201,
url:url
};
const data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
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 settings = require("../../../../config/settings");
const system = require('../../../system');
const settings = require('../../../../config/settings');
function exp(db, DataTypes) {
var base = {
const base = {
code: {
type: DataTypes.STRING(50),
unique: true
unique: true,
},
name: DataTypes.STRING(1000),
};
......
const system = require("../../system");
const settings = require("../../../config/settings");
const system = require('../../system');
const settings = require('../../../config/settings');
const appconfig = system.getSysConfig();
function exp(db, DataTypes) {
var base = {
//继承的表引用用户信息user_id
const base = {
// 继承的表引用用户信息user_id
code: DataTypes.STRING(100),
name: DataTypes.STRING(500),
creator: DataTypes.STRING(100),//创建者
updator: DataTypes.STRING(100),//更新者
auditor: DataTypes.STRING(100),//审核者
opNotes: DataTypes.STRING(500),//操作备注
creator: DataTypes.STRING(100), // 创建者
updator: DataTypes.STRING(100), // 更新者
auditor: DataTypes.STRING(100), // 审核者
opNotes: DataTypes.STRING(500), // 操作备注
auditStatusName: {
type:DataTypes.STRING(50),
defaultValue:"待审核",
type: DataTypes.STRING(50),
defaultValue: '待审核',
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
auditStatus: { // 审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(appconfig.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", appconfig.pdict.audit_status[val]);
set(val) {
this.setDataValue('auditStatus', val);
this.setDataValue('auditStatusName', appconfig.pdict.audit_status[val]);
},
defaultValue:"dsh",
defaultValue: 'dsh',
},
sourceTypeName: DataTypes.STRING(50),
sourceType: {//来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单"
sourceType: { // 来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) {
this.setDataValue("sourceType", val);
this.setDataValue("sourceTypeName", appconfig.pdict.source_type[val]);
}
set(val) {
this.setDataValue('sourceType', val);
this.setDataValue('sourceTypeName', appconfig.pdict.source_type[val]);
},
},
sourceOrderNo: DataTypes.STRING(100),//来源单号
sourceOrderNo: DataTypes.STRING(100), // 来源单号
};
return base;
}
......
const system = require("../system")
const settings = require("../../config/settings.js");
const system = require('../system');
const settings = require('../../config/settings.js');
class CacheBase {
constructor() {
this.db = system.getObject("db.common.connection").getCon();
this.redisClient = system.getObject("util.redisClient");
this.db = system.getObject('db.common.connection').getCon();
this.redisClient = system.getObject('util.redisClient');
this.desc = this.desc();
this.prefix = this.prefix();
this.cacheCacheKeyPrefix = "sadd_base:cachekey";
this.cacheCacheKeyPrefix = 'sadd_base:cachekey';
this.isdebug = this.isdebug();
}
isdebug() {
return false;
}
desc() {
throw new Error("子类需要定义desc方法,返回缓存描述");
throw new Error('子类需要定义desc方法,返回缓存描述');
}
prefix() {
throw new Error("子类需要定义prefix方法,返回本缓存的前缀");
throw new Error('子类需要定义prefix方法,返回本缓存的前缀');
}
async cache(inputkey, val, ex, ...items) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) {
var objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
const cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == 'undefined' || cacheValue == 'null' || this.isdebug) {
const objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objvalstr) {
return null;
}
......@@ -31,25 +31,23 @@ class CacheBase {
} else {
await this.redisClient.set(cachekey, objvalstr);
}
//缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]);
// 缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [`${cachekey}|${this.desc}`]);
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) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null") {
const cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == 'undefined' || cacheValue == '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) {
const cachekey = this.prefix + inputkey;
......@@ -57,7 +55,7 @@ class CacheBase {
return 0;
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
throw new Error("子类中实现构建缓存值的方法,返回字符串");
throw new Error('子类中实现构建缓存值的方法,返回字符串');
}
}
module.exports = CacheBase;
const CacheBase=require("../cache.base");
const system=require("../../system");
//缓存首次登录的赠送的宝币数量
class CacheLocker extends CacheBase{
constructor(){
super();
this.prefix="locker_";
}
desc(){
const CacheBase = require('../cache.base');
const system = require('../../system');
// 缓存首次登录的赠送的宝币数量
class CacheLocker extends CacheBase {
constructor() {
super();
this.prefix = 'locker_';
}
desc() {
}
prefix(){
}
async init(tradekey){
const key=this.prefix+tradekey;
return this.redisClient.rpushWithEx(key,"1",1800);
}
async enter(tradekey){
const key=this.prefix+tradekey;
return this.redisClient.rpop(key);
}
async release(tradekey){
const key=this.prefix+tradekey;
return this.redisClient.rpushWithEx(key,"1",1800);
}
}
prefix() {
}
async init(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, '1', 1800);
}
async enter(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpop(key);
}
async release(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, '1', 1800);
}
}
module.exports=CacheLocker;
module.exports = CacheLocker;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class AppCache extends CacheBase{
constructor(){
const CacheBase = require('../cache.base');
const system = require('../../system');
const settings = require('../../../config/settings');
class AppCache extends CacheBase {
constructor() {
super();
this.prefix="g_centerappkey:";
this.appDao=system.getObject("db.common.appDao");
this.prefix = 'g_centerappkey:';
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;
\ No newline at end of file
module.exports = AppCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class CompanyCache extends CacheBase{
constructor(){
const CacheBase = require('../cache.base');
const system = require('../../system');
const settings = require('../../../config/settings');
class CompanyCache extends CacheBase {
constructor() {
super();
this.prefix="g_centercompanykey:";
this.companyDao=system.getObject("db.common.companyDao");
this.prefix = 'g_centercompanykey:';
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;
\ No newline at end of file
module.exports = CompanyCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const CacheBase = require('../cache.base');
const system = require('../../system');
class MagCache extends CacheBase {
constructor() {
super();
this.prefix = "magCache";
this.prefix = 'magCache';
}
desc() {
return "管理当前缓存的key";
return '管理当前缓存的key';
}
prefix() {
return "g_magcache:";
return 'g_magcache:';
}
async getCacheSmembersByKey(key) {
return this.redisClient.smembers(key);
}
async delCacheBySrem(key, value) {
return this.redisClient.srem(key, value)
return this.redisClient.srem(key, value);
}
async keys(p) {
return this.redisClient.keys(p);
......@@ -28,7 +28,7 @@ class MagCache extends CacheBase {
return this.redisClient.delete(k);
}
async clearAll() {
console.log("xxxxxxxxxxxxxxxxxxxclearAll............");
console.log('xxxxxxxxxxxxxxxxxxxclearAll............');
return this.redisClient.flushall();
}
}
......
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class UserCache extends CacheBase{
constructor(){
const CacheBase = require('../cache.base');
const system = require('../../system');
const settings = require('../../../config/settings');
class UserCache extends CacheBase {
constructor() {
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;
\ No newline at end of file
module.exports = UserCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
const CacheBase = require('../cache.base');
const system = require('../../system');
const settings = require('../../../config/settings');
// 缓存首次登录的赠送的宝币数量
class VCodeCache extends CacheBase {
constructor() {
super();
this.smsUtil = system.getObject("util.smsClient");
this.smsUtil = system.getObject('util.smsClient');
}
// isdebug() {
// return settings.env == "dev";
// }
desc() {
return "缓存给手机发送的验证码60妙";
return '缓存给手机发送的验证码60妙';
}
prefix() {
return "g_vcode_"
return 'g_vcode_';
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
//inputkey采用appkey_mobile的形式
var mobile = inputkey;
var tmplCode = val;
var signName = items ? items[0] : "";
var vcode = await this.smsUtil.getUidStr(6, 10);
// inputkey采用appkey_mobile的形式
const mobile = inputkey;
const tmplCode = val;
const signName = items ? items[0] : '';
const vcode = await this.smsUtil.getUidStr(6, 10);
if (!tmplCode && !signName) {
this.smsUtil.sendMsg(mobile, vcode);
} //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
} // tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else {
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode }));
}
return JSON.stringify({ vcode: vcode });
return JSON.stringify({ vcode });
}
}
module.exports = VCodeCache;
const system=require("../../../system");
const Dao=require("../../dao.base");
class AuthDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class AuthDao extends Dao {
constructor() {
super(Dao.getModelName(AuthDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
extraWhere(qobj, qw, qc) {
qc.raw = true;
return qw;
}
}
module.exports=AuthDao;
module.exports = AuthDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class DataauthDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class DataauthDao extends Dao {
constructor() {
super(Dao.getModelName(DataauthDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
extraWhere(qobj, qw, qc) {
qc.raw = true;
return qw;
}
}
module.exports=DataauthDao;
module.exports = DataauthDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class OrgDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class OrgDao extends Dao {
constructor() {
super(Dao.getModelName(OrgDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
extraWhere(qobj, qw, qc) {
qc.raw = true;
return qw;
}
}
module.exports=OrgDao;
module.exports = OrgDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class RoleDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class RoleDao extends Dao {
constructor() {
super(Dao.getModelName(RoleDao));
}
async findOne(paramappid,t){
var app= await this.model.findOne({where:{appid:paramappid}},{transaction:t});
async findOne(paramappid, t) {
const app = await this.model.findOne({ where: { appid: paramappid } }, { transaction: t });
return app;
}
extraWhere(obj,w,qc,linkAttrs){
extraWhere(obj, w, qc, linkAttrs) {
// if(obj.codepath && obj.codepath!=""){
// // if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// // console.log(obj);
// // w["app_id"]=obj.appid;
// // }
// }
w["app_id"]=obj.app_id;
w["company_id"]=obj.company_id;
w.app_id = obj.app_id;
w.company_id = obj.company_id;
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;
}
async update(obj){
var obj2=await this.preUpdate(obj);
await this.model.update(obj2,{where:{id:obj2.id}});
var role=await this.model.findOne({where:{id:obj2.id}});
async update(obj) {
const obj2 = await this.preUpdate(obj);
await this.model.update(obj2, { where: { id: obj2.id } });
const role = await this.model.findOne({ where: { id: obj2.id } });
return role;
}
async preCreate(u){
async preCreate(u) {
return u;
}
async create(u,t){
var self=this;
var u2= await this.preCreate(u);
if(t){
var role= await this.model.create(u2,{transaction: t});
return role;
}else{
var role= await this.model.create(u2);
return role;
}
async create(u, t) {
const self = this;
const u2 = await this.preCreate(u);
if (t) {
var role = await this.model.create(u2, { transaction: t });
return role;
}
var role = await this.model.create(u2);
return role;
}
}
module.exports=RoleDao;
module.exports = RoleDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class BizoptDao extends Dao {
constructor() {
super(Dao.getModelName(BizoptDao));
}
extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
extraWhere(qobj, qw, qc) { // 根据业务员id获取商机信息的组装条件
qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
// 检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` }
}
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.business_type = qc.where.business_type || {
[this.db.Op.notIn]: ["ICP", "EDI", "bookkeeping"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myChance") > 0) {//说明是从商机列表过来的
qw["salesman_id"] = qobj.userid;
}
return qw;
}
// 需要添加公司查询条件
qw.facilitator_id = Number(qobj.company_id);
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != '') {
qw.salesman_opcode = { [this.db.Op.like]: `%${qobj.opath}%` };
}
// 不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf('pmx') < 0) {
qc.where.business_type = qc.where.business_type || {
[this.db.Op.notIn]: ['ICP', 'EDI', 'bookkeeping'],
};
if (qobj.bizpath && qobj.bizpath != '') {
if (qobj.bizpath.indexOf('myChance') > 0) { // 说明是从商机列表过来的
qw.salesman_id = qobj.userid;
}
}
}
return qw;
}
/*根据商机编号获取商机详情*/
/* 根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj) {
var qcwhere = { "demand_code": qobj.businessMode };
const qcwhere = { demand_code: qobj.businessMode };
return await this.findOne(qcwhere);
}
/*更新商机状态*/
/* 更新商机状态*/
async updateStatusByDemandCode(qobj, t) {
var setobj = { "business_status": qobj.currentStatus };
const setobj = { business_status: qobj.currentStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj["close_reason"] = qobj.statusReason;
}
else {
setobj["close_reason"] = "";
setobj.close_reason = qobj.statusReason;
} else {
setobj.close_reason = '';
}
var whereobj = { "demand_code": qobj.businessMode };
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新业务员信息*/
/* 更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj, t) {
var setobj = {};
const setobj = {};
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
setobj.salesman_id = qobj.salesmanId;
};
......@@ -73,17 +71,17 @@ class BizoptDao extends Dao {
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName;
};
var whereobj = { "demand_code": qobj.businessMode };
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入商机信息*/
/* 插入商机信息*/
async insertInfo(qobj, t) {
var obj = {
"demand_code": qobj.businessMode,
"business_type": qobj.businessType,
"business_status": qobj.currentStatus,
"business_info": {}
const obj = {
demand_code: qobj.businessMode,
business_type: qobj.businessType,
business_status: qobj.currentStatus,
business_info: {},
};
if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource;
......@@ -104,7 +102,7 @@ class BizoptDao extends Dao {
obj.business_info.contactsName = qobj.contactsName;
}
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone;//已经加密
obj.business_info.contactsPhone = qobj.contactsPhone;// 已经加密
}
if (qobj.serviceName && qobj.serviceName != 'undefined') {
obj.business_info.serviceName = qobj.serviceName;
......@@ -138,7 +136,5 @@ class BizoptDao extends Dao {
}
return await this.create(obj, t);
}
}
module.exports = BizoptDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class CacheinfoDao extends Dao {
constructor() {
super(Dao.getModelName(CacheinfoDao));
}
// extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
// qc.raw = true;
// qc.where.business_type = qc.where.business_type || {
// [this.db.Op.notIn]: ["ICP", "EDI"]
// }
// if(qobj.bizpath && qobj.bizpath!=""){
// if(qobj.bizpath.indexOf("myChance")>0){//说明是从商机列表过来的
// qw["salesman_id"]=qobj.userid;
// }
// }
// extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
// qc.raw = true;
// qc.where.business_type = qc.where.business_type || {
// [this.db.Op.notIn]: ["ICP", "EDI"]
// }
// if(qobj.bizpath && qobj.bizpath!=""){
// if(qobj.bizpath.indexOf("myChance")>0){//说明是从商机列表过来的
// qw["salesman_id"]=qobj.userid;
// }
// }
// return qw;
// }
// return qw;
// }
/*根据订单id获取缓存信息详情*/
async findInfoByDeliverId(qobj){
var qcwhere = {"deliver_id":qobj.deliverNumber};
/* 根据订单id获取缓存信息详情*/
async findInfoByDeliverId(qobj) {
const qcwhere = { deliver_id: qobj.deliverNumber };
return await this.findOne(qcwhere);
}
}
/*更加订单id更新缓存信息*/
async updateInfoByDeliverId(qobj,t){
var setobj = {"cache_info":qobj.cacheInfo};
var whereobj = {"deliver_id":qobj.deliverNumber};
return await this.updateByWhere(setobj,whereobj,t);
/* 更加订单id更新缓存信息*/
async updateInfoByDeliverId(qobj, t) {
const setobj = { cache_info: qobj.cacheInfo };
const whereobj = { deliver_id: qobj.deliverNumber };
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入缓存信息*/
async insertInfo(qobj,t){
var obj = {
"deliver_id":qobj.deliverNumber,
"cache_info":qobj.cacheInfo
/* 插入缓存信息*/
async insertInfo(qobj, t) {
const obj = {
deliver_id: qobj.deliverNumber,
cache_info: qobj.cacheInfo,
};
return await this.create(obj,t);
return await this.create(obj, t);
}
}
module.exports = CacheinfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class DeliverybillDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverybillDao));
}
extraModelFilter(pobj) {
return { "key": "include", "value": { model: this.db.models.settlebill, raw: true, attributes: ['memo'] } };
return { key: 'include', value: { model: this.db.models.settlebill, raw: true, attributes: ['memo'] } };
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qw["delivery_status"] == "handling") {//解决首页多状态查询
qw["delivery_status"] = { [this.db.Op.notIn]: ['received', 'success', 'closed'] }
extraWhere(qobj, qw, qc) { // 根据业务员id获取交付单信息的组装条件
// qc.raw = true;
// 检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qw.delivery_status == 'handling') { // 解决首页多状态查询
qw.delivery_status = { [this.db.Op.notIn]: ['received', 'success', 'closed'] };
}
if (qobj.company_id == 1) {
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是从商机列表过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
if (qobj.bizpath && qobj.bizpath != '') {
if (qobj.bizpath.indexOf('pmxdeliverrequest') > 0) { // 说明是从商机列表过来的
qw.delivery_status = 'success';
qw.settle_status = 'waittosettle';
}
}
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["delivery_man_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` }
} else {//说明是租户管理员,给租户自己核销结算的功能,
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是结算核销路由过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
}
return qw;
}
// 需要添加公司查询条件
qw.facilitator_id = Number(qobj.company_id);
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != '') {
qw.delivery_man_opcode = { [this.db.Op.like]: `%${qobj.opath}%` };
} else { // 说明是租户管理员,给租户自己核销结算的功能,
if (qobj.bizpath.indexOf('pmxdeliverrequest') > 0) { // 说明是结算核销路由过来的
qw.delivery_status = 'success';
qw.settle_status = 'waittosettle';
}
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.product_code = qc.where.product_code || {
[this.db.Op.notIn]: ["ICP", "EDI", "ICPANNUALREPORT", "EDIANNUALREPORT", "bookkeeping"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myDeliver") > 0) {//说明是从商机列表过来的
qw["delivery_man_id"] = qobj.userid;
}
}
// 不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf('pmx') < 0) {
qc.where.product_code = qc.where.product_code || {
[this.db.Op.notIn]: ['ICP', 'EDI', 'ICPANNUALREPORT', 'EDIANNUALREPORT', 'bookkeeping'],
};
if (qobj.bizpath && qobj.bizpath != '') {
if (qobj.bizpath.indexOf('myDeliver') > 0) { // 说明是从商机列表过来的
qw.delivery_man_id = qobj.userid;
}
}
}
return qw;
}
/*根据交付单编号获取订单详情*/
/* 根据交付单编号获取订单详情*/
async findInfoByDeliverCode(qobj) {
var qcwhere = { "delivery_code": qobj.deliverNumber };
const qcwhere = { delivery_code: qobj.deliverNumber };
return await this.findOne(qcwhere);
}
/*根据交付单编号更新状态信息*/
/* 根据交付单编号更新状态信息*/
async updateStatusByDeliverCode(qobj, t) {
var setobj = { "delivery_status": qobj.deliverStatus };
const setobj = { delivery_status: qobj.deliverStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
} else {
setobj.close_reason = '';
}
else {
setobj.close_reason = "";
}
var whereobj = { "delivery_code": qobj.deliverNumber };
var rs = await this.findOne(whereobj);
const whereobj = { delivery_code: qobj.deliverNumber };
const rs = await this.findOne(whereobj);
if (rs && rs != 'undefined') {
if (qobj.deliverStatus == "collecting" || qobj.deliverStatus == "received" || qobj.deliverStatus == "paid" || qobj.deliverStatus == "userConfirmationReject") {//兼顾阿里
rs.delivery_info.payStatus = "待交付";
}
else if (qobj.deliverStatus == "closed") {
rs.delivery_info.payStatus = "已关闭";
}
else {
rs.delivery_info.payStatus = "已交付";
if (qobj.deliverStatus == 'collecting' || qobj.deliverStatus == 'received' || qobj.deliverStatus == 'paid' || qobj.deliverStatus == 'userConfirmationReject') { // 兼顾阿里
rs.delivery_info.payStatus = '待交付';
} else if (qobj.deliverStatus == 'closed') {
rs.delivery_info.payStatus = '已关闭';
} else {
rs.delivery_info.payStatus = '已交付';
}
setobj.delivery_info = rs.delivery_info;
}
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新业务员/交付员信息*/
/* 更新业务员/交付员信息*/
async updateSalesmanInfoByDeliverCode(qobj, t) {
var setobj = {};
if (qobj.type == "salesman") {
const setobj = {};
if (qobj.type == 'salesman') {
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
setobj.salesman_id = qobj.salesmanId;
};
......@@ -98,7 +94,7 @@ class DeliverybillDao extends Dao {
setobj.salesman_opcode = qobj.salesmanOpcode;
};
}
if (qobj.type == "deliverman") {
if (qobj.type == 'deliverman') {
if (qobj.deliverymanId && qobj.deliverymanId != 'undefined') {
setobj.delivery_man_id = qobj.deliverymanId;
};
......@@ -118,32 +114,31 @@ class DeliverybillDao extends Dao {
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName;
};
var whereobj = { "delivery_code": qobj.deliverNumber };
const whereobj = { delivery_code: qobj.deliverNumber };
return await this.updateByWhere(setobj, whereobj, t);
}
/*根据交付单更新交付材料信息*/
async updateInfoByDeliverCode(qobj, t) {//公司注册、云上园区注册时填写交付材料
var whereobj = { "delivery_code": qobj.deliverNumber };
var setobj = { "delivery_info": qobj.baseInfo };
/* 根据交付单更新交付材料信息*/
async updateInfoByDeliverCode(qobj, t) { // 公司注册、云上园区注册时填写交付材料
const whereobj = { delivery_code: qobj.deliverNumber };
const setobj = { delivery_info: qobj.baseInfo };
if (qobj.deliverStatus && qobj.deliverStatus != 'undefined') {
setobj.delivery_status = qobj.deliverStatus;
}
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
}
else {
setobj.close_reason = "";
} else {
setobj.close_reason = '';
}
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入交付单信息*/
async insertInfo(qobj, t) {//到时候看交付单信息后再确定
var obj = {
"delivery_code": qobj.deliverNumber,
"delivery_status": qobj.deliverStatus,
"delivery_info": qobj.baseInfo
/* 插入交付单信息*/
async insertInfo(qobj, t) { // 到时候看交付单信息后再确定
const obj = {
delivery_code: qobj.deliverNumber,
delivery_status: qobj.deliverStatus,
delivery_info: qobj.baseInfo,
};
if (qobj.businessMode && qobj.businessMode != 'undefined') {
obj.demand_code = qobj.businessMode;
......@@ -186,7 +181,7 @@ class DeliverybillDao extends Dao {
obj.salesman_name = qobj.salesmanName;
}
if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
obj.salesman_phone = qobj.salesmanPhone
obj.salesman_phone = qobj.salesmanPhone;
}
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
obj.salesman_opcode = qobj.salesmanOpcode;
......@@ -211,7 +206,5 @@ class DeliverybillDao extends Dao {
}
return await this.create(obj, t);
}
}
module.exports = DeliverybillDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class MaterialDao extends Dao {
constructor() {
super(Dao.getModelName(MaterialDao));
}
/*根据交付单编号获取注册材料信息详情*/
/* 根据交付单编号获取注册材料信息详情*/
async findInfoByDeliverNumber(qobj) {
var qcwhere = { "delivery_code": qobj.deliverNumber };
const qcwhere = { delivery_code: qobj.deliverNumber };
return await this.findOne(qcwhere);
}
/* 根据id更新zip信息 */
async updateZipById(qobj, t) {
try{
var whereobj = { "id": qobj.id };
var setobj= {
"is_download":1,
"download_url":qobj.url
try {
const whereobj = { id: qobj.id };
const setobj = {
is_download: 1,
download_url: qobj.url,
};
return await this.updateByWhere(setobj, whereobj, t);
}
catch(error){
console.log("error----------" + error);
} catch (error) {
console.log(`error----------${error}`);
return error;
}
}
/*根据交付单编号更新交材料详情*/
/* 根据交付单编号更新交材料详情*/
async updateInfoByDeliverNumber(qobj, t) {
var whereobj = { "delivery_code": qobj.deliverNumber };
var setobj = {};
const whereobj = { delivery_code: qobj.deliverNumber };
const setobj = {};
if (qobj.companyInfo && qobj.companyInfo != 'undefined') {
setobj.company_info = qobj.companyInfo;
}
......@@ -55,13 +53,13 @@ class MaterialDao extends Dao {
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入注册材料信息*/
async insertInfo(pobj, t) {//公司注册,云上园区注册时的信息
var obj = {
"delivery_code": pobj.deliverNumber
/* 插入注册材料信息*/
async insertInfo(pobj, t) { // 公司注册,云上园区注册时的信息
const obj = {
delivery_code: pobj.deliverNumber,
};
if (pobj.deliverId && pobj.deliverId != 'undefined') {
obj["delivery_id"] = pobj.deliverId;
obj.delivery_id = pobj.deliverId;
}
if (pobj.companyInfo && pobj.companyInfo != 'undefined') {
obj.company_info = pobj.companyInfo;
......@@ -80,7 +78,5 @@ class MaterialDao extends Dao {
}
return await this.create(obj, t);
}
}
module.exports = MaterialDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class SalesmanhisDao extends Dao {
constructor() {
super(Dao.getModelName(SalesmanhisDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"flow_code":qobj.flowCode,
"salesman_info":qobj.salesmanInfo
/* 插入状态信息信息*/
async insertInfo(qobj, t) {
const obj = {
flow_type: qobj.flowType,
flow_id: qobj.flowId,
flow_code: qobj.flowCode,
salesman_info: qobj.salesmanInfo,
};
return await this.create(obj,t);
return await this.create(obj, t);
}
}
module.exports = SalesmanhisDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class SchemeDao extends Dao {
constructor() {
super(Dao.getModelName(SchemeDao));
}
/*根据商机编号获取方案信息详情*/
async findInfoByDemandCode(qobj){
var qcwhere = {"demand_code":qobj.businessMode};
/* 根据商机编号获取方案信息详情*/
async findInfoByDemandCode(qobj) {
const qcwhere = { demand_code: qobj.businessMode };
return await this.findOne(qcwhere);
}
/*根据方案编号更新方案状态及原因*/
async updateStatusByDemandCode(qobj,t){
var setobj = {"scheme_status":qobj.currentStatus};
if (qobj.statusReason && qobj.statusReason != 'undefined'){
setobj["reject_reason"] = qobj.statusReason;
/* 根据方案编号更新方案状态及原因*/
async updateStatusByDemandCode(qobj, t) {
const setobj = { scheme_status: qobj.currentStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.reject_reason = qobj.statusReason;
} else {
setobj.reject_reason = '';
}
else{
setobj["reject_reason"] = "";
}
var whereobj = {"demand_code":qobj.businessMode};
return await this.updateByWhere(setobj,whereobj,t);
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*根据商机编号更新方案详情*/
async updateInfoByDemandCode(qobj,t){
var whereobj = {"demand_code":qobj.businessMode};
var setobj = {"scheme_info":qobj.baseInfo,"scheme_status":qobj.currentStatus};
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){
/* 根据商机编号更新方案详情*/
async updateInfoByDemandCode(qobj, t) {
const whereobj = { demand_code: qobj.businessMode };
const setobj = { scheme_info: qobj.baseInfo, scheme_status: qobj.currentStatus };
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
setobj.scheme_number = qobj.schemeNumber;
}
if (qobj.statusReason && qobj.statusReason != 'undefined'){
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.reject_reason = qobj.statusReason;
} else {
setobj.reject_reason = '';
}
else{
setobj.reject_reason = "";
}
return await this.updateByWhere(setobj,whereobj,t);
return await this.updateByWhere(setobj, whereobj, t);
}
/*根据方案编号更新方案编号*/
async updateSchemeNumberByDemandCode(qobj,t){
var setobj = {"scheme_number":qobj.schemeNumber};
var whereobj = {"demand_code":qobj.businessMode};
return await this.updateByWhere(setobj,whereobj,t);
/* 根据方案编号更新方案编号*/
async updateSchemeNumberByDemandCode(qobj, t) {
const setobj = { scheme_number: qobj.schemeNumber };
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入方案信息*/
async insertInfo(qobj,t){
var obj = {
"demand_code":qobj.businessMode,
"scheme_info":qobj.baseInfo
/* 插入方案信息*/
async insertInfo(qobj, t) {
const obj = {
demand_code: qobj.businessMode,
scheme_info: qobj.baseInfo,
};
if (qobj.currentStatus && qobj.currentStatus != 'undefined'){
obj["scheme_status"] = qobj.currentStatus;
if (qobj.currentStatus && qobj.currentStatus != 'undefined') {
obj.scheme_status = qobj.currentStatus;
}
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){
obj["scheme_number"] = qobj.schemeNumber;
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
obj.scheme_number = qobj.schemeNumber;
}
if (qobj.statusReason && qobj.statusReason != 'undefined'){
obj["reject_reason"] = qobj.statusReason;
if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.reject_reason = qobj.statusReason;
}
if (qobj.memoInfo && qobj.memoInfo != 'undefined'){
obj["remark_info"] = qobj.memoInfo;
if (qobj.memoInfo && qobj.memoInfo != 'undefined') {
obj.remark_info = qobj.memoInfo;
}
if (qobj.businessId && qobj.businessId != 'undefined'){
obj["bizopt_id"] = qobj.businessId;
if (qobj.businessId && qobj.businessId != 'undefined') {
obj.bizopt_id = qobj.businessId;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined'){
obj["facilitator_id"] = qobj.servicerCode;
if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj.facilitator_id = qobj.servicerCode;
}
if (qobj.servicerName && qobj.servicerName != 'undefined'){
obj["facilitator_name"] = qobj.servicerName;
if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj.facilitator_name = qobj.servicerName;
}
if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined'){
obj["salesman_opcode"] = qobj.clerkOpcode;
if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined') {
obj.salesman_opcode = qobj.clerkOpcode;
}
if (qobj.clerkId && qobj.clerkId != 'undefined'){
obj["salesman_id"] = qobj.clerkId;
if (qobj.clerkId && qobj.clerkId != 'undefined') {
obj.salesman_id = qobj.clerkId;
}
if (qobj.clerkName && qobj.clerkName != 'undefined'){
obj["salesman_name"] = qobj.clerkName;
if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.salesman_name = qobj.clerkName;
}
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined'){
obj["salesman_phone"] = qobj.clerkPhone;
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') {
obj.salesman_phone = qobj.clerkPhone;
}
return await this.create(obj,t);
return await this.create(obj, t);
}
}
module.exports = SchemeDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class SettlebillDao extends Dao {
constructor() {
super(Dao.getModelName(SettlebillDao));
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
extraWhere(qobj, qw, qc) { // 根据业务员id获取交付单信息的组装条件
// qc.raw = true;
// 检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
return qw;
}
// 需要添加公司查询条件
qw.facilitator_id = Number(qobj.company_id);
return qw;
}
}
......
const system = require("../../../system");
const Dao = require("../../dao.base");
const system = require('../../../system');
const Dao = require('../../dao.base');
class StatuslogDao extends Dao {
constructor() {
super(Dao.getModelName(StatuslogDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"status_code":qobj.statusCode
/* 插入状态信息信息*/
async insertInfo(qobj, t) {
const obj = {
flow_type: qobj.flowType,
flow_id: qobj.flowId,
status_code: qobj.statusCode,
};
if (qobj.statusReason && qobj.statusReason != 'undefined'){
obj.status_reason = qobj.statusReason;
if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.status_reason = qobj.statusReason;
} else {
obj.status_reason = '';
}
else{
obj.status_reason = "";
}
if (qobj.clerkName && qobj.clerkName != 'undefined'){
if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.salesman_name = qobj.clerkName;
}
if (qobj.clerkId && qobj.clerkId != 'undefined'){
if (qobj.clerkId && qobj.clerkId != 'undefined') {
obj.salesman_id = qobj.clerkId;
}
return await this.create(obj,t);
return await this.create(obj, t);
}
}
module.exports = StatuslogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class AppDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class AppDao extends Dao {
constructor() {
super(Dao.getModelName(AppDao));
}
extraWhere(obj,w,qc,linkAttrs){
if(obj.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("my_app")>0){//说明是租户查询自己创建的应用
w["creator_id"]=obj.userid;
}
}
if(linkAttrs.length>0){
var search=obj.search;
var lnkKey=linkAttrs[0];
var strq="$"+lnkKey.replace("~",".")+"$";
w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"};
}
return w;
extraWhere(obj, w, qc, linkAttrs) {
if (obj.bizpath && obj.bizpath != '') {
if (obj.bizpath.indexOf('my_app') > 0) { // 说明是租户查询自己创建的应用
w.creator_id = obj.userid;
}
}
if (linkAttrs.length > 0) {
const { search } = obj;
const lnkKey = linkAttrs[0];
const strq = `$${lnkKey.replace('~', '.')}$`;
w[strq] = { [this.db.Op.like]: `%${search[lnkKey]}%` };
}
return w;
}
}
module.exports=AppDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
module.exports = AppDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const fs=require("fs");
const settings=require("../../../../config/settings");
class CacheManager{
constructor(){
//await this.buildCacheMap();
const fs = require('fs');
const settings = require('../../../../config/settings');
class CacheManager {
constructor() {
// await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap(){
var self=this;
self.doc={};
var cachePath=settings.basepath+"/app/base/db/cache/";
const files=fs.readdirSync(cachePath);
if(files){
files.forEach(function(r){
var classObj=require(cachePath+"/"+r);
self[classObj.name]=new classObj();
var refTmp=self[classObj.name];
if(refTmp.prefix){
self.doc[refTmp.prefix]=refTmp.desc;
}
else{
console.log("请在"+classObj.name+"缓存中定义prefix");
}
});
}
buildCacheMap() {
const self = this;
self.doc = {};
const cachePath = `${settings.basepath}/app/base/db/cache/`;
const files = fs.readdirSync(cachePath);
if (files) {
files.forEach((r) => {
const classObj = require(`${cachePath}/${r}`);
self[classObj.name] = new classObj();
const refTmp = self[classObj.name];
if (refTmp.prefix) {
self.doc[refTmp.prefix] = refTmp.desc;
} else {
console.log(`请在${classObj.name}缓存中定义prefix`);
}
});
}
}
}
module.exports=CacheManager;
module.exports = CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
......
const Sequelize = require('sequelize');
const settings = require("../../../../config/settings")
const fs = require("fs")
const path = require("path");
var glob = require("glob");
const settings = require('../../../../config/settings');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
class DbFactory {
constructor() {
const dbConfig = settings.database();
this.db = new Sequelize(dbConfig.dbname,
this.db = new Sequelize(
dbConfig.dbname,
dbConfig.user,
dbConfig.password,
dbConfig.config);
dbConfig.config,
);
this.db.Sequelize = Sequelize;
this.db.Op = Sequelize.Op;
this.initModels();
this.initRelations();
}
async initModels() {
var self = this;
var modelpath = path.normalize(path.join(__dirname, '../..')) + "/models/";
var models = glob.sync(modelpath + "/**/*.js");
const self = this;
const modelpath = `${path.normalize(path.join(__dirname, '../..'))}/models/`;
const models = glob.sync(`${modelpath}/**/*.js`);
console.log(models.length);
models.forEach(function (m) {
models.forEach((m) => {
console.log(m);
self.db.import(m);
});
console.log("init models....");
console.log('init models....');
}
async initRelations() {
this.db.models.dataauth.belongsTo(this.db.models.user, { constraints: false, });
/*建立用户和角色之间的关系*/
this.db.models.user.belongsToMany(this.db.models.role, { as: "Roles", through: 'p_userrole', constraints: false, });
this.db.models.role.belongsToMany(this.db.models.user, { as: "Users", through: 'p_userrole', constraints: false, });
/*组织机构自引用*/
//this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
//this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
this.db.models.dataauth.belongsTo(this.db.models.user, { constraints: false });
/* 建立用户和角色之间的关系*/
this.db.models.user.belongsToMany(this.db.models.role, { as: 'Roles', through: 'p_userrole', constraints: false });
this.db.models.role.belongsToMany(this.db.models.user, { as: 'Users', through: 'p_userrole', constraints: false });
/* 组织机构自引用*/
// this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
// this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
//组织机构和角色是多对多关系,建立兼职岗位,给岗位赋予多个角色,从而同步修改用户的角色
//通过岗位接口去修改用户的角色
//this.db.models.role.belongsToMany(this.db.models.org,{through: this.db.models.orgrole,constraints: false,});
//this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,});
// 组织机构和角色是多对多关系,建立兼职岗位,给岗位赋予多个角色,从而同步修改用户的角色
// 通过岗位接口去修改用户的角色
// this.db.models.role.belongsToMany(this.db.models.org,{through: this.db.models.orgrole,constraints: false,});
// this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,});
//组织机构和用户是1对多,
// 组织机构和用户是1对多,
// this.db.models.user.belongsTo(this.db.models.org,{constraints: false,});
// this.db.models.org.hasMany(this.db.models.user,{constraints: false,});
this.db.models.user.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.user.belongsTo(this.db.models.app, { constraints: false });
this.db.models.role.belongsTo(this.db.models.app, { constraints: false });
this.db.models.auth.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.role, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.app, { constraints: false });
this.db.models.auth.belongsTo(this.db.models.company, { constraints: false });
this.db.models.auth.belongsTo(this.db.models.role, { constraints: false });
this.db.models.app.belongsTo(this.db.models.user, { as: "creator", constraints: false, });
this.db.models.app.belongsTo(this.db.models.user, { as: 'creator', constraints: false });
this.db.models.user.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.user.belongsTo(this.db.models.company, { constraints: false });
this.db.models.role.belongsTo(this.db.models.company, { constraints: false });
// this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.route.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.plugin.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.route.belongsTo(this.db.models.app, { constraints: false });
this.db.models.plugin.belongsTo(this.db.models.app, { constraints: false });
// 商机表 1:1 方案表
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, });
this.db.models.bizopt.hasOne(this.db.models.scheme, { constraints: false, });
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false });
this.db.models.bizopt.hasOne(this.db.models.scheme, { constraints: false });
//交付单关联结算单deliverybill
this.db.models.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false, });
this.db.models.settlebill.hasMany(this.db.models.deliverybill,{as:"dbs",constraints: false,});
// 交付单关联结算单deliverybill
this.db.models.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false });
this.db.models.settlebill.hasMany(this.db.models.deliverybill, { as: 'dbs', constraints: false });
}
//async getCon(){,用于使用替换table模型内字段数据使用
// async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
var that = this;
const that = this;
// await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.');
// }).catch(err => {
// console.error('Unable to connect to the database:', err);
// throw err;
// });
//同步模型
if (settings.env == "dev") {
// 同步模型
if (settings.env == 'dev') {
//console.log(pa);
// console.log(pa);
// pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true}));
// });
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgHistoryDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class MsgHistoryDao extends Dao {
constructor() {
super(Dao.getModelName(MsgHistoryDao));
}
extraWhere(obj,w){
if(obj.ukstr && obj.ukstr!=""){
extraWhere(obj, w) {
if (obj.ukstr && obj.ukstr != '') {
// w={[this.db.Op.or]:[
// {[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
// {[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
// ]
// };
w[this.db.Op.or]=[
{[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
{[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
];
}
return w;
w[this.db.Op.or] = [
{ [this.db.Op.and]: [{ sender: obj.ukstr }, { target: obj.extra }] },
{ [this.db.Op.and]: [{ sender: obj.extra }, { target: obj.ukstr }] },
];
}
return w;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
orderBy() {
// return {"key":"include","value":{model:this.db.models.app}};
return [['id', 'DESC']];
}
}
module.exports=MsgHistoryDao;
module.exports = MsgHistoryDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgNoticeDao extends Dao{
constructor(){
const system = require('../../../system');
const Dao = require('../../dao.base');
class MsgNoticeDao extends Dao {
constructor() {
super(Dao.getModelName(MsgNoticeDao));
}
async saveNotice(msg, t) {
var noticeFrom = await super.findOne({fromId : msg.senderId, toId : msg.targetId});
if(noticeFrom) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
let noticeFrom = await super.findOne({ fromId: msg.senderId, toId: msg.targetId });
if (noticeFrom) {
var set = { lastMsgId: msg.id };
if (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 {
noticeFrom = {
fromuser: msg.sender,
fromId:msg.senderId,
fromId: msg.senderId,
touser: msg.target,
toId:msg.targetId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
toId: msg.targetId,
isAccepted: true,
lastMsgId: msg.id,
businessLicense_id: msg.businessLicense_id || 0,
};
await super.create(noticeFrom, t);
}
var noticeTo = await super.findOne({fromId : msg.targetId, toId : msg.senderId});
if(noticeTo) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
let noticeTo = await super.findOne({ fromId: msg.targetId, toId: msg.senderId });
if (noticeTo) {
var set = { lastMsgId: msg.id };
if (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 {
noticeTo = {
fromuser: msg.target,
fromId:msg.targetId,
touser: msg.sender,
toId:msg.senderId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
fromuser: msg.target,
fromId: msg.targetId,
touser: msg.sender,
toId: msg.senderId,
isAccepted: true,
lastMsgId: msg.id,
businessLicense_id: msg.businessLicense_id || 0,
};
await super.create(noticeTo, t);
}
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
orderBy() {
// return {"key":"include","value":{model:this.db.models.app}};
return [['id', 'DESC']];
}
}
module.exports=MsgNoticeDao;
module.exports = MsgNoticeDao;
const system = require("../system");
const settings = require("../../config/settings.js");
const reclient = system.getObject("util.redisClient");
const md5 = require("MD5");
var dbf = system.getObject("db.common.connection");
var db = dbf.getCon();
const system = require('../system');
const settings = require('../../config/settings.js');
const reclient = system.getObject('util.redisClient');
const md5 = require('MD5');
const dbf = system.getObject('db.common.connection');
const db = dbf.getCon();
db.sync({ force: true }).then(async () => {
console.log("init 完毕");
console.log('init 完毕');
});
const fs=require("fs");
const path=require("path");
const appPath=path.normalize(__dirname+"/app");
const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={
config:require(appPath+"/"+"platform.js").config
}
module.exports=appJsons;
const fs = require('fs');
const path = require('path');
const appPath = path.normalize(`${__dirname}/app`);
const bizsPath = path.normalize(`${__dirname}/bizs`);
const appJsons = {
config: require(`${appPath}/` + 'platform.js').config,
};
module.exports = appJsons;
module.exports = (db, DataTypes) => {
return db.define("auth", {
rolecode: DataTypes.STRING,
bizcode: DataTypes.STRING,
codepath: DataTypes.STRING,
authstrs: DataTypes.STRING
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_auths',
validate: {
}
});
}
module.exports = (db, DataTypes) => db.define('auth', {
rolecode: DataTypes.STRING,
bizcode: DataTypes.STRING,
codepath: DataTypes.STRING,
authstrs: DataTypes.STRING,
}, {
paranoid: true, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_auths',
validate: {
},
});
module.exports = (db, DataTypes) => {
return db.define("dataauth", {
modelname: DataTypes.STRING,
auths: DataTypes.STRING,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_dataauths',
validate: {
}
});
}
module.exports = (db, DataTypes) => db.define('dataauth', {
modelname: DataTypes.STRING,
auths: DataTypes.STRING,
}, {
paranoid: true, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_dataauths',
validate: {
},
});
const system=require("../../../system");
const settings=require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("org", {
code: {
type:DataTypes.STRING(64),
allowNull: false,
},
name: {
type:DataTypes.STRING(64),
allowNull: false,
},
isLeaf:{
type:DataTypes.BOOLEAN,
defaultValue: true
},
orgpath: {
type:DataTypes.STRING,
allowNull: false,
},
nodeType: {//默认为组织
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(appconfig.pdict.node_type),
defaultValue:'org'
},
isPosition:{//是否是岗位
type:DataTypes.BOOLEAN,
defaultValue: false
},
isMain:{//是否是主岗
type:DataTypes.BOOLEAN,
defaultValue: false
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_org',
validate: {
}
});
}
\ No newline at end of file
const system = require('../../../system');
const settings = require('../../../../config/settings');
const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => db.define('org', {
code: {
type: DataTypes.STRING(64),
allowNull: false,
},
name: {
type: DataTypes.STRING(64),
allowNull: false,
},
isLeaf: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
orgpath: {
type: DataTypes.STRING,
allowNull: false,
},
nodeType: { // 默认为组织
type: DataTypes.ENUM,
allowNull: false,
values: Object.keys(appconfig.pdict.node_type),
defaultValue: 'org',
},
isPosition: { // 是否是岗位
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isMain: { // 是否是主岗
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: true, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_org',
validate: {
},
});
module.exports = (db, DataTypes) => {
return db.define("orgrole", {
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_orgrole',
validate: {
},
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => db.define('orgrole', {
}, {
paranoid: false, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_orgrole',
validate: {
},
});
module.exports = (db, DataTypes) => {
return db.define("role", {
name: DataTypes.STRING,
code: DataTypes.STRING,
description: DataTypes.STRING,
isSystem: {//是否系统数据,0否,1是
type: DataTypes.BOOLEAN,
defaultValue: false,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_role',
validate: {
}
});
}
module.exports = (db, DataTypes) => db.define('role', {
name: DataTypes.STRING,
code: DataTypes.STRING,
description: DataTypes.STRING,
isSystem: { // 是否系统数据,0否,1是
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: true, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_role',
validate: {
},
});
const system=require("../../../system");
const settings=require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("user", {
userName: {
type:DataTypes.STRING,
allowNull: false,
},
password: {
type:DataTypes.STRING,
allowNull: false,
},
nickName: {
type:DataTypes.STRING,
allowNull: true,
},
sex: {
type:DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.sex),
},
mobile:DataTypes.STRING,
mail: {
type:DataTypes.STRING,
allowNull: true,
},
headUrl: DataTypes.STRING,
isAdmin:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
isSuper:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
isSystem:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
center_id:DataTypes.STRING,
jwtkey:DataTypes.STRING,
jwtsecret:DataTypes.STRING,
isEnabled:{
type:DataTypes.BOOLEAN,
defaultValue: true
},
opath:DataTypes.STRING,//作业务时,需要在业务表冗余当前处理人的opath
ptags:DataTypes.STRING,//权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_user',
validate: {
const system = require('../../../system');
const settings = require('../../../../config/settings');
const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => db.define('user', {
userName: {
type: DataTypes.STRING,
allowNull: false,
},
password: {
type: DataTypes.STRING,
allowNull: false,
},
nickName: {
type: DataTypes.STRING,
allowNull: true,
},
sex: {
type: DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.sex),
},
mobile: DataTypes.STRING,
mail: {
type: DataTypes.STRING,
allowNull: true,
},
headUrl: DataTypes.STRING,
isAdmin: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isSuper: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isSystem: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
center_id: DataTypes.STRING,
jwtkey: DataTypes.STRING,
jwtsecret: DataTypes.STRING,
isEnabled: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
opath: DataTypes.STRING, // 作业务时,需要在业务表冗余当前处理人的opath
ptags: DataTypes.STRING, // 权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据
}, {
paranoid: true, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_user',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
],
});
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("app", {
appkey:{
type: DataTypes.STRING,
allowNull: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
domainName: DataTypes.STRING,//域名
backend:DataTypes.STRING,//域名
homePage: DataTypes.STRING,//首页
functionJSON: DataTypes.TEXT,//功能清单地址--前端通过loadJson下载数据
docUrl: DataTypes.STRING,//前端路由配置文件
configUrl: DataTypes.STRING,//基础信息配置信息地址
logoUrl: DataTypes.STRING,//应用Logo
bkimageUrl: DataTypes.STRING,//应用背景图
showimgUrl: DataTypes.STRING,//应用显示图标
detailimgUrl: DataTypes.STRING,//应用详情介绍地址
opCacheUrl: DataTypes.STRING,//操作缓存地址
description: DataTypes.STRING,//应用描述
isSystem: {
type: DataTypes.BOOLEAN,
defaultValue: false
},//是否启用
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否启用
isPublish: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否对外
appType: {
type: DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.app_type),
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_app',
validate: {
const system = require('../../../system');
const settings = require('../../../../config/settings');
const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => db.define('app', {
appkey: {
type: DataTypes.STRING,
allowNull: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
}, // 和user的from相同,在注册user时,去创建
domainName: DataTypes.STRING, // 域名
backend: DataTypes.STRING, // 域名
homePage: DataTypes.STRING, // 首页
functionJSON: DataTypes.TEXT, // 功能清单地址--前端通过loadJson下载数据
docUrl: DataTypes.STRING, // 前端路由配置文件
configUrl: DataTypes.STRING, // 基础信息配置信息地址
logoUrl: DataTypes.STRING, // 应用Logo
bkimageUrl: DataTypes.STRING, // 应用背景图
showimgUrl: DataTypes.STRING, // 应用显示图标
detailimgUrl: DataTypes.STRING, // 应用详情介绍地址
opCacheUrl: DataTypes.STRING, // 操作缓存地址
description: DataTypes.STRING, // 应用描述
isSystem: {
type: DataTypes.BOOLEAN,
defaultValue: false,
}, // 是否启用
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
}, // 是否启用
isPublish: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
}, // 是否对外
appType: {
type: DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.app_type),
},
}, {
paranoid: false, // 假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'p_app',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// 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