Commit f6936e38 by Sxy

fix: 代码规范

parent c744c92c
...@@ -42,7 +42,7 @@ class OSSAPI extends APIBase { ...@@ -42,7 +42,7 @@ class OSSAPI extends APIBase {
}; };
async downfile(srckey) { async downfile(srckey) {
const oss = System.getObject('util.ossClient'); const oss = System.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => { let downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`; downfile = `/tmp/${srckey}`;
return downfile; return downfile;
}); });
......
...@@ -30,7 +30,10 @@ class DeliverybillCtl extends CtlBase { ...@@ -30,7 +30,10 @@ class DeliverybillCtl extends CtlBase {
const rs = await this.service.findAndCountAll(pobj); const rs = await this.service.findAndCountAll(pobj);
const result = []; const result = [];
for (const val of rs.results.rows) { for (const val of rs.results.rows) {
const { id, delivery_code, service_address, delivery_info, created_at, updated_at, delivery_status, delivery_man_name } = val; const { id, delivery_code,
service_address, delivery_info,
created_at, updated_at, delivery_status,
delivery_man_name } = val;
result.push({ result.push({
deliveryId: id, // id deliveryId: id, // id
deliveryNumber: delivery_code, // 交付单编号 deliveryNumber: delivery_code, // 交付单编号
...@@ -99,7 +102,11 @@ class DeliverybillCtl extends CtlBase { ...@@ -99,7 +102,11 @@ class DeliverybillCtl extends CtlBase {
if (!pobj.deliverId) { if (!pobj.deliverId) {
throw new Error('deliverId 不能为空'); throw new Error('deliverId 不能为空');
} }
if (!pobj.contactsName || !pobj.time || !pobj.accountingType || !pobj.taxpayerType || (!pobj.supplier && pobj.supplier != 0)) { if (!pobj.contactsName
|| !pobj.time
|| !pobj.accountingType
|| !pobj.taxpayerType
|| (!pobj.supplier && pobj.supplier != 0)) {
throw new Error('参数不能为空'); throw new Error('参数不能为空');
} }
const rs = await this.service.setupBill(pobj); const rs = await this.service.setupBill(pobj);
...@@ -391,7 +398,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -391,7 +398,7 @@ class DeliverybillCtl extends CtlBase {
customerId: deliverInfo.deliveryBillInfo.vftClientId, // 客户信息(帐套) customerId: deliverInfo.deliveryBillInfo.vftClientId, // 客户信息(帐套)
sign: '', // 签名 sign: '', // 签名
postWay: '2', postWay: '2',
currentPeriod: pobj.actionBody.accountDate.replace(/\-/g, ''), currentPeriod: pobj.actionBody.accountDate.replace(/-/g, ''),
courierNumber: pobj.actionBody.expressNum, courierNumber: pobj.actionBody.expressNum,
}; };
const result = await toFtClient.postToFtBySign('/customerReceiveBill/addCusReceiveBill', param); const result = await toFtClient.postToFtBySign('/customerReceiveBill/addCusReceiveBill', param);
......
...@@ -41,21 +41,21 @@ class SchemeCtl extends CtlBase { ...@@ -41,21 +41,21 @@ class SchemeCtl extends CtlBase {
rarr.servicerName = rs.facilitator_name;// 服务商名称 rarr.servicerName = rs.facilitator_name;// 服务商名称
rarr.clerkName = rs.salesman_name;// 业务员名称 rarr.clerkName = rs.salesman_name;// 业务员名称
rarr.clerkPhone = rs.salesman_phone;// 业务员联系方式 rarr.clerkPhone = rs.salesman_phone;// 业务员联系方式
rarr.createdTime = this.timeFormat(rs.created_at);// 创建方案的日期 rarr.createdTime = this.timeFormat(rs.created_at);// 创建方案的日期
rarr.statusTime = this.timeFormat(rs.updated_at);// 当前状态的日期 rarr.statusTime = this.timeFormat(rs.updated_at);// 当前状态的日期
const baseInfo = {}; const baseInfo = {};
if (rs.scheme_info.companyName && rs.scheme_info.companyName != 'undefined') { // 公司名称 if (rs.scheme_info.companyName && rs.scheme_info.companyName != 'undefined') { // 公司名称
rarr.companyName = rs.scheme_info.companyName; rarr.companyName = rs.scheme_info.companyName;
} }
if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册' if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册'
|| rarr.businessName == '税控申请' || rarr.businessName == '代理记账') { || rarr.businessName == '税控申请' || rarr.businessName == '代理记账') {
baseInfo.taxpayerType = rs.scheme_info.taxpayerType; baseInfo.taxpayerType = rs.scheme_info.taxpayerType;
} }
if (rarr.businessName == '园区注册') { if (rarr.businessName == '园区注册') {
baseInfo.registeredType = rs.scheme_info.registeredType; baseInfo.registeredType = rs.scheme_info.registeredType;
} }
if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册') { if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册') {
baseInfo.companyProperties = rs.scheme_info.companyProperties; baseInfo.companyProperties = rs.scheme_info.companyProperties;
baseInfo.engagedIndustry = rs.scheme_info.engagedIndustry; baseInfo.engagedIndustry = rs.scheme_info.engagedIndustry;
baseInfo.addressType = rs.scheme_info.addressType; baseInfo.addressType = rs.scheme_info.addressType;
baseInfo.fullAddress = rs.scheme_info.fullAddress; baseInfo.fullAddress = rs.scheme_info.fullAddress;
...@@ -123,7 +123,7 @@ class SchemeCtl extends CtlBase { ...@@ -123,7 +123,7 @@ class SchemeCtl extends CtlBase {
rarr.clerkId = rs.salesman_id;// 业务员id; rarr.clerkId = rs.salesman_id;// 业务员id;
rarr.clerkName = rs.salesman_name;// 业务员名称 rarr.clerkName = rs.salesman_name;// 业务员名称
rarr.clerkPhone = rs.salesman_phone;// 业务员联系方式 rarr.clerkPhone = rs.salesman_phone;// 业务员联系方式
rarr.createdTime = this.timeFormat(rs.created_at);// 创建方案的日期 rarr.createdTime = this.timeFormat(rs.created_at);// 创建方案的日期
rarr.statusTime = this.timeFormat(rs.updated_at);// 当前状态的日期 rarr.statusTime = this.timeFormat(rs.updated_at);// 当前状态的日期
rarr.baseInfo = rs.scheme_info; rarr.baseInfo = rs.scheme_info;
} }
...@@ -288,13 +288,13 @@ class SchemeCtl extends CtlBase { ...@@ -288,13 +288,13 @@ class SchemeCtl extends CtlBase {
} }
// 修改方案的时候,需要把修改的方案传给商城 // 修改方案的时候,需要把修改的方案传给商城
const ttype = pobj.businessType; const ttype = pobj.businessType;
console.log(`ttype:${ttype}`); console.log(`ttype:${ttype}`);
pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType]; pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
console.log(`businessType:${pobj.businessType}`); console.log(`businessType:${pobj.businessType}`);
const rc = system.getObject('util.execClient'); const rc = system.getObject('util.execClient');
const requrl = this.receiveUrl; const requrl = this.receiveUrl;
const params = { const params = {
actionType: 'submitSolution', actionType: 'submitSolution',
actionBody: { actionBody: {
needNum: pobj.businessMode, needNum: pobj.businessMode,
...@@ -453,12 +453,12 @@ class SchemeCtl extends CtlBase { ...@@ -453,12 +453,12 @@ class SchemeCtl extends CtlBase {
} }
// 调商城的接口,把商机详情返回给商城 // 调商城的接口,把商机详情返回给商城
const btype = pobj.businessType; const btype = pobj.businessType;
pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType]; pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
const rc = system.getObject('util.execClient'); const rc = system.getObject('util.execClient');
const requrl = this.receiveUrl; const requrl = this.receiveUrl;
const params = { const params = {
actionType: 'submitSolution', actionType: 'submitSolution',
actionBody: { actionBody: {
needNum: pobj.businessMode, needNum: pobj.businessMode,
...@@ -510,9 +510,3 @@ class SchemeCtl extends CtlBase { ...@@ -510,9 +510,3 @@ class SchemeCtl extends CtlBase {
} }
module.exports = SchemeCtl; module.exports = SchemeCtl;
// var task = new SchemeCtl();
// var obj={"businessMode":"202006100002","baseInfo":{"memoInfo":"sfdsff","whetherType":"individual","creditCode":"1223345455","companyType":"有限公司","companyName":"三个五","establishedTime":"2010-5-6","registeredCapital":"5万元","shareholderName":"2B","businessTerm":"500","businessScope":"sgrgdrgghhh","residenceAddress":"北京市"}};
// task.insertInfo(obj,{},{}).then(d=>{
// console.log(d);
// //console.log(d[0].analyse)
// })
...@@ -11,7 +11,7 @@ class OplogCtl extends CtlBase { ...@@ -11,7 +11,7 @@ class OplogCtl extends CtlBase {
async initNewInstance(qobj) { async initNewInstance(qobj) {
const u = uuidv4(); const u = uuidv4();
const aid = u.replace(/\-/g, ''); const aid = u.replace(/-/g, '');
const rd = { name: '', appid: aid }; const rd = { name: '', appid: aid };
return system.getResult(rd); return system.getResult(rd);
} }
...@@ -40,7 +40,7 @@ class OplogCtl extends CtlBase { ...@@ -40,7 +40,7 @@ class OplogCtl extends CtlBase {
返回20位业务订单号 返回20位业务订单号
prefix:业务前缀 prefix:业务前缀
*/ */
async getBusUid_Ctl(prefix) { async getBusUidCtl(prefix) {
prefix = (prefix || ''); prefix = (prefix || '');
if (prefix) { if (prefix) {
prefix = prefix.toUpperCase(); prefix = prefix.toUpperCase();
...@@ -49,7 +49,7 @@ prefix:业务前缀 ...@@ -49,7 +49,7 @@ prefix:业务前缀
const subLen = 8 - prefixlength; const subLen = 8 - prefixlength;
let uidStr = ''; let uidStr = '';
if (subLen > 0) { if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60); uidStr = await this.getUidInfoCtl(subLen, 60);
} }
const timStr = moment().format('YYYYMMDDHHmm'); const timStr = moment().format('YYYYMMDDHHmm');
return prefix + timStr + uidStr; return prefix + timStr + uidStr;
...@@ -58,7 +58,7 @@ prefix:业务前缀 ...@@ -58,7 +58,7 @@ prefix:业务前缀
len:返回长度 len:返回长度
radix:参与计算的长度,最大为62 radix:参与计算的长度,最大为62
*/ */
async getUidInfo_Ctl(len, radix) { async getUidInfoCtl(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36 const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
const uuid = []; let i; const uuid = []; let i;
radix = radix || chars.length; radix = radix || chars.length;
...@@ -66,7 +66,10 @@ prefix:业务前缀 ...@@ -66,7 +66,10 @@ prefix:业务前缀
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else { } else {
let r; let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[23] = '-';
uuid[18] = uuid[23];
uuid[13] = uuid[18];
uuid[8] = uuid[13];
uuid[14] = '4'; uuid[14] = '4';
for (i = 0; i < 36; i++) { for (i = 0; i < 36; i++) {
if (!uuid[i]) { if (!uuid[i]) {
......
...@@ -46,7 +46,7 @@ class UploadCtl extends CtlBase { ...@@ -46,7 +46,7 @@ class UploadCtl extends CtlBase {
}; };
async downfile(srckey) { async downfile(srckey) {
const oss = system.getObject('util.ossClient'); const oss = system.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => { let downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`; downfile = `/tmp/${srckey}`;
return downfile; return downfile;
}); });
......
...@@ -24,8 +24,8 @@ class VCodeCache extends CacheBase { ...@@ -24,8 +24,8 @@ class VCodeCache extends CacheBase {
const vcode = await this.smsUtil.getUidStr(6, 10); const vcode = await this.smsUtil.getUidStr(6, 10);
if (!tmplCode && !signName) { if (!tmplCode && !signName) {
this.smsUtil.sendMsg(mobile, vcode); this.smsUtil.sendMsg(mobile, vcode);
} // tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码 // tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else { } else {
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode })); this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode }));
} }
return JSON.stringify({ vcode }); return JSON.stringify({ vcode });
......
...@@ -218,7 +218,8 @@ class Dao { ...@@ -218,7 +218,8 @@ class Dao {
} }
async customQuery(sql, paras, t) { async customQuery(sql, paras, t) {
let tmpParas = null;// ||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT }; let tmpParas = null;
// ||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
if (t && t != 'undefined') { if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') { if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.SELECT }; tmpParas = { type: this.db.QueryTypes.SELECT };
......
...@@ -5,7 +5,7 @@ class RoleDao extends Dao { ...@@ -5,7 +5,7 @@ class RoleDao extends Dao {
super(Dao.getModelName(RoleDao)); super(Dao.getModelName(RoleDao));
} }
async findOne(paramappid, t) { async findOne(paramappid, t) {
const app = await this.model.findOne({ where: { appid: paramappid } }, { transaction: t }); const app = await this.model.findOne({ where: { appid: paramappid } }, { transaction: t });
return app; return app;
} }
extraWhere(obj, w, qc, linkAttrs) { extraWhere(obj, w, qc, linkAttrs) {
...@@ -38,10 +38,10 @@ class RoleDao extends Dao { ...@@ -38,10 +38,10 @@ class RoleDao extends Dao {
const self = this; const self = this;
const u2 = await this.preCreate(u); const u2 = await this.preCreate(u);
if (t) { if (t) {
var role = await this.model.create(u2, { transaction: t }); const role = await this.model.create(u2, { transaction: t });
return role; return role;
} }
var role = await this.model.create(u2); const role = await this.model.create(u2);
return role; return role;
} }
} }
......
...@@ -9,9 +9,11 @@ class UserDao extends Dao { ...@@ -9,9 +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'] },
] }, ],
},
], ],
}); });
} }
...@@ -20,17 +22,18 @@ class UserDao extends Dao { ...@@ -20,17 +22,18 @@ 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.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity", { model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]}, {
{ 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 }); },
// if(tUser!=null){ ],
// tUser=tUser.get({plain:true}); }, { transaction: t });
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true}); // if(tUser!=null){
// } // tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return tUser; return tUser;
} }
async getUserByOpenId(popenid, appkey, t) { async getUserByOpenId(popenid, appkey, t) {
...@@ -38,35 +41,35 @@ class UserDao extends Dao { ...@@ -38,35 +41,35 @@ 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.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity", { model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]}, {
{ 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) {
tUser = tUser.get({ plain: true }); tUser = tUser.get({ plain: true });
tUser.partnerinfo = await this.partnerinfoDao.model.findOne({ where: { onlyCode: tUser.onlyCode }, raw: true }); tUser.partnerinfo = await this.partnerinfoDao.model.findOne({ where: { onlyCode: tUser.onlyCode }, raw: true });
} }
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return tUser; return tUser;
} }
async setAccount(user, account, t) { async setAccount(user, account, t) {
var user = await user.setAccount(account, { transaction: t }); const user = await user.setAccount(account, { transaction: t });
return user; return user;
} }
async setApp(user, app, t) { async setApp(user, app, t) {
// 按照APPId,获取app对象 // 按照APPId,获取app对象
var user = await user.setApp(app, { transaction: t }); const user = await user.setApp(app, { transaction: t });
return user; return user;
} }
extraModelFilter() { extraModelFilter() {
// return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]}; return {
return { key: 'include', value: [ key: 'include', value: [
{ model: this.db.models.app }, { model: this.db.models.app },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }] }; { model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }],
};
} }
extraWhere(obj, w, qc, linkAttrs) { extraWhere(obj, w, qc, linkAttrs) {
if (obj.bizpath && obj.bizpath != '') { if (obj.bizpath && obj.bizpath != '') {
......
...@@ -87,7 +87,8 @@ class DbFactory { ...@@ -87,7 +87,8 @@ class DbFactory {
// pconfigObjs.forEach(p=>{ // pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true})); // console.log(p.get({plain:true}));
// }); // });
// await this.db.models.user.create({nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"}) // await this.db.models.user.create({
// nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"})
// .then(function(user){ // .then(function(user){
// var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"}); // var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"});
// acc.save().then(a=>{ // acc.save().then(a=>{
......
...@@ -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) {
var 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) {
var 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,8 @@ class AuthService extends ServiceBase { ...@@ -11,7 +11,8 @@ 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;
} }
async saveAuths(auths, appid, cmid) { async saveAuths(auths, appid, cmid) {
...@@ -20,8 +21,8 @@ class AuthService extends ServiceBase { ...@@ -20,8 +21,8 @@ class AuthService extends ServiceBase {
console.log('yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'); console.log('yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv');
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++) {
var 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({
...@@ -33,10 +34,20 @@ class AuthService extends ServiceBase { ...@@ -33,10 +34,20 @@ class AuthService extends ServiceBase {
console.log(objrtn); console.log(objrtn);
if (!objrtn[1].created) { if (!objrtn[1].created) {
// 就执行更新操作 // 就执行更新操作
await objrtn[0].update(tmpAuth, { where: { role_id: tmpAuth.role_id, bizcode: tmpAuth.bizcode }, transaction: t }); await objrtn[0].update(tmpAuth, {
where: {
role_id: tmpAuth.role_id,
bizcode: tmpAuth.bizcode,
}, transaction: t,
});
} }
} }
const aths = await self.dao.model.findAll({ where: { role_id: tmpAuth.role_id, app_id: tmpAuth.app_id }, transaction: t }); const aths = await self.dao.model.findAll({
where: {
role_id: tmpAuth.role_id,
app_id: tmpAuth.app_id,
}, transaction: t,
});
return aths; return aths;
}); });
} }
......
...@@ -11,7 +11,7 @@ class OrgService extends ServiceBase { ...@@ -11,7 +11,7 @@ class OrgService extends ServiceBase {
const uone = await this.db.models.user.findOne({ where: { org_id: orgid } }); const uone = await this.db.models.user.findOne({ where: { org_id: orgid } });
if (!uone) { if (!uone) {
// 先检查是否组织下有人员存在 // 先检查是否组织下有人员存在
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
const inst = await self.dao.model.findById(orgid); const inst = await self.dao.model.findById(orgid);
const parentid = inst.org_id; const parentid = inst.org_id;
await inst.destroy({ force: true, transaction: t }); await inst.destroy({ force: true, transaction: t });
...@@ -22,10 +22,13 @@ class OrgService extends ServiceBase { ...@@ -22,10 +22,13 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']], order: [['code', 'ASC']],
where: { id: parentid }, transaction: t, where: { id: parentid }, transaction: t,
include: [ include: [
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ {
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']] }, model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
] }, { model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']] },
] }); ],
},
],
});
return orgparent.orgs; return orgparent.orgs;
}); });
} }
...@@ -34,14 +37,14 @@ class OrgService extends ServiceBase { ...@@ -34,14 +37,14 @@ class OrgService extends ServiceBase {
async update(p, q, req) { async update(p, q, req) {
const self = this; const self = this;
const cmkey = p.comkey;// 如果是来自租户界面的修改 const cmkey = p.comkey;// 如果是来自租户界面的修改
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
p.isLeaf = p.isPosition; p.isLeaf = p.isPosition;
const orgupdate = await self.dao.model.findOne({ where: { id: p.id }, transaction: t }); const orgupdate = await self.dao.model.findOne({ where: { id: p.id }, transaction: t });
await self.dao.model.update(p, { where: { id: p.id }, transaction: t }); await self.dao.model.update(p, { where: { id: p.id }, transaction: t });
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 (var 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;
...@@ -52,7 +55,7 @@ class OrgService extends ServiceBase { ...@@ -52,7 +55,7 @@ class OrgService extends ServiceBase {
const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } }); const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } });
await orgupdate.setRoles(roles, { transaction: t }); await orgupdate.setRoles(roles, { transaction: t });
// 同时要给这个岗位下的user,更新角色 todo // 同时要给这个岗位下的user,更新角色 todo
for (var ud of usersupdate) { for (const ud of usersupdate) {
await ud.setRoles(roles, { transaction: t }); await ud.setRoles(roles, { transaction: t });
} }
} }
...@@ -60,14 +63,19 @@ class OrgService extends ServiceBase { ...@@ -60,14 +63,19 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']], order: [['code', 'ASC']],
where: { id: orgupdate.org_id }, transaction: t, where: { id: orgupdate.org_id }, transaction: t,
include: [ include: [
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ {
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{
model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
],
},
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }, ],
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, },
] },
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }); ],
});
return orgparent.orgs; return orgparent.orgs;
}); });
} }
...@@ -78,10 +86,10 @@ class OrgService extends ServiceBase { ...@@ -78,10 +86,10 @@ class OrgService extends ServiceBase {
} }
return null; return null;
} }
async changePos(toorgid, uid) { async changePos(toorgid, uid) {
// 查询出当前用户,设置当前用户的orgid为修改目标 // 查询出当前用户,设置当前用户的orgid为修改目标
const self = this; const self = this;
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
const ufind = await self.db.models.user.findById(uid); const ufind = await self.db.models.user.findById(uid);
...@@ -89,7 +97,8 @@ class OrgService extends ServiceBase { ...@@ -89,7 +97,8 @@ class OrgService extends ServiceBase {
where: { id: toorgid }, where: { id: toorgid },
include: [ include: [
{ model: self.db.models.role, as: 'roles' }, { model: self.db.models.role, as: 'roles' },
] }); ],
});
ufind.org_id = toorgid; ufind.org_id = toorgid;
ufind.opath = org.orgpath; ufind.opath = org.orgpath;
if (org.isMain) { // 如果是主岗 if (org.isMain) { // 如果是主岗
...@@ -110,9 +119,9 @@ class OrgService extends ServiceBase { ...@@ -110,9 +119,9 @@ class OrgService extends ServiceBase {
const self = this; const self = this;
const cmkey = p.comkey; const cmkey = p.comkey;
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
if (cmkey) { if (cmkey) {
const tmpcompany = await self.db.models.company.findOne({ where: { companykey: cmkey }, transaction: t }); const tmpcompany = await self.db.models.company.findOne({ where: { companykey: cmkey }, transaction: t });
p.company_id = tmpcompany.id; p.company_id = tmpcompany.id;
} }
const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } }); const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } });
...@@ -126,15 +135,20 @@ class OrgService extends ServiceBase { ...@@ -126,15 +135,20 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']], order: [['code', 'ASC']],
where: { id: orgnew.org_id }, transaction: t, where: { id: orgnew.org_id }, transaction: t,
include: [ include: [
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ {
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{
model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
],
},
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }, ],
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, },
] },
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }); ],
});
return orgparent.orgs; return orgparent.orgs;
}); });
} }
...@@ -143,32 +157,42 @@ class OrgService extends ServiceBase { ...@@ -143,32 +157,42 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']], order: [['code', 'ASC']],
where: { id }, where: { id },
include: [ include: [
{ model: this.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ {
{ model: this.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ model: this.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{
model: this.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{ model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
],
},
{ model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }, ],
{ model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, },
] },
{ model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: this.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }); ],
});
return org.orgs; return org.orgs;
} }
async initOrgs(company, appid) { async initOrgs(company, appid) {
const self = this; const self = this;
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
const org = await self.dao.model.findOne({ const org = await self.dao.model.findOne({
order: [['code', 'ASC']], order: [['code', 'ASC']],
// where:{name:company.name,company_id:company.id,app_id:appid},transaction:t, // where:{name:company.name,company_id:company.id,app_id:appid},transaction:t,
where: { name: company.name, company_id: company.id }, transaction: t, where: { name: company.name, company_id: company.id }, transaction: t,
include: [ include: [
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ {
{ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [ model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{
model: self.db.models.org, as: 'orgs', order: [['code', 'ASC']], include: [
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
],
},
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }, ],
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, },
] },
{ model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] }, { model: self.db.models.role, as: 'roles', attributes: ['id', 'code', 'name'] },
] }); ],
});
if (org != null) { if (org != null) {
return org; return org;
} }
......
...@@ -60,7 +60,12 @@ class UserService extends ServiceBase { ...@@ -60,7 +60,12 @@ class UserService extends ServiceBase {
// 设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo // 设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo
// 如果是非租户,那么按照当前应用ID是找不到指定的角色,所以是空的 // 如果是非租户,那么按照当前应用ID是找不到指定的角色,所以是空的
const roles = await self.roleDao.model.findAll({ where: { id: { [self.db.Op.in]: rolecodes }, app_id: roleappid, company_id: p.company_id }, transaction: t }); const roles = await self.roleDao.model.findAll({
where: {
id: { [self.db.Op.in]: rolecodes },
app_id: roleappid, company_id: p.company_id,
}, transaction: t,
});
if (roles && roles.length > 0) { if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t }); await u.setRoles(roles, { transaction: t });
} }
...@@ -180,7 +185,13 @@ class UserService extends ServiceBase { ...@@ -180,7 +185,13 @@ class UserService extends ServiceBase {
return rtn; return rtn;
} }
// 先按照用户名查续身份信息,获取key,secret, // 先按照用户名查续身份信息,获取key,secret,
const regrtn = await this.pmregister({ userName: mobile, nickName: mobile, rolecodes: p.rolecodes, company_id: p.company_id, app_id: p.app_id }); const regrtn = await this.pmregister({
userName: mobile,
nickName: mobile,
rolecodes: p.rolecodes,
company_id: p.company_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;
// rtn.user = u; // rtn.user = u;
......
...@@ -79,7 +79,10 @@ class DeliverybillService extends ServiceBase { ...@@ -79,7 +79,10 @@ class DeliverybillService extends ServiceBase {
if (deliverData.delivery_status !== system.SERVERSESTATUS.INSERVICE) { if (deliverData.delivery_status !== system.SERVERSESTATUS.INSERVICE) {
throw new Error('该状态下不可建账'); throw new Error('该状态下不可建账');
} }
if (deliverData.delivery_info.setupStatus && deliverData.delivery_info.setupStatus === system.SERVERSESTATUS.SETUP) { if (
deliverData.delivery_info.setupStatus
&& deliverData.delivery_info.setupStatus === system.SERVERSESTATUS.SETUP
) {
throw new Error('已建账'); throw new Error('已建账');
} }
// 通知 财税 // 通知 财税
...@@ -135,7 +138,8 @@ class DeliverybillService extends ServiceBase { ...@@ -135,7 +138,8 @@ class DeliverybillService extends ServiceBase {
setupStatus: deliverData.delivery_info.setupStatus || System.SERVERSESTATUS.NOTSETUP, // 建账状态 notsetup | setup setupStatus: deliverData.delivery_info.setupStatus || System.SERVERSESTATUS.NOTSETUP, // 建账状态 notsetup | setup
createdAt: deliverData.created_at, createdAt: deliverData.created_at,
updatedAt: deliverData.updated_at, updatedAt: deliverData.updated_at,
accountingType: (deliverData.delivery_info.setupInfo && deliverData.delivery_info.setupInfo.accountingType) || null, // 会计准侧 accountingType: (deliverData.delivery_info.setupInfo
&& deliverData.delivery_info.setupInfo.accountingType) || null, // 会计准侧
}; };
if (deliverData.scheme_number) { if (deliverData.scheme_number) {
const schemeData = await this.fitaxschemeDao.findOne({ const schemeData = await this.fitaxschemeDao.findOne({
......
...@@ -14,7 +14,7 @@ class AppService extends ServiceBase { ...@@ -14,7 +14,7 @@ class AppService extends ServiceBase {
const app = this.cacheManager.AppCache.cache(p.appkey, null); const app = this.cacheManager.AppCache.cache(p.appkey, null);
return app; return app;
} }
async upFrontRoute(jsonObject, app_id) { async upFrontRoute(jsonObject, appId) {
const self = this; const self = this;
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
const keyfile = `${self.getUUID()}.json`; const keyfile = `${self.getUUID()}.json`;
...@@ -23,7 +23,7 @@ class AppService extends ServiceBase { ...@@ -23,7 +23,7 @@ class AppService extends ServiceBase {
fs.writeFileSync(tmpdirfile, str); fs.writeFileSync(tmpdirfile, str);
const result = await self.ossC.upfile(keyfile, tmpdirfile); const result = await self.ossC.upfile(keyfile, tmpdirfile);
fs.unlinkSync(tmpdirfile); fs.unlinkSync(tmpdirfile);
await self.db.models.app.update({ docUrl: result.url, id: app_id }, { where: { id: app_id }, transaction: t }); await self.db.models.app.update({ docUrl: result.url, id: appId }, { where: { id: appId }, transaction: t });
return result; return result;
}); });
} }
......
...@@ -10,7 +10,7 @@ class CachSearchesSve { ...@@ -10,7 +10,7 @@ class CachSearchesSve {
} }
getUUID() { getUUID() {
const uuid = uuidv4(); const uuid = uuidv4();
const u = uuid.replace(/\-/g, ''); const u = uuid.replace(/-/g, '');
return u; return u;
} }
async buildCacheRtn(pageValues) { async buildCacheRtn(pageValues) {
...@@ -27,24 +27,24 @@ class CachSearchesSve { ...@@ -27,24 +27,24 @@ class CachSearchesSve {
const { pageSize } = obj.pageInfo; const { pageSize } = obj.pageInfo;
const limit = pageSize; const limit = pageSize;
const offset = (pageNo - 1) * pageSize; const offset = (pageNo - 1) * pageSize;
const search_name = obj.search && obj.search.name ? obj.search.name : ''; const searchName = obj.search && obj.search.name ? obj.search.name : '';
const cacheCacheKeyPrefix = `sadd_base_appkeys:${settings.appKey}_cachekey`; const cacheCacheKeyPrefix = `sadd_base_appkeys:${settings.appKey}_cachekey`;
if (obj.appid == settings.platformid) { if (obj.appid == settings.platformid) {
let cacheList = await this.cacheManager.MagCache.getCacheSmembersByKey(cacheCacheKeyPrefix); let cacheList = await this.cacheManager.MagCache.getCacheSmembersByKey(cacheCacheKeyPrefix);
if (search_name) { if (searchName) {
cacheList = cacheList.filter(f => f.indexOf(search_name) >= 0); cacheList = cacheList.filter(f => f.indexOf(searchName) >= 0);
} }
const pageValues = cacheList.slice(offset, offset + limit); const pageValues = cacheList.slice(offset, offset + limit);
const kobjs = await this.buildCacheRtn(pageValues); const kobjs = await this.buildCacheRtn(pageValues);
var tmpList = { results: { rows: kobjs, count: cacheList.length } }; const tmpList = { results: { rows: kobjs, count: cacheList.length } };
return system.getResult(tmpList); return system.getResult(tmpList);
} }
const body = { const body = {
pageInfo: obj.pageInfo, pageInfo: obj.pageInfo,
search: obj.search, search: obj.search,
}; };
var tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl); const tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl);
return tmpList; return tmpList;
} }
async delCache(obj) { async delCache(obj) {
...@@ -75,17 +75,17 @@ class CachSearchesSve { ...@@ -75,17 +75,17 @@ class CachSearchesSve {
const apicallAccu = await this.cacheManager.ApiAccuCache.getApiCallAccu(obj); const apicallAccu = await this.cacheManager.ApiAccuCache.getApiCallAccu(obj);
const result = { rows: [], count: 0 }; const result = { rows: [], count: 0 };
const keys = await this.cacheManager.MagCache.keys(`api_call_${appkey}*`); const keys = await this.cacheManager.MagCache.keys(`api_call_${appkey}*`);
var detail = null; let detail = null;
for (let j = 0; j < keys.length; j++) { for (let j = 0; j < keys.length; j++) {
const d = keys[j]; const d = keys[j];
const pathdetail = d.substr(d.lastIndexOf('_') + 1, d.length); const pathdetail = d.substr(d.lastIndexOf('_') + 1, d.length);
const apicalldetailAccu = await this.cacheManager.ApiCallCountCache.getApiCallCount(appkey, pathdetail); const apicalldetailAccu = await this.cacheManager.ApiCallCountCache.getApiCallCount(appkey, pathdetail);
var detail = { detailPath: d, detailCount: apicalldetailAccu.callcount }; detail = { detailPath: d, detailCount: apicalldetailAccu.callcount };
} }
result.rows = detail; result.rows = detail;
} }
// 操作别的应用的缓存 // 操作别的应用的缓存
async opOtherAppCache(action_type, body = null, opCacheUrl) { async opOtherAppCache(actionType, body = null, opCacheUrl) {
const appData = await this.authUtils.getTokenInfo(settings.appKey, settings.secret); const appData = await this.authUtils.getTokenInfo(settings.appKey, settings.secret);
if (appData.status != 0) { if (appData.status != 0) {
return appData; return appData;
...@@ -94,7 +94,7 @@ class CachSearchesSve { ...@@ -94,7 +94,7 @@ class CachSearchesSve {
const restS = await system.getObject('util.restClient'); const restS = await system.getObject('util.restClient');
const restResult = await restS.execPostWithAK( const restResult = await restS.execPostWithAK(
{ {
action_type, action_type: actionType,
body, body,
}, },
opCacheUrl, appData.data.accessKey, opCacheUrl, appData.data.accessKey,
......
...@@ -21,7 +21,13 @@ class CompanyService extends ServiceBase { ...@@ -21,7 +21,13 @@ class CompanyService extends ServiceBase {
const us = await self.db.models.user.findAll({ where: { opath: opathstr }, transaction: t }); const us = await self.db.models.user.findAll({ where: { opath: opathstr }, transaction: t });
// 查询出角色 // 查询出角色
const roleids = curNodeData.roles; const roleids = curNodeData.roles;
const rs = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: roleids }, app_id: p.app_id, company_id: p.company_id }, transaction: t }); const rs = await self.db.models.role.findAll({
where: {
id: {
[self.db.Op.in]: roleids,
}, app_id: p.app_id, company_id: p.company_id,
}, transaction: t,
});
for (const u of us) { for (const u of us) {
await u.setRoles(rs, { transaction: t }); await u.setRoles(rs, { transaction: t });
} }
......
...@@ -16,7 +16,15 @@ class RouteService extends ServiceBase { ...@@ -16,7 +16,15 @@ class RouteService extends ServiceBase {
let rtn = null; let rtn = null;
try { try {
// 添加路由 // 添加路由
const routeobj = await self.cjsonregister(RouteService.newRouteUrl(serviceName), { name: routedata.name, hosts: routedata.hosts, paths: routedata.paths, strip_path: routedata.isstrip }); const routeobj = await self.cjsonregister(
RouteService.newRouteUrl(serviceName),
{
name: routedata.name,
hosts: routedata.hosts,
paths: routedata.paths,
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) {
......
...@@ -20,12 +20,12 @@ class MsgHistoryService extends ServiceBase { ...@@ -20,12 +20,12 @@ class MsgHistoryService extends ServiceBase {
return msg; return msg;
} }
async pushBusinessLicenseMsg(senderId, targetId, businessLicense_id) { async pushBusinessLicenseMsg(senderId, targetId, businessLicenseId) {
if (!businessLicense_id) { if (!businessLicenseId) {
return 0; return 0;
} }
const notice = await this.msgnoticeDao.findOne({ fromId: senderId, toId: targetId }); const notice = await this.msgnoticeDao.findOne({ fromId: senderId, toId: targetId });
if (notice && notice.businessLicense_id == businessLicense_id) { if (notice && notice.businessLicense_id == businessLicenseId) {
return 0; return 0;
} }
......
...@@ -28,7 +28,7 @@ class MsgNoticeService extends ServiceBase { ...@@ -28,7 +28,7 @@ class MsgNoticeService extends ServiceBase {
const msgIds = []; const msgIds = [];
const businessLicenseIds = []; const businessLicenseIds = [];
const userIds = []; const userIds = [];
for (var item of list) { for (const item of list) {
msgIds.push(item.lastMsgId); msgIds.push(item.lastMsgId);
businessLicenseIds.push(item.businessLicense_id); businessLicenseIds.push(item.businessLicense_id);
userIds.push(item.toId); userIds.push(item.toId);
...@@ -51,7 +51,7 @@ class MsgNoticeService extends ServiceBase { ...@@ -51,7 +51,7 @@ class MsgNoticeService extends ServiceBase {
const licenseList = await this.businesslicenseDao.customQuery(`SELECT * FROM yz_business_license WHERE id IN (${businessLicenseIds.join(',')}) `); const licenseList = await this.businesslicenseDao.customQuery(`SELECT * FROM yz_business_license WHERE id IN (${businessLicenseIds.join(',')}) `);
const serviceTypeIds = []; const serviceTypeIds = [];
for (var item of licenseList) { for (const item of licenseList) {
serviceTypeIds.push(item.serviceTypeOneId); serviceTypeIds.push(item.serviceTypeOneId);
serviceTypeIds.push(item.serviceTypeTwoId); serviceTypeIds.push(item.serviceTypeTwoId);
} }
...@@ -60,7 +60,7 @@ class MsgNoticeService extends ServiceBase { ...@@ -60,7 +60,7 @@ class MsgNoticeService extends ServiceBase {
const sql = `SELECT id, name FROM \`p_service_type\` WHERE id IN (${serviceTypeIds.join(',')}) `; const sql = `SELECT id, name FROM \`p_service_type\` WHERE id IN (${serviceTypeIds.join(',')}) `;
const typeList = await this.dao.customQuery(sql); const typeList = await this.dao.customQuery(sql);
var typeMap = []; const typeMap = [];
if (typeList && typeList.length > 0) { if (typeList && typeList.length > 0) {
for (const t of typeList) { for (const t of typeList) {
typeMap[`type_id_${t.id}`] = t.name; typeMap[`type_id_${t.id}`] = t.name;
...@@ -68,12 +68,12 @@ class MsgNoticeService extends ServiceBase { ...@@ -68,12 +68,12 @@ class MsgNoticeService extends ServiceBase {
item.serviceTypeOneName = t.name; item.serviceTypeOneName = t.name;
} else if (t.id == item.serviceTypeTwoId) { } else if (t.id == item.serviceTypeTwoId) {
item.serviceTypeTwoName = t.name; item.serviceTypeTwoName = t.name;
} else {} } else { }
} }
} }
} }
for (var item of licenseList) { for (const item of licenseList) {
item.serviceTypeOneName = typeMap[`type_id_${item.serviceTypeOneId}`]; item.serviceTypeOneName = typeMap[`type_id_${item.serviceTypeOneId}`];
item.serviceTypeTwoName = typeMap[`type_id_${item.serviceTypeTwoId}`]; item.serviceTypeTwoName = typeMap[`type_id_${item.serviceTypeTwoId}`];
} }
...@@ -98,7 +98,7 @@ class MsgNoticeService extends ServiceBase { ...@@ -98,7 +98,7 @@ class MsgNoticeService extends ServiceBase {
const rs = []; const rs = [];
for (const i in list) { for (const i in list) {
var item = list[i]; const item = list[i];
item.lastMsg = msgMap[`id${item.lastMsgId}`]; item.lastMsg = msgMap[`id${item.lastMsgId}`];
item.businessLicense = businessLicenseMap[`id${item.businessLicense_id}`]; item.businessLicense = businessLicenseMap[`id${item.businessLicense_id}`];
item.friend = userMap[`id${item.toId}`]; item.friend = userMap[`id${item.toId}`];
......
...@@ -22,7 +22,7 @@ class ServiceBase { ...@@ -22,7 +22,7 @@ class ServiceBase {
} }
getUUID() { getUUID() {
const uuid = uuidv4(); const uuid = uuidv4();
const u = uuid.replace(/\-/g, ''); const u = uuid.replace(/-/g, '');
return u; return u;
} }
static getDaoName(ClassObj) { static getDaoName(ClassObj) {
...@@ -79,7 +79,7 @@ class ServiceBase { ...@@ -79,7 +79,7 @@ class ServiceBase {
返回20位业务订单号 返回20位业务订单号
prefix:业务前缀 prefix:业务前缀
*/ */
async getBusUid(prefix) { async getBusUid(prefix) {
prefix = (prefix || ''); prefix = (prefix || '');
if (prefix) { if (prefix) {
prefix = prefix.toUpperCase(); prefix = prefix.toUpperCase();
...@@ -97,7 +97,7 @@ class ServiceBase { ...@@ -97,7 +97,7 @@ class ServiceBase {
len:返回长度 len:返回长度
radix:参与计算的长度,最大为62 radix:参与计算的长度,最大为62
*/ */
async getUidInfo(len, radix) { async getUidInfo(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36 const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
const uuid = []; let i; const uuid = []; let i;
radix = radix || chars.length; radix = radix || chars.length;
...@@ -105,7 +105,10 @@ class ServiceBase { ...@@ -105,7 +105,10 @@ class ServiceBase {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else { } else {
let r; let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[23] = '-';
uuid[18] = uuid[23];
uuid[13] = uuid[18];
uuid[8] = uuid[13];
uuid[14] = '4'; uuid[14] = '4';
for (i = 0; i < 36; i++) { for (i = 0; i < 36; i++) {
if (!uuid[i]) { if (!uuid[i]) {
...@@ -132,7 +135,7 @@ class ServiceBase { ...@@ -132,7 +135,7 @@ class ServiceBase {
throw new Error(rtn.data); throw new Error(rtn.data);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return null; return null;
} }
} }
async cget(opurl) { async cget(opurl) {
...@@ -155,7 +158,7 @@ class ServiceBase { ...@@ -155,7 +158,7 @@ class ServiceBase {
return null; return null;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return null; return null;
} }
} }
async cdel(opurl) { async cdel(opurl) {
...@@ -167,7 +170,7 @@ class ServiceBase { ...@@ -167,7 +170,7 @@ class ServiceBase {
throw new Error(rtn.data); throw new Error(rtn.data);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return null; return null;
} }
} }
static bindPluginUrl(rname) { static bindPluginUrl(rname) {
......
...@@ -245,7 +245,7 @@ class System { ...@@ -245,7 +245,7 @@ class System {
const configValue = require(configPath); const configValue = require(configPath);
return configValue.config; return configValue.config;
} }
static get_client_ip(req) { static getClientIp(req) {
const ip = req.headers['x-forwarded-for'] const ip = req.headers['x-forwarded-for']
|| req.ip || req.ip
|| req.connection.remoteAddress || req.connection.remoteAddress
......
...@@ -7,7 +7,7 @@ class AuthUtils { ...@@ -7,7 +7,7 @@ class AuthUtils {
} }
getUUID() { getUUID() {
const uuid = uuidv4(); const uuid = uuidv4();
const u = uuid.replace(/\-/g, ''); const u = uuid.replace(/-/g, '');
return u; return u;
} }
/** /**
......
...@@ -49,8 +49,8 @@ class ExcelClient { ...@@ -49,8 +49,8 @@ class ExcelClient {
wb.xlsx.writeFile(filePath).then(async (d) => { wb.xlsx.writeFile(filePath).then(async (d) => {
const rtn = await self.ossClient.upfile(fileName, filePath); const rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath, (err) => {}); fs.unlink(filePath, (err) => { });
var obj = { let obj = {
user_id: user.id || 0, user_id: user.id || 0,
userName: user.userName || '', userName: user.userName || '',
code, code,
...@@ -58,7 +58,7 @@ class ExcelClient { ...@@ -58,7 +58,7 @@ class ExcelClient {
filePath: rtn.url || '', filePath: rtn.url || '',
isDownload: false, isDownload: false,
}; };
var obj = await self.filedownloadDao.create(obj); obj = await self.filedownloadDao.create(obj);
}); });
} }
} }
......
...@@ -7,7 +7,7 @@ class LogClient { ...@@ -7,7 +7,7 @@ class LogClient {
} }
getUUID() { getUUID() {
const uuid = uuidv4(); const uuid = uuidv4();
const u = uuid.replace(/\-/g, ''); const u = uuid.replace(/-/g, '');
return u; return u;
} }
async log(pobj, req, rtninfo, errinfo) { async log(pobj, req, rtninfo, errinfo) {
......
...@@ -88,7 +88,7 @@ class RedisClient { ...@@ -88,7 +88,7 @@ class RedisClient {
} }
if (self.chatserver) { if (self.chatserver) {
if (channel != 'task') { if (channel != 'task') {
var message = JSON.parse(message); const message = JSON.parse(message);
console.log(message, '------------------------------------------ publish message'); console.log(message, '------------------------------------------ publish message');
if (channel == 'brc') { // 如果是广播频道,则发送广播到客户端 if (channel == 'brc') { // 如果是广播频道,则发送广播到客户端
self.chatserver.server.emit('brc', message); self.chatserver.server.emit('brc', message);
...@@ -248,7 +248,8 @@ module.exports = RedisClient; ...@@ -248,7 +248,8 @@ module.exports = RedisClient;
// client.sismember("h","ok").then(function(r){ // client.sismember("h","ok").then(function(r){
// console.log(r); // console.log(r);
// }); // });
// console.dir(client);ti.exec( callback )回调函数参数err:返回null或者Array,出错则返回对应命令序列链中发生错误的错误信息,这个数组中最后一个元素是源自exec本身的一个EXECABORT类型的错误 // console.dir(client);ti.exec( callback )
// 回调函数参数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);
// }); // });
......
...@@ -10,55 +10,50 @@ class RestClient { ...@@ -10,55 +10,50 @@ class RestClient {
this.cmdDownLoadFilePattern = 'curl -G -o {fileName} {url}'; this.cmdDownLoadFilePattern = 'curl -G -o {fileName} {url}';
this.cmdPostPattern2 = 'curl -k -H \'Content-type: application/x-www-form-urlencoded\' -d \'{data}\' {url}'; this.cmdPostPattern2 = 'curl -k -H \'Content-type: application/x-www-form-urlencoded\' -d \'{data}\' {url}';
this.cmdPostPatternWithAK = 'curl -k -H \'Content-type: application/json\' -H \'AccessKey:{ak}\' -d \'{data}\' {url}'; this.cmdPostPatternWithAK = 'curl -k -H \'Content-type: application/json\' -H \'AccessKey:{ak}\' -d \'{data}\' {url}';
// 云帐户
// this.cmdPostPattern3="curl -k -H 'Content-type: application/x-www-form-urlencoded' -H 'dealer-id:"+settings.apiconfig.yunzhanghuDealer_id()+"' -H 'request-id:"+parseInt(Date.now() / 1000)+"_gsb"+"' -d '{data}' {url}";
// this.cmdGetPattern3 = "curl {-G} -k {url} --header 'dealer-id:"+settings.apiconfig.yunzhanghuDealer_id()+"'";
// e签宝
// this.cmdPostPattern4="curl -k -H 'Content-type: application/json' -H 'X-Tsign-Open-App-Id:"+settings.apiconfig.eSignBaoAppId()+"' -H 'X-Tsign-Open-App-Secret:"+settings.apiconfig.eSignBaoAppKey()+"' -d '{data}' {url}";
// form-data形式post data参数类型 md5=2&data=1 // form-data形式post data参数类型 md5=2&data=1
this.cmdPostPattern5 = 'curl -k --data \'{data}\' {url}'; this.cmdPostPattern5 = 'curl -k --data \'{data}\' {url}';
} }
FetchGetCmd(subData, url) { FetchGetCmd(subData, url) {
const cmd = this.cmdGetPattern.replace(/\{\-G\}/g, '-G').replace(/\{data\}/g, subData) const cmd = this.cmdGetPattern.replace(/\{-G\}/g, '-G').replace(/\{data\}/g, subData)
.replace(/\{url\}/g, url); .replace(/\{url\}/g, url);
return cmd; return cmd;
} }
FetchPostCmd(subData, url) { FetchPostCmd(subData, url) {
const data = JSON.stringify(subData); const data = JSON.stringify(subData);
const cmd = this.cmdPostPattern.replace( const cmd = this.cmdPostPattern.replace(
/\{data\}/g, /\{data\}/g,
data, data,
).replace(/\{url\}/g, url); ).replace(/\{url\}/g, url);
return cmd; return cmd;
} }
FetchPostCmdWithAK(subData, url, acck) { FetchPostCmdWithAK(subData, url, acck) {
const data = JSON.stringify(subData); const data = JSON.stringify(subData);
const cmd = this.cmdPostPatternWithAK.replace( const cmd = this.cmdPostPatternWithAK.replace(
/\{data\}/g, /\{data\}/g,
data, data,
).replace(/\{url\}/g, url) ).replace(/\{url\}/g, url)
.replace(/\{ak\}/g, acck); .replace(/\{ak\}/g, acck);
return cmd; return cmd;
} }
FetchPostCmd2(subData, url) { FetchPostCmd2(subData, url) {
const data = subData; const data = subData;
const cmd = this.cmdPostPattern2.replace( const cmd = this.cmdPostPattern2.replace(
/\{data\}/g, /\{data\}/g,
data, data,
).replace(/\{url\}/g, url); ).replace(/\{url\}/g, url);
return cmd; return cmd;
} }
FetchPostCmd3(subData, url) { FetchPostCmd3(subData, url) {
const data = subData; const data = subData;
const cmd = this.cmdPostPattern3.replace( const cmd = this.cmdPostPattern3.replace(
/\{data\}/g, /\{data\}/g,
data, data,
).replace(/\{url\}/g, url); ).replace(/\{url\}/g, url);
return cmd; return cmd;
} }
FetchGetCmd3(url) { FetchGetCmd3(url) {
const cmd = this.cmdGetPattern3.replace(/\{\-G\}/g, '-G').replace(/\{url\}/g, url); const cmd = this.cmdGetPattern3.replace(/\{-G\}/g, '-G').replace(/\{url\}/g, url);
return cmd; return cmd;
} }
FetchPostCmd4(subData, url) { FetchPostCmd4(subData, url) {
...@@ -78,10 +73,10 @@ class RestClient { ...@@ -78,10 +73,10 @@ class RestClient {
return cmd; return cmd;
} }
FetchDownLoadCmd(outfname, url) { FetchDownLoadCmd(outfname, url) {
// console.log(this.cmdPattern); // console.log(this.cmdPattern);
const cmd = this.cmdDownLoadFilePattern.replace(/\{fileName\}/g, outfname).replace(/\{url\}/g, url); const cmd = this.cmdDownLoadFilePattern.replace(/\{fileName\}/g, outfname).replace(/\{url\}/g, url);
return cmd; return cmd;
} }
async exec(cmd) { async exec(cmd) {
// await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值 // await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
// 异常需要try/catch自己捕获或外部catch捕获 // 异常需要try/catch自己捕获或外部catch捕获
......
...@@ -38,7 +38,7 @@ class SmsClient { ...@@ -38,7 +38,7 @@ class SmsClient {
}; };
return this.restClient.execPost(txtObj, this.smsTeml); return this.restClient.execPost(txtObj, this.smsTeml);
} }
async getUidStr(len, radix) { async getUidStr(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
const uuid = []; let i; const uuid = []; let i;
radix = radix || chars.length; radix = radix || chars.length;
...@@ -46,7 +46,10 @@ class SmsClient { ...@@ -46,7 +46,10 @@ class SmsClient {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else { } else {
let r; let r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[23] = '-';
uuid[18] = uuid[23];
uuid[13] = uuid[18];
uuid[8] = uuid[13];
uuid[14] = '4'; uuid[14] = '4';
for (i = 0; i < 36; i++) { for (i = 0; i < 36; i++) {
if (!uuid[i]) { if (!uuid[i]) {
......
...@@ -370,7 +370,7 @@ const paperPostConfirmToRys = async (bizId, data) => { ...@@ -370,7 +370,7 @@ const paperPostConfirmToRys = async (bizId, data) => {
} }
}; };
const buildDoubleNumber = data => data && Number(data) || 0.00; const buildDoubleNumber = data => ((data && Number(data)) || 0.00);
/** /**
* 构建 余额表数据 * 构建 余额表数据
......
...@@ -7,7 +7,7 @@ module.exports = function (app) { ...@@ -7,7 +7,7 @@ module.exports = function (app) {
const methodName = req.params.method; const methodName = req.params.method;
const { gname } = req.params; const { gname } = req.params;
classPath = `${gname}.${classPath}`; classPath = `${gname}.${classPath}`;
const tClientIp = System.get_client_ip(req); const tClientIp = System.getClientIp(req);
req.clientIp = tClientIp; req.clientIp = tClientIp;
req.uagent = req.headers['user-agent']; req.uagent = req.headers['user-agent'];
// req.classname=classPath; // req.classname=classPath;
...@@ -35,7 +35,7 @@ module.exports = function (app) { ...@@ -35,7 +35,7 @@ module.exports = function (app) {
classPath = `${gname}.${classPath}`; classPath = `${gname}.${classPath}`;
console.log('===================='); console.log('====================');
console.log(classPath); console.log(classPath);
const tClientIp = System.get_client_ip(req); const tClientIp = System.getClientIp(req);
req.clientIp = tClientIp; req.clientIp = tClientIp;
req.uagent = req.headers['user-agent']; req.uagent = req.headers['user-agent'];
// req.classname=classPath; // req.classname=classPath;
......
...@@ -28,7 +28,7 @@ module.exports = function (app) { ...@@ -28,7 +28,7 @@ module.exports = function (app) {
const { gname } = req.params; const { gname } = req.params;
const params = []; const params = [];
classPath = `${gname}.${classPath}`; classPath = `${gname}.${classPath}`;
const tClientIp = system.get_client_ip(req); const tClientIp = system.getClientIp(req);
req.body.clientIp = tClientIp; req.body.clientIp = tClientIp;
req.body.agent = req.headers['user-agent']; req.body.agent = req.headers['user-agent'];
req.body.classname = classPath; req.body.classname = classPath;
......
const fs = require('fs'); const fs = require('fs');
// function to encode file data to base64 encoded string // function to encode file data to base64 encoded string
function base64_encode(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
...@@ -10,8 +10,9 @@ function base64_encode(file) { ...@@ -10,8 +10,9 @@ function base64_encode(file) {
} }
// function to create file from base64 encoded string // function to create file from base64 encoded string
function base64_decode(base64str, file) { function base64Decode(base64str, file) {
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded // create buffer object from base64 encoded string,
// it is important to tell the constructor that the string is base64 encoded
const bitmap = new Buffer(base64str, 'base64'); const bitmap = new Buffer(base64str, 'base64');
// write buffer to file // write buffer to file
fs.writeFileSync(file, bitmap); fs.writeFileSync(file, bitmap);
...@@ -19,7 +20,7 @@ function base64_decode(base64str, file) { ...@@ -19,7 +20,7 @@ function base64_decode(base64str, file) {
} }
function getDataUrl(filepath) { function getDataUrl(filepath) {
const str = base64_encode(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';
......
var gulp = require('gulp');
var fs = require("fs");
var tap = require('gulp-tap');
var minimist = require('minimist');
var merge = require('merge-stream');
var rename = require('gulp-rename');
var del = require("del");
var concat = require('gulp-concat');
var gulpif=require("gulp-if");
var knownOptions = {
string: 'name',
string: 'bizfile',
default: { name: process.env.NODE_ENV || 'Test' }
};
var options = minimist(process.argv.slice(2), knownOptions);
var name = options.name;
var 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/*");
var tmpName = name.toLowerCase();
var fstream = gulp.src("./extra/build/*.js")
.pipe(tap(function (file) {
var sfile = file.contents.toString('utf-8');
var 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;
// var pageStream=gulp.src("./extra/build/page/**/*").pipe(
// gulp.dest("./extra/dest")
// );
// return merge(fstream, pageStream);
});
gulp.task('page', function (cbk) {
var 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) {
var sfile = file.contents.toString();
var 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) {
var 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) {
var 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) {
var 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) {
var 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();
});
var 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/"));
});
var 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
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