Commit b669e8db by Sxy

fix: 代码规范

parent 577fbddf
......@@ -42,9 +42,7 @@ class OSSAPI extends APIBase {
}
async downfile(srckey) {
const oss = System.getObject('util.ossClient');
const downfile = await oss.downfile(srckey).then(() => {
return `/tmp/${srckey}`;
});
const downfile = await oss.downfile(srckey).then(() => `/tmp/${srckey}`);
return downfile;
}
}
......
......@@ -30,7 +30,7 @@ class MaterialCtl extends CtlBase {
profitableWay,
specialApproval,
serviceProjectEdi,
serviceProjectIcp
serviceProjectIcp,
} = implementationPlanInfo;
// 1. id ,type
......@@ -122,20 +122,22 @@ class MaterialCtl extends CtlBase {
};
// 专项审批项目 ICP
if (type === 'ICP') {
implementationPlanData.files.push(
...specialApproval.filter(item => (!!(item.file && item.file.url))).map(item => ({
file: item.file,
title: `专项审批项-${item.title}`,
})));
implementationPlanData.files.push(...specialApproval.filter(item => (!!(
item.file
&& item.file.url))).map(item => ({
file: item.file,
title: `专项审批项-${item.title}`,
})));
}
implementationPlanData.files.push(...otherMaterialsInfo.filter(item => item.title === '域名证书'));
if (type === 'EDI') {
implementationPlanData.files.push(
...serviceProjectEdi.filter(item => (!!(item.file && item.file.url))).map(item => ({
title: item.title,
file: item.file,
})));
implementationPlanData.files.push(...serviceProjectEdi.filter(item => (!!(
item.file
&& item.file.url))).map(item => ({
title: item.title,
file: item.file,
})));
}
// 4. 增值电信申请表
......
......@@ -49,10 +49,10 @@ class Dao {
if (t != null && t != 'undefined') {
whereParam.transaction = t;
const result = await this.model.destroy(whereParam);
return result
return result;
}
const result = await this.model.destroy(whereParam);
return result
return result;
}
async delete(qobj, t) {
let en = null;
......
......@@ -40,10 +40,9 @@ class RoleDao extends Dao {
if (t) {
const role = await this.model.create(u2, { transaction: t });
return role;
} else {
const role = await this.model.create(u2);
return role;
}
const role = await this.model.create(u2);
return role;
}
}
module.exports = RoleDao;
......@@ -9,11 +9,11 @@ class UserDao extends Dao {
return this.model.findOne({
where: { id: userid },
include: [{ model: self.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'] },
{
model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] },
],
},
{
model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] },
],
},
],
});
}
......@@ -22,12 +22,12 @@ class UserDao extends Dao {
const tUser = await this.model.findOne({
where: { userName: username, app_id: app.id },
include: [{ model: this.db.models.app, raw: true },
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
],
},
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
],
},
],
}, { transaction: t });
// if(tUser!=null){
......@@ -41,12 +41,12 @@ class UserDao extends Dao {
let tUser = await this.model.findOne({
where: { openId: popenid },
include: [{ model: this.db.models.app, raw: true },
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
],
},
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
],
},
],
}, { transaction: t });
if (tUser != null) {
......@@ -123,7 +123,7 @@ class UserDao extends Dao {
// 修改用户(user表)公司的唯一码
async putUserCompanyOnlyCode(userId, companyOnlyCode, result) {
const customerObj = { companyOnlyCode: companyOnlyCode };
const customerObj = { companyOnlyCode };
const putSqlWhere = { where: { id: userId } };
this.updateByWhere(customerObj, putSqlWhere);
return result;
......
......@@ -40,7 +40,7 @@ class DeliverDao extends Dao {
case '/deliveryManagement/wait':
qc.where.delivery_status = qc.where.delivery_status || {
$in: [system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING,
system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING, system.SERVERSESTATUS.POSTING,
system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING, system.SERVERSESTATUS.POSTING,
],
};
break;
......
......@@ -8,7 +8,7 @@ class MsgNoticeDao extends Dao {
async saveNotice(msg, t) {
let noticeFrom = await super.findOne({ fromId: msg.senderId, toId: msg.targetId });
if (noticeFrom) {
let set = { lastMsgId: msg.id };
const set = { lastMsgId: msg.id };
if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
......@@ -28,7 +28,7 @@ class MsgNoticeDao extends Dao {
let noticeTo = await super.findOne({ fromId: msg.targetId, toId: msg.senderId });
if (noticeTo) {
let set = { lastMsgId: msg.id };
const set = { lastMsgId: msg.id };
if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
......
......@@ -11,7 +11,7 @@ class AuthService extends ServiceBase {
// var newattrs=rolecodestr.split(",");
const aths = await this.dao.model.findAll({
attributes: ['bizcode', 'authstrs', 'codepath'],
where: { role_id: { [this.db.Op.in]: roleids }, app_id: appid, company_id: comid }
where: { role_id: { [this.db.Op.in]: roleids }, app_id: appid, company_id: comid },
});
return aths;
}
......@@ -22,7 +22,7 @@ class AuthService extends ServiceBase {
console.log(auths);
return self.db.transaction(async (t) => {
for (let i = 0; i < auths.length; i++) {
let tmpAuth = auths[i];
const tmpAuth = auths[i];
tmpAuth.app_id = appid;
tmpAuth.company_id = cmid;
const objrtn = await self.dao.model.findOrCreate({
......@@ -38,18 +38,18 @@ class AuthService extends ServiceBase {
where:
{
role_id: tmpAuth.role_id,
bizcode: tmpAuth.bizcode
bizcode: tmpAuth.bizcode,
},
transaction: t
transaction: t,
});
}
}
const aths = await self.dao.model.findAll({
where: {
role_id: tmpAuth.role_id,
app_id: tmpAuth.app_id
app_id: tmpAuth.app_id,
},
transaction: t
transaction: t,
});
return aths;
});
......
......@@ -44,7 +44,7 @@ class OrgService extends ServiceBase {
const usersupdate = await self.db.models.user.findAll({ where: { org_id: orgupdate.id } });
// 如果节点名称或岗位性质发生变化
// if(p.name!=orgupdate.name || p.isMain!=orgupdate.isMain){
for (let ud of usersupdate) {
for (const ud of usersupdate) {
ud.opath = p.orgpath;
const n = p.orgpath.lastIndexOf('/');
ud.ppath = p.isMain ? p.orgpath.substring(0, n) : p.orgpath;
......
......@@ -64,9 +64,9 @@ class UserService extends ServiceBase {
where: {
id: { [self.db.Op.in]: rolecodes },
app_id: roleappid,
company_id: p.company_id
company_id: p.company_id,
},
transaction: t
transaction: t,
});
if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t });
......@@ -192,7 +192,7 @@ class UserService extends ServiceBase {
nickName: mobile,
rolecodes: p.rolecodes,
company_id: p.company_id,
app_id: p.app_id
app_id: p.app_id,
});
const token = await this.cmakejwt(regrtn.user.jwtkey, regrtn.user.jwtsecret, null);
// rtn.token = token;
......
......@@ -18,8 +18,8 @@ class SchemeService extends ServiceBase {
throw new Error('查不到该商机');
}
if ([system.BUSSTATUS.CLOSED,
system.BUSSTATUS.SUCCESS,
system.BUSSTATUS.WAITINGCONFIRM].includes(bizData.business_status)) {
system.BUSSTATUS.SUCCESS,
system.BUSSTATUS.WAITINGCONFIRM].includes(bizData.business_status)) {
throw new Error('此商机状态下不可操作');
}
const schemeData = await this.dao.findOne({
......@@ -27,7 +27,7 @@ class SchemeService extends ServiceBase {
});
if (schemeData
&& [system.SCHEMESTATUS.WAITINGCONFIRM,
system.SCHEMESTATUS.CLOSED].includes(schemeData.scheme_status)) {
system.SCHEMESTATUS.CLOSED].includes(schemeData.scheme_status)) {
throw new Error('此方案状态下不可操作');
}
......@@ -35,7 +35,7 @@ class SchemeService extends ServiceBase {
data.scheme_number = await pushTx.pushScheme(bizData, schemeData
? {
...data,
scheme_number: schemeData.scheme_number
scheme_number: schemeData.scheme_number,
} : data);
......
......@@ -25,12 +25,12 @@ class CompanyService extends ServiceBase {
where:
{
id: {
[self.db.Op.in]: roleids
[self.db.Op.in]: roleids,
},
app_id: p.app_id,
company_id: p.company_id
company_id: p.company_id,
},
transaction: t
transaction: t,
});
for (const u of us) {
await u.setRoles(rs, { transaction: t });
......
......@@ -22,8 +22,9 @@ class RouteService extends ServiceBase {
name: routedata.name,
hosts: routedata.hosts,
paths: routedata.paths,
strip_path: routedata.isstrip
});
strip_path: routedata.isstrip,
},
);
routedata.center_id = routeobj.id;
rtn = await self.dao.create(routedata, t);
} catch (e) {
......
......@@ -188,8 +188,8 @@ class DeliverService extends ServiceBase {
}
if (
![system.SERVERSESTATUS.DISPOSEING,
system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)
system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)
) {
throw new Error('该交付单状态下不可提交');
}
......@@ -352,8 +352,8 @@ class DeliverService extends ServiceBase {
}
if (
![system.SERVERSESTATUS.DISPOSEING,
system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(result.delivery_status)
system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(result.delivery_status)
) {
throw new Error('该状态下不可填写邮寄信息');
}
......
......@@ -5,260 +5,260 @@ const request = require('request');
const cryptoJS = require('crypto-js');
class System {
static declare(ns) {
const ar = ns.split('.');
let root = System;
for (let i = 0, len = ar.length; i < len; ++i) {
const n = ar[i];
if (!root[n]) {
root[n] = {};
root = root[n];
} else {
root = root[n];
}
}
}
static async delReq(url, qdata) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.del({
url,
qs: qdata,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
const data = JSON.parse(body);
rtn.data = data;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async getReq(url, qdata) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.get({
url,
json: true,
qs: qdata,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
rtn.data = body;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async postJsonTypeReq(url, data, md = 'POST') {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request({
url,
method: md,
json: true,
headers: {
'Content-type': 'application/json',
// 'Authorization': 'Basic YWRtaW5lczphZG1pbkdTQmVzLg=='
},
body: data,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
rtn.data = body;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async post3wFormTypeReq(url, data) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.post({
url,
form: data,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
const data = JSON.parse(body);
rtn.data = data;
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async postMpFormTypeReq(url, formdata) {
const promise = new Promise(((resv, rej) => {
request.post({
url,
formData: formdata,
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
resv(body);
} else {
rej(error);
}
});
}));
return promise;
}
static declare(ns) {
const ar = ns.split('.');
let root = System;
for (let i = 0, len = ar.length; i < len; ++i) {
const n = ar[i];
if (!root[n]) {
root[n] = {};
root = root[n];
} else {
root = root[n];
}
}
}
static async delReq(url, qdata) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.del({
url,
qs: qdata,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
const data = JSON.parse(body);
rtn.data = data;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async getReq(url, qdata) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.get({
url,
json: true,
qs: qdata,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
rtn.data = body;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async postJsonTypeReq(url, data, md = 'POST') {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request({
url,
method: md,
json: true,
headers: {
'Content-type': 'application/json',
// 'Authorization': 'Basic YWRtaW5lczphZG1pbkdTQmVzLg=='
},
body: data,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
if (body) {
rtn.data = body;
} else {
rtn.data = null;
}
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async post3wFormTypeReq(url, data) {
const rtn = {};
const promise = new Promise(((resv, rej) => {
request.post({
url,
form: data,
}, (error, response, body) => {
rtn.statusCode = response.statusCode;
if (!error) {
const data = JSON.parse(body);
rtn.data = data;
resv(rtn);
} else {
rej(error);
}
});
}));
return promise;
}
static async postMpFormTypeReq(url, formdata) {
const promise = new Promise(((resv, rej) => {
request.post({
url,
formData: formdata,
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
resv(body);
} else {
rej(error);
}
});
}));
return promise;
}
/**
/**
* 请求返回成功
* @param {*} data 操作成功返回的数据,有值为成功,无值为失败
* @param {*} okmsg 操作成功的描述
* @param {*} req 请求头信息
*/
static getResult(data, opmsg = '操作成功', req) {
return {
status: !data ? -1 : 0,
msg: opmsg,
data,
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : 'empty',
};
}
/**
static getResult(data, opmsg = '操作成功', req) {
return {
status: !data ? -1 : 0,
msg: opmsg,
data,
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : 'empty',
};
}
/**
* 请求返回成功
* @param {*} data 操作成功返回的数据
* @param {*} okmsg 操作成功的描述
*/
static getResultSuccess(data, okmsg = 'success') {
return {
status: 0,
msg: okmsg,
data,
};
}
/**
static getResultSuccess(data, okmsg = 'success') {
return {
status: 0,
msg: okmsg,
data,
};
}
/**
* 请求返回失败
* @param {*} status 操作失败状态,默认为-1
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static getResultFail(status = -1, errmsg = 'fail', data = null) {
return {
status,
msg: errmsg,
data,
};
}
/**
static getResultFail(status = -1, errmsg = 'fail', data = null) {
return {
status,
msg: errmsg,
data,
};
}
/**
* 请求处理异常
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static getResultError(errmsg = 'fail', data = null) {
return {
status: -200,
msg: errmsg,
data,
};
}
static register(key, ClassObj, groupName, filename) {
if (System.objTable[key] != null) {
throw new Error('相同key的对象已经存在');
} else {
let obj;
if (ClassObj.name === 'ServiceBase') {
obj = new ClassObj(groupName, filename.replace('Sve', 'Dao'));
} else {
obj = new ClassObj(groupName, filename);
}
System.objTable[key] = obj;
}
static getResultError(errmsg = 'fail', data = null) {
return {
status: -200,
msg: errmsg,
data,
};
}
static register(key, ClassObj, groupName, filename) {
if (System.objTable[key] != null) {
throw new Error('相同key的对象已经存在');
} else {
let obj;
if (ClassObj.name === 'ServiceBase') {
obj = new ClassObj(groupName, filename.replace('Sve', 'Dao'));
} else {
obj = new ClassObj(groupName, filename);
}
System.objTable[key] = obj;
}
return System.objTable[key];
}
static getObject(objpath) {
const pathArray = objpath.split('.');
const packageName = pathArray[0];
const groupName = pathArray[1];
let filename = pathArray[2];
let classpath = '';
if (filename) {
classpath = `${objsettings[packageName]}/${groupName}`;
} else {
classpath = objsettings[packageName];
filename = groupName;
}
return System.objTable[key];
}
static getObject(objpath) {
const pathArray = objpath.split('.');
const packageName = pathArray[0];
const groupName = pathArray[1];
let filename = pathArray[2];
let classpath = '';
if (filename) {
classpath = `${objsettings[packageName]}/${groupName}`;
} else {
classpath = objsettings[packageName];
filename = groupName;
}
const objabspath = `${classpath}/${filename}.js`;
const objabspath = `${classpath}/${filename}.js`;
// 判断文件的存在性
// 如果不存在,需要查看packageName
// 如果packageName=web.service,dao
// 判断文件的存在性
// 如果不存在,需要查看packageName
// 如果packageName=web.service,dao
if (System.objTable[objabspath] != null) {
return System.objTable[objabspath];
}
let ClassObj = null;
try {
ClassObj = require(objabspath);
} catch (e) {
// console.log(e)
if (System.objTable[objabspath] != null) {
return System.objTable[objabspath];
}
let ClassObj = null;
try {
ClassObj = require(objabspath);
} catch (e) {
// console.log(e)
const fname = objsettings[`${packageName}base`];
ClassObj = require(fname);
}
if (ClassObj.name == 'Dao') {
const modelname = filename.substring(0, filename.lastIndexOf('Dao'));
return System.register(objabspath, ClassObj, modelname);
}
if (ClassObj.name.indexOf('Ctl') >= 0) {
console.log(ClassObj.name);
}
return System.register(objabspath, ClassObj, groupName, filename);
}
const fname = objsettings[`${packageName}base`];
ClassObj = require(fname);
}
if (ClassObj.name == 'Dao') {
const modelname = filename.substring(0, filename.lastIndexOf('Dao'));
return System.register(objabspath, ClassObj, modelname);
}
if (ClassObj.name.indexOf('Ctl') >= 0) {
console.log(ClassObj.name);
}
return System.register(objabspath, ClassObj, groupName, filename);
}
static getSysConfig() {
const configPath = `${settings.basepath}/app/base/db/metadata/index.js`;
// if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config");
// delete require.cache[configPath];
// }
delete require.cache[configPath];
const configValue = require(configPath);
return configValue.config;
}
static getClientIp(req) {
const ip = req.headers['x-forwarded-for']
static getSysConfig() {
const configPath = `${settings.basepath}/app/base/db/metadata/index.js`;
// if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config");
// delete require.cache[configPath];
// }
delete require.cache[configPath];
const configValue = require(configPath);
return configValue.config;
}
static getClientIp(req) {
const ip = req.headers['x-forwarded-for']
|| req.ip
|| req.connection.remoteAddress
|| req.socket.remoteAddress
|| (req.connection.socket && req.connection.socket.remoteAddress) || '';
const x = ip.match(/(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/);
if (x) {
return x[0];
}
return 'localhost';
}
const x = ip.match(/(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/);
if (x) {
return x[0];
}
return 'localhost';
}
/**
/**
* 记录日志信息
* @param {*} opTitle 操作的标题
* @param {*} params 参数
......@@ -266,85 +266,85 @@ class System {
* @param {*} resultInfo 返回结果
* @param {*} errorInfo 错误信息
*/
static execLogs(opTitle, params, identifyCode, resultInfo, errorInfo) {
const reqUrl = settings.logUrl();
let isLogData = true;
if (params.method && (params.method.indexOf('find') >= 0 || params.method.indexOf('get') >= 0)) {
isLogData = false;
}
const param = {
actionType: 'produceLogsData', // Y 功能名称
actionBody: {
opTitle: opTitle || '', // N 操作的业务标题
identifyCode: identifyCode || 'brg-center-manage', // Y 操作的业务标识
indexName: settings.logindex, // Y es索引值,同一个项目用一个值
messageBody: params, // 日志的描述信息
resultInfo: isLogData ? resultInfo : { status: resultInfo.status }, // 返回信息
errorInfo, // 错误信息
requestId: resultInfo.requestId || '',
},
};
console.log(JSON.stringify(param));
const P = new Promise((resv, rej) => {
this.postJsonTypeReq(reqUrl, param).then((res) => {
if (res.statusCode == 200) {
resv(res.data);
} else {
rej(null);
}
});
});
return P;
}
static execLogs(opTitle, params, identifyCode, resultInfo, errorInfo) {
const reqUrl = settings.logUrl();
let isLogData = true;
if (params.method && (params.method.indexOf('find') >= 0 || params.method.indexOf('get') >= 0)) {
isLogData = false;
}
const param = {
actionType: 'produceLogsData', // Y 功能名称
actionBody: {
opTitle: opTitle || '', // N 操作的业务标题
identifyCode: identifyCode || 'brg-center-manage', // Y 操作的业务标识
indexName: settings.logindex, // Y es索引值,同一个项目用一个值
messageBody: params, // 日志的描述信息
resultInfo: isLogData ? resultInfo : { status: resultInfo.status }, // 返回信息
errorInfo, // 错误信息
requestId: resultInfo.requestId || '',
},
};
console.log(JSON.stringify(param));
const P = new Promise((resv, rej) => {
this.postJsonTypeReq(reqUrl, param).then((res) => {
if (res.statusCode == 200) {
resv(res.data);
} else {
rej(null);
}
});
});
return P;
}
/**
/**
* 加密信息
* @param {*} opStr
*/
static encryptStr(opStr) {
if (!opStr) {
return opStr;
}
const keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
const ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
const cipherStr = cryptoJS.TripleDES.encrypt(opStr, keyHex, { iv: ivHex }).toString();
return cipherStr;
}
/**
static encryptStr(opStr) {
if (!opStr) {
return opStr;
}
const keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
const ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
const cipherStr = cryptoJS.TripleDES.encrypt(opStr, keyHex, { iv: ivHex }).toString();
return cipherStr;
}
/**
* 解密信息
* @param {*} opStr
*/
static decryptStr(opStr) {
if (!opStr) {
return opStr;
}
try {
const keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
const ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
const bytes = cryptoJS.TripleDES.decrypt(opStr, keyHex, {
iv: ivHex,
});
const plaintext = bytes.toString(cryptoJS.enc.Utf8);
return plaintext || opStr;
} catch (err) {
return opStr;
}
}
static decryptStr(opStr) {
if (!opStr) {
return opStr;
}
try {
const keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
const ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
const bytes = cryptoJS.TripleDES.decrypt(opStr, keyHex, {
iv: ivHex,
});
const plaintext = bytes.toString(cryptoJS.enc.Utf8);
return plaintext || opStr;
} catch (err) {
return opStr;
}
}
}
Date.prototype.Format = function (fmt) { // author: meizz
const o = {
'M+': this.getMonth() + 1, // 月份
'd+': this.getDate(), // 日
'h+': this.getHours(), // 小时
'm+': this.getMinutes(), // 分
's+': this.getSeconds(), // 秒
'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
S: this.getMilliseconds(), // 毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (`${this.getFullYear()}`).substr(4 - RegExp.$1.length));
for (const k in o) if (new RegExp(`(${k})`).test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length)));
return fmt;
const o = {
'M+': this.getMonth() + 1, // 月份
'd+': this.getDate(), // 日
'h+': this.getHours(), // 小时
'm+': this.getMinutes(), // 分
's+': this.getSeconds(), // 秒
'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
S: this.getMilliseconds(), // 毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (`${this.getFullYear()}`).substr(4 - RegExp.$1.length));
for (const k in o) if (new RegExp(`(${k})`).test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length)));
return fmt;
};
/**
......@@ -353,57 +353,57 @@ Date.prototype.Format = function (fmt) { // author: meizz
// 表分类
System.FLOWCODE = {
BIZ: 'BIZ', // 商机表
SCHEME: 'SCHEME', // 方案表
DELIVERY: 'DELIVERY', // 服务单表
ANNUALREPORT: 'ANNUALREPORT', // 年报表
BIZ: 'BIZ', // 商机表
SCHEME: 'SCHEME', // 方案表
DELIVERY: 'DELIVERY', // 服务单表
ANNUALREPORT: 'ANNUALREPORT', // 年报表
};
// 服务名称
System.SERVICECODE = {
ICP: 'ICP',
EDI: 'EDI',
ICPANNUALREPORT: 'ICPANNUALREPORT',
EDIANNUALREPORT: 'EDIANNUALREPORT',
ICP: 'ICP',
EDI: 'EDI',
ICPANNUALREPORT: 'ICPANNUALREPORT',
EDIANNUALREPORT: 'EDIANNUALREPORT',
};
// 商机状态
System.BUSSTATUS = {
WAITINGSCHEME: 'beforeSubmission', // 待提交方案
WAITINGCONFIRM: 'beforeConfirmation', // 待用户确认
SUCCESS: 'isFinished', // 已成交
CLOSED: 'isClosed', // 需求关闭
WAITINGSCHEME: 'beforeSubmission', // 待提交方案
WAITINGCONFIRM: 'beforeConfirmation', // 待用户确认
SUCCESS: 'isFinished', // 已成交
CLOSED: 'isClosed', // 需求关闭
};
// 方案状态
System.SCHEMESTATUS = {
WAITINGCONFIRM: 'beforeConfirmation', // 待用户确认.
CLOSED: 'isClosed', // 方案关闭
REJECT: 'isReject', // 方案被拒绝
WAITINGCONFIRM: 'beforeConfirmation', // 待用户确认.
CLOSED: 'isClosed', // 方案关闭
REJECT: 'isReject', // 方案被拒绝
};
// 资质服务单状态
System.SERVERSESTATUS = {
RECEIVED: 'received', // 已接单
COLLECTING: 'collecting', // 收集材料中
SUBMITING: 'submiting', // 递交材料中
DISPOSEING: 'disposeing', // 工信部处理中
POSTING: 'posting', // 证书已邮寄
SUCCESS: 'success', // 服务已完成
CLOSED: 'closed', // 已关闭
RECEIVED: 'received', // 已接单
COLLECTING: 'collecting', // 收集材料中
SUBMITING: 'submiting', // 递交材料中
DISPOSEING: 'disposeing', // 工信部处理中
POSTING: 'posting', // 证书已邮寄
SUCCESS: 'success', // 服务已完成
CLOSED: 'closed', // 已关闭
};
// 年报服务单状态
System.ANNUALREPORT = {
RECEIVED: 'received', // 已接单
WAITDECLARE: 'waitdeclare', // 待申报
DECLARESUCCESS: 'declaresuccess', // 申报成功
SUCCESS: 'success', // 服务已完成
CLOSED: 'closed', // 已关闭
TAKEEFFECT: 'takeeffect', // 生效
RECEIVED: 'received', // 已接单
WAITDECLARE: 'waitdeclare', // 待申报
DECLARESUCCESS: 'declaresuccess', // 申报成功
SUCCESS: 'success', // 服务已完成
CLOSED: 'closed', // 已关闭
TAKEEFFECT: 'takeeffect', // 生效
};
// 渠道名
System.SOURCENAME = {
tencentCloud: '腾讯云',
tencentCloud: '腾讯云',
};
/*
......
......@@ -249,7 +249,7 @@ module.exports = RedisClient;
// console.log(r);
// });
// console.dir(client);ti.exec( callback )
//回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误
// 回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误
// r.set("hello","oooo").then(function(result){
// console.log(result);
// });
......
......@@ -228,9 +228,7 @@ function buildValue(value, cryptStr) {
}));
}
if (newValue.proposerInfo.businessInformation) {
newValue.proposerInfo.businessInformation.fixedTelephone = cryptStr(
newValue.proposerInfo.businessInformation.fixedTelephone
);
newValue.proposerInfo.businessInformation.fixedTelephone = cryptStr(newValue.proposerInfo.businessInformation.fixedTelephone);
}
}
if (newValue.shareholderData) {
......
......@@ -48,9 +48,9 @@ module.exports = function (app) {
const invokeObj = System.getObject(`api.${classPath}`);
if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => {
res.end(JSON.stringify(r));
});
}
p.then((r) => {
res.end(JSON.stringify(r));
});
});
};
......@@ -16,10 +16,10 @@ module.exports = function (app) {
const invokeObj = system.getObject(`web.${classPath}`);
if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => {
res.end(JSON.stringify(r));
});
}
p.then((r) => {
res.end(JSON.stringify(r));
});
});
app.post('/web/:gname/:qname/:method', (req, res) => {
req.codepath = req.headers.codepath;
......
......@@ -3,7 +3,7 @@ const fs = require('fs');
// function to encode file data to base64 encoded string
function base64Encode(file) {
// read binary data
const bitmap = fs.readFileSync("./imgs/sp.png");
const bitmap = fs.readFileSync('./imgs/sp.png');
// convert binary data to base64 encoded string
const bf = Buffer.alloc(bitmap.length, bitmap);
return bf.toString('base64');
......@@ -19,15 +19,15 @@ function base64Decode(base64str, file) {
function getDataUrl(filepath) {
const str = base64Encode(filepath);
let mime = "";
if (filepath.indexOf("png") >= 0) {
mime = "image/png";
let mime = '';
if (filepath.indexOf('png') >= 0) {
mime = 'image/png';
}
if (filepath.indexOf("jpg") >= 0 || filepath.indexOf("jpeg") >= 0) {
mime = "image/jpg";
if (filepath.indexOf('jpg') >= 0 || filepath.indexOf('jpeg') >= 0) {
mime = 'image/jpg';
}
if (filepath.indexOf("gif") >= 0) {
mime = "image/gif";
if (filepath.indexOf('gif') >= 0) {
mime = 'image/gif';
}
const dataurl = `data:${mime};base64,${str}`;
return dataurl;
......
data:function(){
return {
downloadTimes : 1, // 设置检查重试次数变量,
code : '', // 下载文件的code值
}
data: function() {
return {
downloadTimes: 1, // 设置检查重试次数变量,
code: '', // 下载文件的code值
}
},
methods : {
methods: {
// 创建下载文件方法
exportFile() {
var self = this;
var datas = self.querydata;
if(!datas || datas.length == 0) {
if (!datas || datas.length == 0) {
that.$message.warning(`无查询结果`);
return ;
return;
}
/* [{},{},{}]转换成[[],[],[]] 格式 */
var rows = [];
for(var dd of datas) {
for (var dd of datas) {
var arr = [];
for(var _idx in dd) {
for (var _idx in dd) {
arr.push(dd[_idx]);
}
rows.push(arr);
}
this.code = "";
/* 生成文件 */
self.$root.postReq("/web/filedownloadCtl/download",{rows : rows}).then(function(d){
if(d.status == 0) {
setTimeout((function(){
self.$root.postReq("/web/filedownloadCtl/download", { rows: rows }).then(function (d) {
if (d.status == 0) {
setTimeout((function () {
/* d.data 返回文件标识 */
self.code = d.data;
self.downloadFile();
......@@ -38,21 +38,21 @@ methods : {
/* 循环检查code, 并下载文件 */
downloadFile() {
var self = this;
self.$root.postReq("/web/filedownloadCtl/findOne",{code : self.code}).then(function(d){
if(d.status == 0) {
if(d.data && d.data.filePath) {
self.$root.postReq("/web/filedownloadCtl/findOne", { code: self.code }).then(function (d) {
if (d.status == 0) {
if (d.data && d.data.filePath) {
downloadTimes = 1;
/* 文件生成成功 */
window.open(d.data.filePath, "_blank");
} else {
/* 递归2秒一次,超过5次,下载失败 */
if(downloadTimes > 5) {
if (downloadTimes > 5) {
downloadTimes = 1;
/* 下载超时 */
return;
}
downloadTimes = downloadTimes + 1;
setTimeout((function(){
setTimeout((function () {
self.downloadFile();
}), 2000);
}
......
const gulp = require('gulp');
const fs = require("fs");
const tap = require('gulp-tap');
const minimist = require('minimist');
const merge = require('merge-stream');
const rename = require('gulp-rename');
const del = require("del");
const concat = require('gulp-concat');
const gulpif = require("gulp-if");
const knownOptions = {
string: 'name',
string: 'bizfile',
default: { name: process.env.NODE_ENV || 'Test' }
};
const options = minimist(process.argv.slice(2), knownOptions);
const name = options.name;
const bizfile = options.bizfile;
const BUILD_PATH = "./extra/build";
const DEST_PATH = "./extra/dest";
const CTL_PATH = "./app/base/controller/impl";
const SERVICE_PATH = "./app/base/service/impl";
const DAO_PATH = "./app/base/db/impl";
const PAGE_PATH = "./app/front/vues/pages";
const VUECOM_PATH = "./app/front/vues";
const CSS_PATH = "./app/front/entry/public/css";
const IMG_PATH = "./extra/imgs";
const DEST_IMGPATH = "./app/front/entry/public/imgs";
const METABIZ_PATH = "./app/base/db/metadata/bizs/wx76a324c5d201d1a4";
gulp.task('makefile', function (done) {
// 将你的默认的任务代码放在这
del("./extra/dest/*");
const tmpName = name.toLowerCase();
const fstream = gulp.src("./extra/build/*.js")
.pipe(tap(function (file) {
const sfile = file.contents.toString('utf-8');
const rpstr = sfile.replace(/\$\{Name\}/g, name);
file.contents = new Buffer(rpstr, "utf-8");
})).pipe(
rename(function (path) {
path.basename = path.basename.replace("templ", tmpName);
})
).pipe(gulp.dest("./extra/dest"));
return fstream;
// const pageStream=gulp.src("./extra/build/page/**/*").pipe(
// gulp.dest("./extra/dest")
// );
// return merge(fstream, pageStream);
});
gulp.task('page', function (cbk) {
const tmpName = name.toLowerCase();
return gulp.src("./extra/build/page/templPage/*.*")
.pipe(
rename(function (path) {
path.basename = path.basename.replace("templ", tmpName);
})
).pipe(tap(function (file) {
const sfile = file.contents.toString();
const rpstr = sfile.replace(/\$\{COMNAME\}/g, "gsb_" + tmpName);
file.contents = new Buffer(rpstr, "utf-8");
})).pipe(
gulp.dest("./extra/dest/" + tmpName + "/")
);
});
gulp.task("cpctl", function (cbk) {
const tmpName = name.toLowerCase();
return gulp.src("./extra/dest/" + tmpName + "Ctl.js").pipe(
rename(function (path) {
path.basename = path.basename.substring(0, 1).toLowerCase() + path.basename.substring(1);
})
).pipe(gulp.dest(CTL_PATH));
});
gulp.task("cpsve", function (cbk) {
const tmpName = name.toLowerCase();
return gulp.src("./extra/dest/" + tmpName + "Sve.js").pipe(
rename(function (path) {
path.basename = path.basename.substring(0, 1).toLowerCase() + path.basename.substring(1);
})
).pipe(gulp.dest(SERVICE_PATH));
});
gulp.task("cpdao", function (cbk) {
const tmpName = name.toLowerCase();
return gulp.src("./extra/dest/" + tmpName + "Dao.js").pipe(
rename(function (path) {
path.basename = path.basename.substring(0, 1).toLowerCase() + path.basename.substring(1);
})
).pipe(gulp.dest(DAO_PATH));
});
gulp.task("cppage", function (cbk) {
const tmpName = name.toLowerCase();
return gulp.src("./extra/dest/" + tmpName + "/*.*").pipe(gulp.dest(PAGE_PATH + "/" + tmpName + "/"));
});
gulp.task("cpbizfile", function (cbk) {
return gulp.src("./extra/build/page/meta.js").pipe(
rename(function (path) {
if (bizfile) {
path.basename = bizfile;
} else {
path.basename = name;
}
})
).pipe(gulp.dest(METABIZ_PATH + "/"));
});
gulp.task("simple", ['page', 'cppage', 'cpbizfile'], function (done) {
done();
});
gulp.task('all', ['makefile', 'page', 'cpctl', 'cpsve', 'cpdao', 'cppage', 'cpbizfile'], function (done) {
done();
});
const minifycss = require('gulp-minify-css')
gulp.task("pagecss", function (cbk) {
function defaultcondition(file) {
if (file.path.indexOf("spring") >= 0) {
return false;
} else if (file.path.indexOf("summer") >= 0) {
return false;
} else if (file.path.indexOf("autumn") >= 0) {
return false;
} else if (file.path.indexOf("winter") >= 0) {
return false;
} else {
return true;
}
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(defaultcondition, concat("pagecom.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task("springcss", function (cbk) {
function springcondition(file) {
if (file.path.indexOf("spring") >= 0) {
return true;
}
return false;
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(springcondition, concat("spring.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task("summercss", function (cbk) {
function summercondition(file) {
if (file.path.indexOf("summer") >= 0) {
return true;
}
return false;
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(summercondition, concat("summer.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task("autumncss", function (cbk) {
function autumncondition(file) {
if (file.path.indexOf("autumn") >= 0) {
return true;
}
return false;
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(autumncondition, concat("autumn.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task("wintercss", function (cbk) {
function wintercondition(file) {
if (file.path.indexOf("winter") >= 0) {
return true;
}
return false;
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(wintercondition, concat("winter.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task("1", function (cbk) {
function mobilecondition(file) {
if (file.path.indexOf("mobile") >= 0) {
return true;
}
return false;
}
return gulp.src(VUECOM_PATH + "/**/*/*.css").pipe(
gulpif(mobilecondition, concat("mobile.css"))
).pipe(minifycss()).pipe(gulp.dest(CSS_PATH + "/"));
});
gulp.task('allcss', ['pagecss', 'springcss', 'summercss', 'autumncss', 'wintercss'], function (done) {
done();
});
gulp.task('watch', function () {
gulp.watch(VUECOM_PATH + "/**/*/*.css", gulp.series(['allcss']));
});
gulp.task("basehandle", function (cbk) {
return gulp.src(VUECOM_PATH + "/base/**/*.vue").
pipe(tap(function (file) {
file.contents = new Buffer(require(file.path).replace(/\n/g, ""), "utf-8");
})).pipe(gulp.dest(VUECOM_PATH + "/allie/base/"));
});
const gulp = require('gulp'),
imagemin = require('gulp-imagemin');
pngquant = require('imagemin-pngquant'),
gulp.task('testimg', function () {
del("./extra/testimgs/*");
return gulp.src(IMG_PATH + '/**/*.{png,jpg,gif,ico}')
.pipe(imagemin({
optimizationLevel: 1, //类型:Number 默认:3 取值范围:0-7(优化等级)
progressive: true, //类型:Boolean 默认:false 无损压缩jpg图片
interlaced: true, //类型:Boolean 默认:false 隔行扫描gif进行渲染
multipass: true,//类型:Boolean 默认:false 多次优化svg直到完全优化
use: [pngquant({
quality: [0.3]
})]
}))
//.pipe(gulp.dest(DEST_IMGPATH));
.pipe(gulp.dest("./extra/testimgs/"));
});
\ No newline at end of file
const http = require('http');
const express = require('express');
const app = express();
const setttings = require("./app/config/settings");
const setttings = require('./app/config/settings');
const environment = require('./app/config/environment');
// const SocketServer=require("./app/config/socket.server");
//const cluster = require('cluster');
//const numCPUs = require('os').cpus().length;
// const cluster = require('cluster');
// const numCPUs = require('os').cpus().length;
// all environments
environment(app);//初始化环境
environment(app);// 初始化环境
// 错误处理中间件应当在路由加载之后才能加载
// if (cluster.isMaster) {
// console.log(`Master ${process.pid} is running`);
......@@ -27,8 +27,8 @@ environment(app);//初始化环境
// });
// }
const server = http.createServer(app);
//const socketServer = new SocketServer(server);
server.listen(setttings.port, function () {
// const socketServer = new SocketServer(server);
server.listen(setttings.port, () => {
console.log(`Express server listening on port ${app.get('port')}`);
});
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