Commit b669e8db by Sxy

fix: 代码规范

parent 577fbddf
...@@ -42,9 +42,7 @@ class OSSAPI extends APIBase { ...@@ -42,9 +42,7 @@ class OSSAPI extends APIBase {
} }
async downfile(srckey) { async downfile(srckey) {
const oss = System.getObject('util.ossClient'); const oss = System.getObject('util.ossClient');
const downfile = await oss.downfile(srckey).then(() => { const downfile = await oss.downfile(srckey).then(() => `/tmp/${srckey}`);
return `/tmp/${srckey}`;
});
return downfile; return downfile;
} }
} }
......
...@@ -30,7 +30,7 @@ class MaterialCtl extends CtlBase { ...@@ -30,7 +30,7 @@ class MaterialCtl extends CtlBase {
profitableWay, profitableWay,
specialApproval, specialApproval,
serviceProjectEdi, serviceProjectEdi,
serviceProjectIcp serviceProjectIcp,
} = implementationPlanInfo; } = implementationPlanInfo;
// 1. id ,type // 1. id ,type
...@@ -122,20 +122,22 @@ class MaterialCtl extends CtlBase { ...@@ -122,20 +122,22 @@ class MaterialCtl extends CtlBase {
}; };
// 专项审批项目 ICP // 专项审批项目 ICP
if (type === 'ICP') { if (type === 'ICP') {
implementationPlanData.files.push( implementationPlanData.files.push(...specialApproval.filter(item => (!!(
...specialApproval.filter(item => (!!(item.file && item.file.url))).map(item => ({ item.file
file: item.file, && item.file.url))).map(item => ({
title: `专项审批项-${item.title}`, file: item.file,
}))); title: `专项审批项-${item.title}`,
})));
} }
implementationPlanData.files.push(...otherMaterialsInfo.filter(item => item.title === '域名证书')); implementationPlanData.files.push(...otherMaterialsInfo.filter(item => item.title === '域名证书'));
if (type === 'EDI') { if (type === 'EDI') {
implementationPlanData.files.push( implementationPlanData.files.push(...serviceProjectEdi.filter(item => (!!(
...serviceProjectEdi.filter(item => (!!(item.file && item.file.url))).map(item => ({ item.file
title: item.title, && item.file.url))).map(item => ({
file: item.file, title: item.title,
}))); file: item.file,
})));
} }
// 4. 增值电信申请表 // 4. 增值电信申请表
......
...@@ -49,10 +49,10 @@ class Dao { ...@@ -49,10 +49,10 @@ class Dao {
if (t != null && t != 'undefined') { if (t != null && t != 'undefined') {
whereParam.transaction = t; whereParam.transaction = t;
const result = await this.model.destroy(whereParam); const result = await this.model.destroy(whereParam);
return result return result;
} }
const result = await this.model.destroy(whereParam); const result = await this.model.destroy(whereParam);
return result return result;
} }
async delete(qobj, t) { async delete(qobj, t) {
let en = null; let en = null;
......
...@@ -40,10 +40,9 @@ class RoleDao extends Dao { ...@@ -40,10 +40,9 @@ class RoleDao extends Dao {
if (t) { if (t) {
const role = await this.model.create(u2, { transaction: t }); const role = await this.model.create(u2, { transaction: t });
return role; return role;
} else {
const role = await this.model.create(u2);
return role;
} }
const role = await this.model.create(u2);
return role;
} }
} }
module.exports = RoleDao; module.exports = RoleDao;
...@@ -9,11 +9,11 @@ class UserDao extends Dao { ...@@ -9,11 +9,11 @@ class UserDao extends Dao {
return this.model.findOne({ return this.model.findOne({
where: { id: userid }, where: { id: userid },
include: [{ model: self.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'] }, 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.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] }, { model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] },
], ],
}, },
], ],
}); });
} }
...@@ -22,12 +22,12 @@ class UserDao extends Dao { ...@@ -22,12 +22,12 @@ class UserDao extends Dao {
const tUser = await this.model.findOne({ const tUser = await this.model.findOne({
where: { userName: username, app_id: app.id }, where: { userName: username, app_id: app.id },
include: [{ model: this.db.models.app, raw: true }, include: [{ model: this.db.models.app, raw: true },
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], 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.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true }, { model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
], ],
}, },
], ],
}, { transaction: t }); }, { transaction: t });
// if(tUser!=null){ // if(tUser!=null){
...@@ -41,12 +41,12 @@ class UserDao extends Dao { ...@@ -41,12 +41,12 @@ class UserDao extends Dao {
let tUser = await this.model.findOne({ let tUser = await this.model.findOne({
where: { openId: popenid }, where: { openId: popenid },
include: [{ model: this.db.models.app, raw: true }, include: [{ model: this.db.models.app, raw: true },
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], 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.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true }, { model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
], ],
}, },
], ],
}, { transaction: t }); }, { transaction: t });
if (tUser != null) { if (tUser != null) {
...@@ -123,7 +123,7 @@ class UserDao extends Dao { ...@@ -123,7 +123,7 @@ class UserDao extends Dao {
// 修改用户(user表)公司的唯一码 // 修改用户(user表)公司的唯一码
async putUserCompanyOnlyCode(userId, companyOnlyCode, result) { async putUserCompanyOnlyCode(userId, companyOnlyCode, result) {
const customerObj = { companyOnlyCode: companyOnlyCode }; const customerObj = { companyOnlyCode };
const putSqlWhere = { where: { id: userId } }; const putSqlWhere = { where: { id: userId } };
this.updateByWhere(customerObj, putSqlWhere); this.updateByWhere(customerObj, putSqlWhere);
return result; return result;
......
...@@ -40,7 +40,7 @@ class DeliverDao extends Dao { ...@@ -40,7 +40,7 @@ class DeliverDao extends Dao {
case '/deliveryManagement/wait': case '/deliveryManagement/wait':
qc.where.delivery_status = qc.where.delivery_status || { qc.where.delivery_status = qc.where.delivery_status || {
$in: [system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING, $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; break;
......
...@@ -8,7 +8,7 @@ class MsgNoticeDao extends Dao { ...@@ -8,7 +8,7 @@ class MsgNoticeDao extends Dao {
async saveNotice(msg, t) { async saveNotice(msg, t) {
let noticeFrom = await super.findOne({ fromId: msg.senderId, toId: msg.targetId }); let noticeFrom = await super.findOne({ fromId: msg.senderId, toId: msg.targetId });
if (noticeFrom) { if (noticeFrom) {
let set = { lastMsgId: msg.id }; const set = { lastMsgId: msg.id };
if (msg.businessLicense_id) { if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id; set.businessLicense_id = msg.businessLicense_id;
} }
...@@ -28,7 +28,7 @@ class MsgNoticeDao extends Dao { ...@@ -28,7 +28,7 @@ class MsgNoticeDao extends Dao {
let noticeTo = await super.findOne({ fromId: msg.targetId, toId: msg.senderId }); let noticeTo = await super.findOne({ fromId: msg.targetId, toId: msg.senderId });
if (noticeTo) { if (noticeTo) {
let set = { lastMsgId: msg.id }; const set = { lastMsgId: msg.id };
if (msg.businessLicense_id) { if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id; set.businessLicense_id = msg.businessLicense_id;
} }
......
...@@ -11,7 +11,7 @@ class AuthService extends ServiceBase { ...@@ -11,7 +11,7 @@ class AuthService extends ServiceBase {
// var newattrs=rolecodestr.split(","); // var newattrs=rolecodestr.split(",");
const aths = await this.dao.model.findAll({ const aths = await this.dao.model.findAll({
attributes: ['bizcode', 'authstrs', 'codepath'], 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; return aths;
} }
...@@ -22,7 +22,7 @@ class AuthService extends ServiceBase { ...@@ -22,7 +22,7 @@ class AuthService extends ServiceBase {
console.log(auths); console.log(auths);
return self.db.transaction(async (t) => { return self.db.transaction(async (t) => {
for (let i = 0; i < auths.length; i++) { for (let i = 0; i < auths.length; i++) {
let tmpAuth = auths[i]; const tmpAuth = auths[i];
tmpAuth.app_id = appid; tmpAuth.app_id = appid;
tmpAuth.company_id = cmid; tmpAuth.company_id = cmid;
const objrtn = await self.dao.model.findOrCreate({ const objrtn = await self.dao.model.findOrCreate({
...@@ -38,18 +38,18 @@ class AuthService extends ServiceBase { ...@@ -38,18 +38,18 @@ class AuthService extends ServiceBase {
where: where:
{ {
role_id: tmpAuth.role_id, role_id: tmpAuth.role_id,
bizcode: tmpAuth.bizcode bizcode: tmpAuth.bizcode,
}, },
transaction: t transaction: t,
}); });
} }
} }
const aths = await self.dao.model.findAll({ const aths = await self.dao.model.findAll({
where: { where: {
role_id: tmpAuth.role_id, role_id: tmpAuth.role_id,
app_id: tmpAuth.app_id app_id: tmpAuth.app_id,
}, },
transaction: t transaction: t,
}); });
return aths; return aths;
}); });
......
...@@ -44,7 +44,7 @@ class OrgService extends ServiceBase { ...@@ -44,7 +44,7 @@ class OrgService extends ServiceBase {
const usersupdate = await self.db.models.user.findAll({ where: { org_id: orgupdate.id } }); const usersupdate = await self.db.models.user.findAll({ where: { org_id: orgupdate.id } });
// 如果节点名称或岗位性质发生变化 // 如果节点名称或岗位性质发生变化
// if(p.name!=orgupdate.name || p.isMain!=orgupdate.isMain){ // if(p.name!=orgupdate.name || p.isMain!=orgupdate.isMain){
for (let ud of usersupdate) { for (const ud of usersupdate) {
ud.opath = p.orgpath; ud.opath = p.orgpath;
const n = p.orgpath.lastIndexOf('/'); const n = p.orgpath.lastIndexOf('/');
ud.ppath = p.isMain ? p.orgpath.substring(0, n) : p.orgpath; ud.ppath = p.isMain ? p.orgpath.substring(0, n) : p.orgpath;
......
...@@ -64,9 +64,9 @@ class UserService extends ServiceBase { ...@@ -64,9 +64,9 @@ class UserService extends ServiceBase {
where: { where: {
id: { [self.db.Op.in]: rolecodes }, id: { [self.db.Op.in]: rolecodes },
app_id: roleappid, app_id: roleappid,
company_id: p.company_id company_id: p.company_id,
}, },
transaction: t transaction: t,
}); });
if (roles && roles.length > 0) { if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t }); await u.setRoles(roles, { transaction: t });
...@@ -192,7 +192,7 @@ class UserService extends ServiceBase { ...@@ -192,7 +192,7 @@ class UserService extends ServiceBase {
nickName: mobile, nickName: mobile,
rolecodes: p.rolecodes, rolecodes: p.rolecodes,
company_id: p.company_id, 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); const token = await this.cmakejwt(regrtn.user.jwtkey, regrtn.user.jwtsecret, null);
// rtn.token = token; // rtn.token = token;
......
...@@ -18,8 +18,8 @@ class SchemeService extends ServiceBase { ...@@ -18,8 +18,8 @@ class SchemeService extends ServiceBase {
throw new Error('查不到该商机'); throw new Error('查不到该商机');
} }
if ([system.BUSSTATUS.CLOSED, if ([system.BUSSTATUS.CLOSED,
system.BUSSTATUS.SUCCESS, system.BUSSTATUS.SUCCESS,
system.BUSSTATUS.WAITINGCONFIRM].includes(bizData.business_status)) { system.BUSSTATUS.WAITINGCONFIRM].includes(bizData.business_status)) {
throw new Error('此商机状态下不可操作'); throw new Error('此商机状态下不可操作');
} }
const schemeData = await this.dao.findOne({ const schemeData = await this.dao.findOne({
...@@ -27,7 +27,7 @@ class SchemeService extends ServiceBase { ...@@ -27,7 +27,7 @@ class SchemeService extends ServiceBase {
}); });
if (schemeData if (schemeData
&& [system.SCHEMESTATUS.WAITINGCONFIRM, && [system.SCHEMESTATUS.WAITINGCONFIRM,
system.SCHEMESTATUS.CLOSED].includes(schemeData.scheme_status)) { system.SCHEMESTATUS.CLOSED].includes(schemeData.scheme_status)) {
throw new Error('此方案状态下不可操作'); throw new Error('此方案状态下不可操作');
} }
...@@ -35,7 +35,7 @@ class SchemeService extends ServiceBase { ...@@ -35,7 +35,7 @@ class SchemeService extends ServiceBase {
data.scheme_number = await pushTx.pushScheme(bizData, schemeData data.scheme_number = await pushTx.pushScheme(bizData, schemeData
? { ? {
...data, ...data,
scheme_number: schemeData.scheme_number scheme_number: schemeData.scheme_number,
} : data); } : data);
......
...@@ -25,12 +25,12 @@ class CompanyService extends ServiceBase { ...@@ -25,12 +25,12 @@ class CompanyService extends ServiceBase {
where: where:
{ {
id: { id: {
[self.db.Op.in]: roleids [self.db.Op.in]: roleids,
}, },
app_id: p.app_id, app_id: p.app_id,
company_id: p.company_id company_id: p.company_id,
}, },
transaction: t transaction: t,
}); });
for (const u of us) { for (const u of us) {
await u.setRoles(rs, { transaction: t }); await u.setRoles(rs, { transaction: t });
......
...@@ -22,8 +22,9 @@ class RouteService extends ServiceBase { ...@@ -22,8 +22,9 @@ class RouteService extends ServiceBase {
name: routedata.name, name: routedata.name,
hosts: routedata.hosts, hosts: routedata.hosts,
paths: routedata.paths, paths: routedata.paths,
strip_path: routedata.isstrip strip_path: routedata.isstrip,
}); },
);
routedata.center_id = routeobj.id; routedata.center_id = routeobj.id;
rtn = await self.dao.create(routedata, t); rtn = await self.dao.create(routedata, t);
} catch (e) { } catch (e) {
......
...@@ -188,8 +188,8 @@ class DeliverService extends ServiceBase { ...@@ -188,8 +188,8 @@ class DeliverService extends ServiceBase {
} }
if ( if (
![system.SERVERSESTATUS.DISPOSEING, ![system.SERVERSESTATUS.DISPOSEING,
system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status) system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)
) { ) {
throw new Error('该交付单状态下不可提交'); throw new Error('该交付单状态下不可提交');
} }
...@@ -352,8 +352,8 @@ class DeliverService extends ServiceBase { ...@@ -352,8 +352,8 @@ class DeliverService extends ServiceBase {
} }
if ( if (
![system.SERVERSESTATUS.DISPOSEING, ![system.SERVERSESTATUS.DISPOSEING,
system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.SUCCESS,
system.SERVERSESTATUS.POSTING].includes(result.delivery_status) system.SERVERSESTATUS.POSTING].includes(result.delivery_status)
) { ) {
throw new Error('该状态下不可填写邮寄信息'); throw new Error('该状态下不可填写邮寄信息');
} }
......
...@@ -249,7 +249,7 @@ module.exports = RedisClient; ...@@ -249,7 +249,7 @@ module.exports = RedisClient;
// console.log(r); // console.log(r);
// }); // });
// console.dir(client);ti.exec( callback ) // console.dir(client);ti.exec( callback )
//回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误 // 回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误
// r.set("hello","oooo").then(function(result){ // r.set("hello","oooo").then(function(result){
// console.log(result); // console.log(result);
// }); // });
......
...@@ -228,9 +228,7 @@ function buildValue(value, cryptStr) { ...@@ -228,9 +228,7 @@ function buildValue(value, cryptStr) {
})); }));
} }
if (newValue.proposerInfo.businessInformation) { if (newValue.proposerInfo.businessInformation) {
newValue.proposerInfo.businessInformation.fixedTelephone = cryptStr( newValue.proposerInfo.businessInformation.fixedTelephone = cryptStr(newValue.proposerInfo.businessInformation.fixedTelephone);
newValue.proposerInfo.businessInformation.fixedTelephone
);
} }
} }
if (newValue.shareholderData) { if (newValue.shareholderData) {
......
...@@ -48,9 +48,9 @@ module.exports = function (app) { ...@@ -48,9 +48,9 @@ module.exports = function (app) {
const invokeObj = System.getObject(`api.${classPath}`); const invokeObj = System.getObject(`api.${classPath}`);
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); 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) { ...@@ -16,10 +16,10 @@ module.exports = function (app) {
const invokeObj = system.getObject(`web.${classPath}`); const invokeObj = system.getObject(`web.${classPath}`);
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); 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) => { app.post('/web/:gname/:qname/:method', (req, res) => {
req.codepath = req.headers.codepath; req.codepath = req.headers.codepath;
......
...@@ -3,7 +3,7 @@ const fs = require('fs'); ...@@ -3,7 +3,7 @@ const fs = require('fs');
// function to encode file data to base64 encoded string // function to encode file data to base64 encoded string
function base64Encode(file) { function base64Encode(file) {
// read binary data // read binary data
const bitmap = fs.readFileSync("./imgs/sp.png"); const bitmap = fs.readFileSync('./imgs/sp.png');
// convert binary data to base64 encoded string // convert binary data to base64 encoded string
const bf = Buffer.alloc(bitmap.length, bitmap); const bf = Buffer.alloc(bitmap.length, bitmap);
return bf.toString('base64'); return bf.toString('base64');
...@@ -19,15 +19,15 @@ function base64Decode(base64str, file) { ...@@ -19,15 +19,15 @@ function base64Decode(base64str, file) {
function getDataUrl(filepath) { function getDataUrl(filepath) {
const str = base64Encode(filepath); const str = base64Encode(filepath);
let mime = ""; let mime = '';
if (filepath.indexOf("png") >= 0) { if (filepath.indexOf('png') >= 0) {
mime = "image/png"; mime = 'image/png';
} }
if (filepath.indexOf("jpg") >= 0 || filepath.indexOf("jpeg") >= 0) { if (filepath.indexOf('jpg') >= 0 || filepath.indexOf('jpeg') >= 0) {
mime = "image/jpg"; mime = 'image/jpg';
} }
if (filepath.indexOf("gif") >= 0) { if (filepath.indexOf('gif') >= 0) {
mime = "image/gif"; mime = 'image/gif';
} }
const dataurl = `data:${mime};base64,${str}`; const dataurl = `data:${mime};base64,${str}`;
return dataurl; return dataurl;
......
data:function(){ data: function() {
return { return {
downloadTimes : 1, // 设置检查重试次数变量, downloadTimes: 1, // 设置检查重试次数变量,
code : '', // 下载文件的code值 code: '', // 下载文件的code值
} }
}, },
methods : { methods: {
// 创建下载文件方法 // 创建下载文件方法
exportFile() { exportFile() {
var self = this; var self = this;
var datas = self.querydata; var datas = self.querydata;
if(!datas || datas.length == 0) { if (!datas || datas.length == 0) {
that.$message.warning(`无查询结果`); that.$message.warning(`无查询结果`);
return ; return;
} }
/* [{},{},{}]转换成[[],[],[]] 格式 */ /* [{},{},{}]转换成[[],[],[]] 格式 */
var rows = []; var rows = [];
for(var dd of datas) { for (var dd of datas) {
var arr = []; var arr = [];
for(var _idx in dd) { for (var _idx in dd) {
arr.push(dd[_idx]); arr.push(dd[_idx]);
} }
rows.push(arr); rows.push(arr);
} }
this.code = ""; this.code = "";
/* 生成文件 */ /* 生成文件 */
self.$root.postReq("/web/filedownloadCtl/download",{rows : rows}).then(function(d){ self.$root.postReq("/web/filedownloadCtl/download", { rows: rows }).then(function (d) {
if(d.status == 0) { if (d.status == 0) {
setTimeout((function(){ setTimeout((function () {
/* d.data 返回文件标识 */ /* d.data 返回文件标识 */
self.code = d.data; self.code = d.data;
self.downloadFile(); self.downloadFile();
...@@ -38,21 +38,21 @@ methods : { ...@@ -38,21 +38,21 @@ methods : {
/* 循环检查code, 并下载文件 */ /* 循环检查code, 并下载文件 */
downloadFile() { downloadFile() {
var self = this; var self = this;
self.$root.postReq("/web/filedownloadCtl/findOne",{code : self.code}).then(function(d){ self.$root.postReq("/web/filedownloadCtl/findOne", { code: self.code }).then(function (d) {
if(d.status == 0) { if (d.status == 0) {
if(d.data && d.data.filePath) { if (d.data && d.data.filePath) {
downloadTimes = 1; downloadTimes = 1;
/* 文件生成成功 */ /* 文件生成成功 */
window.open(d.data.filePath, "_blank"); window.open(d.data.filePath, "_blank");
} else { } else {
/* 递归2秒一次,超过5次,下载失败 */ /* 递归2秒一次,超过5次,下载失败 */
if(downloadTimes > 5) { if (downloadTimes > 5) {
downloadTimes = 1; downloadTimes = 1;
/* 下载超时 */ /* 下载超时 */
return; return;
} }
downloadTimes = downloadTimes + 1; downloadTimes = downloadTimes + 1;
setTimeout((function(){ setTimeout((function () {
self.downloadFile(); self.downloadFile();
}), 2000); }), 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 http = require('http');
const express = require('express'); const express = require('express');
const app = express(); const app = express();
const setttings = require("./app/config/settings"); const setttings = require('./app/config/settings');
const environment = require('./app/config/environment'); const environment = require('./app/config/environment');
// const SocketServer=require("./app/config/socket.server"); // const SocketServer=require("./app/config/socket.server");
//const cluster = require('cluster'); // const cluster = require('cluster');
//const numCPUs = require('os').cpus().length; // const numCPUs = require('os').cpus().length;
// all environments // all environments
environment(app);//初始化环境 environment(app);// 初始化环境
// 错误处理中间件应当在路由加载之后才能加载 // 错误处理中间件应当在路由加载之后才能加载
// if (cluster.isMaster) { // if (cluster.isMaster) {
// console.log(`Master ${process.pid} is running`); // console.log(`Master ${process.pid} is running`);
...@@ -27,8 +27,8 @@ environment(app);//初始化环境 ...@@ -27,8 +27,8 @@ environment(app);//初始化环境
// }); // });
// } // }
const server = http.createServer(app); const server = http.createServer(app);
//const socketServer = new SocketServer(server); // const socketServer = new SocketServer(server);
server.listen(setttings.port, function () { server.listen(setttings.port, () => {
console.log(`Express server listening on port ${app.get('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