Commit aa5c5398 by 蒋勇

d

parent aac3b8cb
......@@ -74,6 +74,7 @@ class CtlBase {
}
if(req.xctx.userid){//在请求传递数据对象注入公司id
pobj.userid=req.xctx.userid;
pobj.username=req.xctx.username;
}
pobj.bizpath=req.xctx.bizpath;
}
......
......@@ -10,6 +10,13 @@ class AppCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(AppCtl));
this.userCtl = system.getObject("service.auth.userSve");
this.comS=system.getObject("service.common.companySve");
}
async findAndCountAll(pobj, qobj, req) {
let comtemp=await this.comS.findById(pobj.company_id)
pobj.myappstrs=comtemp.appids
let rtn=await super.findAndCountAll(pobj,qobj,req)
return system.getResult(rtn)
}
async findAllApps(p, q, req) {
var rtns = await this.service.findAllApps(p.userid);
......
......@@ -15,6 +15,20 @@ class CompanyCtl extends CtlBase {
let company=await this.cacheManager["CompanyCache"].cache(p.companykey)
return system.getResult(company)
}
async getMyApps(p,q,req){
let userfind = await this.cacheManager["UserCache"].getCache(p.username)
let isSuper=userfind.isSuper
if(userfind.company.appids && userfind.company.appids!=""){
let appsarray=userfind.company.appids.split(",")
let appidsquery=appsarray.map(astr=>{
return astr.split("|")[0]
})
let apps=await this.service.getMyApps(appidsquery,isSuper)
return system.getResult(apps)
}else{
return []
}
}
async bindApps(p,q,req){
let appids=p.appids
let cmpid=p.postcmpid
......
......@@ -8,7 +8,12 @@ class AppDao extends Dao{
extraWhere(obj,w,qc,linkAttrs){
if(obj.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("my_app")>0){//说明是租户查询自己创建的应用
w["creator_id"]=obj.userid;
let appstrs=obj.myappstrs
let appsarray=appstrs.split(",")
let appidsquery=appsarray.map(astr=>{
return astr.split("|")[0]
})
w["id"]= {[this.db.Op.in]:appidsquery};
}
}
if(linkAttrs.length>0){
......
......@@ -5,6 +5,23 @@ class CompanyService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(CompanyService));
}
async getMyApps(appids,isSuper){
let appsrtn=null
if(isSuper){
appsrtn=this.db.models.app.findAll({where:
{
id:{[this.db.Op.ne]:settings.pmappid}
}
})
}else{
appsrtn=this.db.models.app.findAll({where:
{
id:{[this.db.Op.in]:appids}
}
})
}
return appsrtn
}
async bindApps(appids,companyid){
var self=this
return this.db.transaction(async function (t) {
......
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