Commit f6936e38 by Sxy

fix: 代码规范

parent c744c92c
......@@ -42,7 +42,7 @@ class OSSAPI extends APIBase {
};
async downfile(srckey) {
const oss = System.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => {
let downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`;
return downfile;
});
......
......@@ -30,7 +30,10 @@ class DeliverybillCtl extends CtlBase {
const rs = await this.service.findAndCountAll(pobj);
const result = [];
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({
deliveryId: id, // id
deliveryNumber: delivery_code, // 交付单编号
......@@ -99,7 +102,11 @@ class DeliverybillCtl extends CtlBase {
if (!pobj.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('参数不能为空');
}
const rs = await this.service.setupBill(pobj);
......@@ -391,7 +398,7 @@ class DeliverybillCtl extends CtlBase {
customerId: deliverInfo.deliveryBillInfo.vftClientId, // 客户信息(帐套)
sign: '', // 签名
postWay: '2',
currentPeriod: pobj.actionBody.accountDate.replace(/\-/g, ''),
currentPeriod: pobj.actionBody.accountDate.replace(/-/g, ''),
courierNumber: pobj.actionBody.expressNum,
};
const result = await toFtClient.postToFtBySign('/customerReceiveBill/addCusReceiveBill', param);
......
......@@ -41,21 +41,21 @@ class SchemeCtl extends CtlBase {
rarr.servicerName = rs.facilitator_name;// 服务商名称
rarr.clerkName = rs.salesman_name;// 业务员名称
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);// 当前状态的日期
const baseInfo = {};
if (rs.scheme_info.companyName && rs.scheme_info.companyName != 'undefined') { // 公司名称
rarr.companyName = rs.scheme_info.companyName;
}
if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册'
|| rarr.businessName == '税控申请' || rarr.businessName == '代理记账') {
|| rarr.businessName == '税控申请' || rarr.businessName == '代理记账') {
baseInfo.taxpayerType = rs.scheme_info.taxpayerType;
}
if (rarr.businessName == '园区注册') {
baseInfo.registeredType = rs.scheme_info.registeredType;
}
if (rarr.businessName == '公司注册' || rarr.businessName == '园区注册') {
baseInfo.companyProperties = rs.scheme_info.companyProperties;
baseInfo.companyProperties = rs.scheme_info.companyProperties;
baseInfo.engagedIndustry = rs.scheme_info.engagedIndustry;
baseInfo.addressType = rs.scheme_info.addressType;
baseInfo.fullAddress = rs.scheme_info.fullAddress;
......@@ -123,7 +123,7 @@ class SchemeCtl extends CtlBase {
rarr.clerkId = rs.salesman_id;// 业务员id;
rarr.clerkName = rs.salesman_name;// 业务员名称
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.baseInfo = rs.scheme_info;
}
......@@ -288,13 +288,13 @@ class SchemeCtl extends CtlBase {
}
// 修改方案的时候,需要把修改的方案传给商城
const ttype = pobj.businessType;
const ttype = pobj.businessType;
console.log(`ttype:${ttype}`);
pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
console.log(`businessType:${pobj.businessType}`);
const rc = system.getObject('util.execClient');
const requrl = this.receiveUrl;
const params = {
const params = {
actionType: 'submitSolution',
actionBody: {
needNum: pobj.businessMode,
......@@ -453,12 +453,12 @@ class SchemeCtl extends CtlBase {
}
// 调商城的接口,把商机详情返回给商城
const btype = pobj.businessType;
const btype = pobj.businessType;
pobj.businessType = appconfig.pdict.fdyDict[pobj.businessType];
const rc = system.getObject('util.execClient');
const requrl = this.receiveUrl;
const params = {
const params = {
actionType: 'submitSolution',
actionBody: {
needNum: pobj.businessMode,
......@@ -510,9 +510,3 @@ class SchemeCtl extends CtlBase {
}
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 {
async initNewInstance(qobj) {
const u = uuidv4();
const aid = u.replace(/\-/g, '');
const aid = u.replace(/-/g, '');
const rd = { name: '', appid: aid };
return system.getResult(rd);
}
......@@ -40,7 +40,7 @@ class OplogCtl extends CtlBase {
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
async getBusUidCtl(prefix) {
prefix = (prefix || '');
if (prefix) {
prefix = prefix.toUpperCase();
......@@ -49,7 +49,7 @@ prefix:业务前缀
const subLen = 8 - prefixlength;
let uidStr = '';
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
uidStr = await this.getUidInfoCtl(subLen, 60);
}
const timStr = moment().format('YYYYMMDDHHmm');
return prefix + timStr + uidStr;
......@@ -58,7 +58,7 @@ prefix:业务前缀
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
async getUidInfoCtl(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
const uuid = []; let i;
radix = radix || chars.length;
......@@ -66,7 +66,10 @@ prefix:业务前缀
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
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';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
......
......@@ -46,7 +46,7 @@ class UploadCtl extends CtlBase {
};
async downfile(srckey) {
const oss = system.getObject('util.ossClient');
var downfile = await oss.downfile(srckey).then(() => {
let downfile = await oss.downfile(srckey).then(() => {
downfile = `/tmp/${srckey}`;
return downfile;
});
......
......@@ -24,8 +24,8 @@ class VCodeCache extends CacheBase {
const vcode = await this.smsUtil.getUidStr(6, 10);
if (!tmplCode && !signName) {
this.smsUtil.sendMsg(mobile, vcode);
} // tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else {
// tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
} else {
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode }));
}
return JSON.stringify({ vcode });
......
......@@ -218,7 +218,8 @@ class Dao {
}
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 (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.SELECT };
......
......@@ -5,7 +5,7 @@ class RoleDao extends Dao {
super(Dao.getModelName(RoleDao));
}
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;
}
extraWhere(obj, w, qc, linkAttrs) {
......@@ -38,10 +38,10 @@ class RoleDao extends Dao {
const self = this;
const u2 = await this.preCreate(u);
if (t) {
var role = await this.model.create(u2, { transaction: t });
const role = await this.model.create(u2, { transaction: t });
return role;
}
var role = await this.model.create(u2);
const role = await this.model.create(u2);
return role;
}
}
......
......@@ -9,9 +9,11 @@ class UserDao extends Dao {
return this.model.findOne({
where: { id: userid },
include: [{ model: self.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'] },
{ model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{
model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] },
] },
],
},
],
});
}
......@@ -20,17 +22,18 @@ class UserDao extends Dao {
const tUser = await this.model.findOne({
where: { userName: username, app_id: app.id },
include: [{ model: this.db.models.app, raw: true },
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "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.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
] },
] }, { transaction: t });
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
],
},
],
}, { transaction: t });
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return tUser;
}
async getUserByOpenId(popenid, appkey, t) {
......@@ -38,35 +41,35 @@ class UserDao extends Dao {
let tUser = await this.model.findOne({
where: { openId: popenid },
include: [{ model: this.db.models.app, raw: true },
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "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.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
] },
] }, { transaction: t });
],
},
],
}, { transaction: t });
if (tUser != null) {
tUser = tUser.get({ plain: true });
tUser.partnerinfo = await this.partnerinfoDao.model.findOne({ where: { onlyCode: tUser.onlyCode }, raw: true });
}
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return tUser;
}
async setAccount(user, account, t) {
var user = await user.setAccount(account, { transaction: t });
const user = await user.setAccount(account, { transaction: t });
return user;
}
async setApp(user, app, t) {
// 按照APPId,获取app对象
var user = await user.setApp(app, { transaction: t });
const user = await user.setApp(app, { transaction: t });
return user;
}
extraModelFilter() {
// return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return { key: 'include', value: [
{ model: this.db.models.app },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }] };
return {
key: 'include', value: [
{ model: this.db.models.app },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }],
};
}
extraWhere(obj, w, qc, linkAttrs) {
if (obj.bizpath && obj.bizpath != '') {
......
......@@ -87,7 +87,8 @@ class DbFactory {
// pconfigObjs.forEach(p=>{
// 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){
// var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"});
// acc.save().then(a=>{
......
......@@ -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) {
var 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) {
var set = { lastMsgId: msg.id };
const set = { lastMsgId: msg.id };
if (msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
......
......@@ -11,7 +11,8 @@ 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;
}
async saveAuths(auths, appid, cmid) {
......@@ -20,8 +21,8 @@ class AuthService extends ServiceBase {
console.log('yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv');
console.log(auths);
return self.db.transaction(async (t) => {
for (let i = 0;i < auths.length;i++) {
var tmpAuth = auths[i];
for (let i = 0; i < auths.length; i++) {
const tmpAuth = auths[i];
tmpAuth.app_id = appid;
tmpAuth.company_id = cmid;
const objrtn = await self.dao.model.findOrCreate({
......@@ -33,10 +34,20 @@ class AuthService extends ServiceBase {
console.log(objrtn);
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;
});
}
......
......@@ -11,7 +11,7 @@ class OrgService extends ServiceBase {
const uone = await this.db.models.user.findOne({ where: { org_id: orgid } });
if (!uone) {
// 先检查是否组织下有人员存在
return this.db.transaction(async (t) => {
return this.db.transaction(async (t) => {
const inst = await self.dao.model.findById(orgid);
const parentid = inst.org_id;
await inst.destroy({ force: true, transaction: t });
......@@ -22,10 +22,13 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']],
where: { id: parentid }, transaction: t,
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;
});
}
......@@ -34,14 +37,14 @@ class OrgService extends ServiceBase {
async update(p, q, req) {
const self = this;
const cmkey = p.comkey;// 如果是来自租户界面的修改
return this.db.transaction(async (t) => {
return this.db.transaction(async (t) => {
p.isLeaf = p.isPosition;
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 });
const usersupdate = await self.db.models.user.findAll({ where: { org_id: orgupdate.id } });
// 如果节点名称或岗位性质发生变化
// if(p.name!=orgupdate.name || p.isMain!=orgupdate.isMain){
for (var 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;
......@@ -52,7 +55,7 @@ class OrgService extends ServiceBase {
const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } });
await orgupdate.setRoles(roles, { transaction: t });
// 同时要给这个岗位下的user,更新角色 todo
for (var ud of usersupdate) {
for (const ud of usersupdate) {
await ud.setRoles(roles, { transaction: t });
}
}
......@@ -60,14 +63,19 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']],
where: { id: orgupdate.org_id }, transaction: t,
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'] },
] });
],
});
return orgparent.orgs;
});
}
......@@ -78,10 +86,10 @@ class OrgService extends ServiceBase {
}
return null;
}
async changePos(toorgid, uid) {
async changePos(toorgid, uid) {
// 查询出当前用户,设置当前用户的orgid为修改目标
const self = this;
return this.db.transaction(async (t) => {
return this.db.transaction(async (t) => {
const ufind = await self.db.models.user.findById(uid);
......@@ -89,7 +97,8 @@ class OrgService extends ServiceBase {
where: { id: toorgid },
include: [
{ model: self.db.models.role, as: 'roles' },
] });
],
});
ufind.org_id = toorgid;
ufind.opath = org.orgpath;
if (org.isMain) { // 如果是主岗
......@@ -110,9 +119,9 @@ class OrgService extends ServiceBase {
const self = this;
const cmkey = p.comkey;
return this.db.transaction(async (t) => {
return this.db.transaction(async (t) => {
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;
}
const roles = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: p.Roles } } });
......@@ -126,15 +135,20 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']],
where: { id: orgnew.org_id }, transaction: t,
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'] },
] });
],
});
return orgparent.orgs;
});
}
......@@ -143,32 +157,42 @@ class OrgService extends ServiceBase {
order: [['code', 'ASC']],
where: { id },
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'] },
] });
],
});
return org.orgs;
}
async initOrgs(company, appid) {
const self = this;
return this.db.transaction(async (t) => {
return this.db.transaction(async (t) => {
const org = await self.dao.model.findOne({
order: [['code', 'ASC']],
// where:{name:company.name,company_id:company.id,app_id:appid},transaction:t,
where: { name: company.name, company_id: company.id }, transaction: t,
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'] },
] });
],
});
if (org != null) {
return org;
}
......
......@@ -60,7 +60,12 @@ class UserService extends ServiceBase {
// 设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo
// 如果是非租户,那么按照当前应用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) {
await u.setRoles(roles, { transaction: t });
}
......@@ -180,7 +185,13 @@ class UserService extends ServiceBase {
return rtn;
}
// 先按照用户名查续身份信息,获取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);
// rtn.token = token;
// rtn.user = u;
......
......@@ -79,7 +79,10 @@ class DeliverybillService extends ServiceBase {
if (deliverData.delivery_status !== system.SERVERSESTATUS.INSERVICE) {
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('已建账');
}
// 通知 财税
......@@ -135,7 +138,8 @@ class DeliverybillService extends ServiceBase {
setupStatus: deliverData.delivery_info.setupStatus || System.SERVERSESTATUS.NOTSETUP, // 建账状态 notsetup | setup
createdAt: deliverData.created_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) {
const schemeData = await this.fitaxschemeDao.findOne({
......
......@@ -14,7 +14,7 @@ class AppService extends ServiceBase {
const app = this.cacheManager.AppCache.cache(p.appkey, null);
return app;
}
async upFrontRoute(jsonObject, app_id) {
async upFrontRoute(jsonObject, appId) {
const self = this;
return this.db.transaction(async (t) => {
const keyfile = `${self.getUUID()}.json`;
......@@ -23,7 +23,7 @@ class AppService extends ServiceBase {
fs.writeFileSync(tmpdirfile, str);
const result = await self.ossC.upfile(keyfile, 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;
});
}
......
......@@ -10,7 +10,7 @@ class CachSearchesSve {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
async buildCacheRtn(pageValues) {
......@@ -27,24 +27,24 @@ class CachSearchesSve {
const { pageSize } = obj.pageInfo;
const limit = 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`;
if (obj.appid == settings.platformid) {
let cacheList = await this.cacheManager.MagCache.getCacheSmembersByKey(cacheCacheKeyPrefix);
if (search_name) {
cacheList = cacheList.filter(f => f.indexOf(search_name) >= 0);
if (searchName) {
cacheList = cacheList.filter(f => f.indexOf(searchName) >= 0);
}
const pageValues = cacheList.slice(offset, offset + limit);
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);
}
const body = {
pageInfo: obj.pageInfo,
search: obj.search,
};
var tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl);
const tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl);
return tmpList;
}
async delCache(obj) {
......@@ -75,17 +75,17 @@ class CachSearchesSve {
const apicallAccu = await this.cacheManager.ApiAccuCache.getApiCallAccu(obj);
const result = { rows: [], count: 0 };
const keys = await this.cacheManager.MagCache.keys(`api_call_${appkey}*`);
var detail = null;
let detail = null;
for (let j = 0; j < keys.length; j++) {
const d = keys[j];
const pathdetail = d.substr(d.lastIndexOf('_') + 1, d.length);
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;
}
// 操作别的应用的缓存
async opOtherAppCache(action_type, body = null, opCacheUrl) {
async opOtherAppCache(actionType, body = null, opCacheUrl) {
const appData = await this.authUtils.getTokenInfo(settings.appKey, settings.secret);
if (appData.status != 0) {
return appData;
......@@ -94,7 +94,7 @@ class CachSearchesSve {
const restS = await system.getObject('util.restClient');
const restResult = await restS.execPostWithAK(
{
action_type,
action_type: actionType,
body,
},
opCacheUrl, appData.data.accessKey,
......
......@@ -21,7 +21,13 @@ class CompanyService extends ServiceBase {
const us = await self.db.models.user.findAll({ where: { opath: opathstr }, transaction: t });
// 查询出角色
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) {
await u.setRoles(rs, { transaction: t });
}
......
......@@ -16,7 +16,15 @@ class RouteService extends ServiceBase {
let rtn = null;
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;
rtn = await self.dao.create(routedata, t);
} catch (e) {
......
......@@ -20,12 +20,12 @@ class MsgHistoryService extends ServiceBase {
return msg;
}
async pushBusinessLicenseMsg(senderId, targetId, businessLicense_id) {
if (!businessLicense_id) {
async pushBusinessLicenseMsg(senderId, targetId, businessLicenseId) {
if (!businessLicenseId) {
return 0;
}
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;
}
......
......@@ -28,7 +28,7 @@ class MsgNoticeService extends ServiceBase {
const msgIds = [];
const businessLicenseIds = [];
const userIds = [];
for (var item of list) {
for (const item of list) {
msgIds.push(item.lastMsgId);
businessLicenseIds.push(item.businessLicense_id);
userIds.push(item.toId);
......@@ -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 serviceTypeIds = [];
for (var item of licenseList) {
for (const item of licenseList) {
serviceTypeIds.push(item.serviceTypeOneId);
serviceTypeIds.push(item.serviceTypeTwoId);
}
......@@ -60,7 +60,7 @@ class MsgNoticeService extends ServiceBase {
const sql = `SELECT id, name FROM \`p_service_type\` WHERE id IN (${serviceTypeIds.join(',')}) `;
const typeList = await this.dao.customQuery(sql);
var typeMap = [];
const typeMap = [];
if (typeList && typeList.length > 0) {
for (const t of typeList) {
typeMap[`type_id_${t.id}`] = t.name;
......@@ -68,12 +68,12 @@ class MsgNoticeService extends ServiceBase {
item.serviceTypeOneName = t.name;
} else if (t.id == item.serviceTypeTwoId) {
item.serviceTypeTwoName = t.name;
} else {}
} else { }
}
}
}
for (var item of licenseList) {
for (const item of licenseList) {
item.serviceTypeOneName = typeMap[`type_id_${item.serviceTypeOneId}`];
item.serviceTypeTwoName = typeMap[`type_id_${item.serviceTypeTwoId}`];
}
......@@ -98,7 +98,7 @@ class MsgNoticeService extends ServiceBase {
const rs = [];
for (const i in list) {
var item = list[i];
const item = list[i];
item.lastMsg = msgMap[`id${item.lastMsgId}`];
item.businessLicense = businessLicenseMap[`id${item.businessLicense_id}`];
item.friend = userMap[`id${item.toId}`];
......
......@@ -22,7 +22,7 @@ class ServiceBase {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
static getDaoName(ClassObj) {
......@@ -79,7 +79,7 @@ class ServiceBase {
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
async getBusUid(prefix) {
prefix = (prefix || '');
if (prefix) {
prefix = prefix.toUpperCase();
......@@ -97,7 +97,7 @@ class ServiceBase {
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
async getUidInfo(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');// 长度62,到yz长度为长36
const uuid = []; let i;
radix = radix || chars.length;
......@@ -105,7 +105,10 @@ class ServiceBase {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
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';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
......@@ -132,7 +135,7 @@ class ServiceBase {
throw new Error(rtn.data);
} catch (e) {
console.log(e);
return null;
return null;
}
}
async cget(opurl) {
......@@ -155,7 +158,7 @@ class ServiceBase {
return null;
} catch (e) {
console.log(e);
return null;
return null;
}
}
async cdel(opurl) {
......@@ -167,7 +170,7 @@ class ServiceBase {
throw new Error(rtn.data);
} catch (e) {
console.log(e);
return null;
return null;
}
}
static bindPluginUrl(rname) {
......
......@@ -245,7 +245,7 @@ class System {
const configValue = require(configPath);
return configValue.config;
}
static get_client_ip(req) {
static getClientIp(req) {
const ip = req.headers['x-forwarded-for']
|| req.ip
|| req.connection.remoteAddress
......
......@@ -7,7 +7,7 @@ class AuthUtils {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
/**
......
......@@ -49,8 +49,8 @@ class ExcelClient {
wb.xlsx.writeFile(filePath).then(async (d) => {
const rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath, (err) => {});
var obj = {
fs.unlink(filePath, (err) => { });
let obj = {
user_id: user.id || 0,
userName: user.userName || '',
code,
......@@ -58,7 +58,7 @@ class ExcelClient {
filePath: rtn.url || '',
isDownload: false,
};
var obj = await self.filedownloadDao.create(obj);
obj = await self.filedownloadDao.create(obj);
});
}
}
......
......@@ -7,7 +7,7 @@ class LogClient {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
async log(pobj, req, rtninfo, errinfo) {
......
......@@ -88,7 +88,7 @@ class RedisClient {
}
if (self.chatserver) {
if (channel != 'task') {
var message = JSON.parse(message);
const message = JSON.parse(message);
console.log(message, '------------------------------------------ publish message');
if (channel == 'brc') { // 如果是广播频道,则发送广播到客户端
self.chatserver.server.emit('brc', message);
......@@ -248,7 +248,8 @@ module.exports = RedisClient;
// client.sismember("h","ok").then(function(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){
// console.log(result);
// });
......
......@@ -10,55 +10,50 @@ class RestClient {
this.cmdDownLoadFilePattern = 'curl -G -o {fileName} {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.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
this.cmdPostPattern5 = 'curl -k --data \'{data}\' {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);
return cmd;
}
return cmd;
}
FetchPostCmd(subData, url) {
const data = JSON.stringify(subData);
const cmd = this.cmdPostPattern.replace(
const data = JSON.stringify(subData);
const cmd = this.cmdPostPattern.replace(
/\{data\}/g,
data,
data,
).replace(/\{url\}/g, url);
return cmd;
return cmd;
}
FetchPostCmdWithAK(subData, url, acck) {
const data = JSON.stringify(subData);
const cmd = this.cmdPostPatternWithAK.replace(
const data = JSON.stringify(subData);
const cmd = this.cmdPostPatternWithAK.replace(
/\{data\}/g,
data,
data,
).replace(/\{url\}/g, url)
.replace(/\{ak\}/g, acck);
return cmd;
}
return cmd;
}
FetchPostCmd2(subData, url) {
const data = subData;
const cmd = this.cmdPostPattern2.replace(
const data = subData;
const cmd = this.cmdPostPattern2.replace(
/\{data\}/g,
data,
data,
).replace(/\{url\}/g, url);
return cmd;
}
return cmd;
}
FetchPostCmd3(subData, url) {
const data = subData;
const cmd = this.cmdPostPattern3.replace(
const data = subData;
const cmd = this.cmdPostPattern3.replace(
/\{data\}/g,
data,
data,
).replace(/\{url\}/g, url);
return cmd;
return cmd;
}
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;
}
FetchPostCmd4(subData, url) {
......@@ -78,10 +73,10 @@ class RestClient {
return cmd;
}
FetchDownLoadCmd(outfname, url) {
// console.log(this.cmdPattern);
const cmd = this.cmdDownLoadFilePattern.replace(/\{fileName\}/g, outfname).replace(/\{url\}/g, url);
return cmd;
}
// console.log(this.cmdPattern);
const cmd = this.cmdDownLoadFilePattern.replace(/\{fileName\}/g, outfname).replace(/\{url\}/g, url);
return cmd;
}
async exec(cmd) {
// await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
// 异常需要try/catch自己捕获或外部catch捕获
......
......@@ -38,7 +38,7 @@ class SmsClient {
};
return this.restClient.execPost(txtObj, this.smsTeml);
}
async getUidStr(len, radix) {
async getUidStr(len, radix) {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
const uuid = []; let i;
radix = radix || chars.length;
......@@ -46,7 +46,10 @@ class SmsClient {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
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';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
......
......@@ -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) {
const methodName = req.params.method;
const { gname } = req.params;
classPath = `${gname}.${classPath}`;
const tClientIp = System.get_client_ip(req);
const tClientIp = System.getClientIp(req);
req.clientIp = tClientIp;
req.uagent = req.headers['user-agent'];
// req.classname=classPath;
......@@ -35,7 +35,7 @@ module.exports = function (app) {
classPath = `${gname}.${classPath}`;
console.log('====================');
console.log(classPath);
const tClientIp = System.get_client_ip(req);
const tClientIp = System.getClientIp(req);
req.clientIp = tClientIp;
req.uagent = req.headers['user-agent'];
// req.classname=classPath;
......
......@@ -28,7 +28,7 @@ module.exports = function (app) {
const { gname } = req.params;
const params = [];
classPath = `${gname}.${classPath}`;
const tClientIp = system.get_client_ip(req);
const tClientIp = system.getClientIp(req);
req.body.clientIp = tClientIp;
req.body.agent = req.headers['user-agent'];
req.body.classname = classPath;
......
const fs = require('fs');
// function to encode file data to base64 encoded string
function base64_encode(file) {
function base64Encode(file) {
// read binary data
const bitmap = fs.readFileSync('./imgs/sp.png');
// convert binary data to base64 encoded string
......@@ -10,8 +10,9 @@ function base64_encode(file) {
}
// function to create file from base64 encoded string
function base64_decode(base64str, file) {
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded
function base64Decode(base64str, file) {
// 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');
// write buffer to file
fs.writeFileSync(file, bitmap);
......@@ -19,7 +20,7 @@ function base64_decode(base64str, file) {
}
function getDataUrl(filepath) {
const str = base64_encode(filepath);
const str = base64Encode(filepath);
let mime = '';
if (filepath.indexOf('png') >= 0) {
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