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,8 +122,9 @@ class MaterialCtl extends CtlBase {
};
// 专项审批项目 ICP
if (type === 'ICP') {
implementationPlanData.files.push(
...specialApproval.filter(item => (!!(item.file && item.file.url))).map(item => ({
implementationPlanData.files.push(...specialApproval.filter(item => (!!(
item.file
&& item.file.url))).map(item => ({
file: item.file,
title: `专项审批项-${item.title}`,
})));
......@@ -131,8 +132,9 @@ class MaterialCtl extends CtlBase {
implementationPlanData.files.push(...otherMaterialsInfo.filter(item => item.title === '域名证书'));
if (type === 'EDI') {
implementationPlanData.files.push(
...serviceProjectEdi.filter(item => (!!(item.file && item.file.url))).map(item => ({
implementationPlanData.files.push(...serviceProjectEdi.filter(item => (!!(
item.file
&& item.file.url))).map(item => ({
title: item.title,
file: item.file,
})));
......
......@@ -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;
}
}
}
module.exports = RoleDao;
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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));
});
}
});
};
......@@ -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));
});
}
});
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(){
data: function() {
return {
downloadTimes : 1, // 设置检查重试次数变量,
code : '', // 下载文件的code值
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