Commit 26d7e704 by 王勇飞

Merge branch 'center-manage' of gitlab.gongsibao.com:jiangyong/zhichan into center-manage

parents f5737e5e 67a97272
node_modules/ node_modules/
*_build.sh
\ No newline at end of file
#!/bin/bash #!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2 FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com" MAINTAINER jy "jiangyong@gongsibao.com"
ARG webenv
ADD center-manage /apps/center-manage/ ADD center-manage /apps/center-manage/
ADD web/$webenv /apps/center-manage/app/front/entry/public/
WORKDIR /apps/center-manage/ WORKDIR /apps/center-manage/
RUN cnpm install -S RUN cnpm install -S
CMD ["node","/apps/center-manage/main.js"] CMD ["node","/apps/center-manage/main.js"]
......
node_modules/ node_modules/
app/config/localsettings.js app/config/localsettings.js
*.sh app/front/entry/public/
\ No newline at end of file \ No newline at end of file
...@@ -7,60 +7,69 @@ const CtlBase = require("../../ctl.base"); ...@@ -7,60 +7,69 @@ const CtlBase = require("../../ctl.base");
class CompanyCtl extends CtlBase { class CompanyCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(CompanyCtl)); super("common", CtlBase.getServiceName(CompanyCtl));
this.userSve = system.getObject("service.auth.userSve");
} }
async update(p,q,req){ async update(p, q, req) {
let u= await super.update(p,q,req) let u = await super.update(p, q, req)
//缓存失效 //缓存失效
await this.cacheManager["CompanyCache"].invalidate(p.companykey) await this.cacheManager["CompanyCache"].invalidate(p.companykey)
let company=await this.cacheManager["CompanyCache"].cache(p.companykey) let company = await this.cacheManager["CompanyCache"].cache(p.companykey)
return system.getResult(company) return system.getResult(company)
} }
async getMyApps(p,q,req){ async getMyApps(p, q, req) {
let userfind = await this.cacheManager["UserCache"].cache(p.username) let userfind = await this.cacheManager["UserCache"].cache(p.username)
let isSuper=userfind.isSuper let isSuper = userfind.isSuper
if(userfind.company.appids && userfind.company.appids!=""){ if (userfind.company.appids && userfind.company.appids != "") {
let appsarray=userfind.company.appids.split(",") let appsarray = userfind.company.appids.split(",")
let appidsquery=appsarray.map(astr=>{ let appidsquery = appsarray.map(astr => {
return astr.split("|")[0] return astr.split("|")[0]
}) })
let apps=await this.service.getMyApps(appidsquery,isSuper) let apps = await this.service.getMyApps(appidsquery, isSuper)
return system.getResult(apps) return system.getResult(apps)
}else{ } else {
return [] return []
} }
} }
async bindApps(p,q,req){ async bindApps(p, q, req) {
let appids=p.appids let appids = p.appids
let cmpid=p.postcmpid let cmpid = p.postcmpid
let appids2=appids.map(item=>{ let appids2 = appids.map(item => {
return item.appid+"|"+item.title return item.appid + "|" + item.title
}) })
let appidstrs=appids2.join(",") let appidstrs = appids2.join(",")
await this.service.bindApps(appidstrs,cmpid) await this.service.bindApps(appidstrs, cmpid)
return system.getResult(appids) return system.getResult(appids)
} }
async setOrgs(p,q,req){ async setOrgs(p, q, req) {
//let companynew=await this.service.findById(p.company_id) //let companynew=await this.service.findById(p.company_id)
let orgs=await this.service.setOrgs(p) let orgs = await this.service.setOrgs(p)
return system.getResult(orgs) return system.getResult(orgs)
} }
async getOrgs(p,q,req){ async getOrgs(p, q, req) {
//let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey) //let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
let companynew=await this.service.findById(p.company_id) let companynew = await this.service.findById(p.company_id);
let orgjsonstr=companynew.orgJson const userData = await this.userSve.findById(p.userid);
let rtnjson=null let orgjsonstr = companynew.orgJson;
if(orgjsonstr && orgjsonstr!=""){ let rtnjson = null;
rtnjson=JSON.parse(companynew.orgJson) if (orgjsonstr && orgjsonstr != "") {
}else{ rtnjson = JSON.parse(companynew.orgJson);
rtnjson=[] } else {
rtnjson = [];
}
if (userData) {
if (userData.isAdmin || userData.isSuper) {
return system.getResult({ orgJson: rtnjson });
} else {
return system.getResult({ orgJson: this.service.buildOrgs(rtnjson, userData.ptags) });
}
} else {
return system.getResult({ orgJson: [] });
} }
return system.getResult({orgJson:rtnjson})
} }
async refQuery(pobj, qobj, req) { async refQuery(pobj, qobj, req) {
let rtn=await this.service.refQuery(pobj); let rtn = await this.service.refQuery(pobj);
return rtn return rtn
} }
} }
module.exports = CompanyCtl; module.exports = CompanyCtl;
...@@ -10,19 +10,20 @@ class VCodeCache extends CacheBase { ...@@ -10,19 +10,20 @@ class VCodeCache extends CacheBase {
// isdebug() { // isdebug() {
// return settings.env == "dev"; // return settings.env == "dev";
// } // }
desc() { desc () {
return "缓存给手机发送的验证码60妙"; return "缓存给手机发送的验证码60妙";
} }
prefix() { prefix () {
return "g_vcode_cm:" return "g_vcode_cm:"
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal (cachekey, inputkey, val, ex, ...items) {
//inputkey采用appkey_mobile的形式 //inputkey采用appkey_mobile的形式
var mobile = inputkey; var mobile = inputkey;
var tmplCode = val; var tmplCode = val;
var signName = items ? items[0] : ""; var signName = items ? items[0] : "";
var vcode = await this.smsUtil.getUidStr(6, 10); var vcode = await this.smsUtil.getUidStr(6, 10);
if (!tmplCode && !signName) { if (!tmplCode && !signName) {
console.log("=============================")
this.smsUtil.sendMsg(mobile, vcode); this.smsUtil.sendMsg(mobile, vcode);
} //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码 } //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else { else {
......
...@@ -106,8 +106,10 @@ class Dao { ...@@ -106,8 +106,10 @@ class Dao {
const search = qobj.search; const search = qobj.search;
var qc = {}; var qc = {};
//设置分页查询条件 //设置分页查询条件
if (pageNo != -1) {
qc.limit = pageSize; qc.limit = pageSize;
qc.offset = (pageNo - 1) * pageSize; qc.offset = (pageNo - 1) * pageSize;
}
//默认的查询排序 //默认的查询排序
qc.order = this.orderBy(qobj); qc.order = this.orderBy(qobj);
//构造where条件 //构造where条件
......
...@@ -101,6 +101,9 @@ class UserDao extends Dao { ...@@ -101,6 +101,9 @@ class UserDao extends Dao {
w[strq] = { [this.db.Op.like]: "%" + search[lnkKey] + "%" }; w[strq] = { [this.db.Op.like]: "%" + search[lnkKey] + "%" };
} }
qc.attributes = {
exclude: ["password", "jwtkey", "jwtsecret"]
}
return w; return w;
} }
async preUpdate(u) { async preUpdate(u) {
......
...@@ -5,7 +5,7 @@ class CompanyService extends ServiceBase { ...@@ -5,7 +5,7 @@ class CompanyService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(CompanyService)); super("common", ServiceBase.getDaoName(CompanyService));
} }
async getMyApps (appids, isSuper) { async getMyApps(appids, isSuper) {
let appsrtn = null let appsrtn = null
if (isSuper) { if (isSuper) {
appsrtn = this.db.models.app.findAll({ appsrtn = this.db.models.app.findAll({
...@@ -24,14 +24,14 @@ class CompanyService extends ServiceBase { ...@@ -24,14 +24,14 @@ class CompanyService extends ServiceBase {
} }
return appsrtn return appsrtn
} }
async bindApps (appids, companyid) { async bindApps(appids, companyid) {
var self = this var self = this
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
let u = await self.dao.update({ appids: appids, id: companyid }, t) let u = await self.dao.update({ appids: appids, id: companyid }, t)
return appids return appids
}) })
} }
async setOrgs (p, cmk) { async setOrgs(p, cmk) {
var self = this var self = this
let curNodeData = p.curdata let curNodeData = p.curdata
let opathstr = curNodeData.orgpath let opathstr = curNodeData.orgpath
...@@ -106,5 +106,18 @@ class CompanyService extends ServiceBase { ...@@ -106,5 +106,18 @@ class CompanyService extends ServiceBase {
return { orgJson: JSON.parse(companytmp.orgJson) } return { orgJson: JSON.parse(companytmp.orgJson) }
}) })
} }
buildOrgs(rtnjson, code) {
if (rtnjson.length > 0) {
for (let val of rtnjson) {
if (val.code === code) {
return [val]
} else {
return this.buildOrgs(val.children || [], code)
}
}
} else {
return rtnjson
}
}
} }
module.exports = CompanyService; module.exports = CompanyService;
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
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