Commit 7de7b368 by 蒋勇

d

parent 37b0861b
...@@ -40,7 +40,8 @@ class CompanyCtl extends CtlBase { ...@@ -40,7 +40,8 @@ class CompanyCtl extends CtlBase {
return system.getResult(appids) return system.getResult(appids)
} }
async setOrgs(p,q,req){ async setOrgs(p,q,req){
let orgs=await this.service.setOrgs(p,req.xctx.fromcompanykey) //let companynew=await this.service.findById(p.company_id)
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){
......
...@@ -12,6 +12,7 @@ class AuthService extends ServiceBase{ ...@@ -12,6 +12,7 @@ class AuthService extends ServiceBase{
var aths=await this.dao.model.findAll({ var aths=await this.dao.model.findAll({
attributes:["bizcode","authstrs","codepath"], attributes:["bizcode","authstrs","codepath"],
where:{role_id:{[this.db.Op.in]:roleids}}}); where:{role_id:{[this.db.Op.in]:roleids}}});
//因为是按照角色ID,所以不需要按照公司
// 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;
} }
......
...@@ -83,13 +83,15 @@ class UserService extends ServiceBase { ...@@ -83,13 +83,15 @@ class UserService extends ServiceBase {
//如果是用户注册,平台用户应该只属于平台应用 //如果是用户注册,平台用户应该只属于平台应用
let roleappid = p.app_id;//先取出当前应用的id,给后续的取角色用,角色是按照应用和公司区分 let roleappid = p.app_id;//先取出当前应用的id,给后续的取角色用,角色是按照应用和公司区分
//目前升级为角色不再按照应用区分,只按照公司区分
p.app_id = settings.pmappid p.app_id = settings.pmappid
let u = await self.dao.create(p, t) let u = await self.dao.create(p, t)
//设置默认角色,租户 //设置默认角色,租户
//设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo //设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo
//如果是非租户,那么按照当前应用ID是找不到指定的角色,所以是空的 //如果是非租户,那么按照当前应用ID是找不到指定的角色,所以是空的
if (p.isAdmin) { /*if (p.isAdmin) {
var roles = await self.roleDao.model.findAll({ where: { id: { [self.db.Op.in]: rolecodes }, app_id: roleappid, company_id: settings.pmcompanyid }, transaction: t }); //var roles = await self.roleDao.model.findAll({ where: { id: { [self.db.Op.in]: rolecodes }, app_id: roleappid, company_id: settings.pmcompanyid }, transaction: t });
var roles = await self.roleDao.model.findAll({ where: { id: { [self.db.Op.in]: rolecodes }}, transaction: t });
if (roles && roles.length > 0) { if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t }); await u.setRoles(roles, { transaction: t });
} }
...@@ -98,6 +100,10 @@ class UserService extends ServiceBase { ...@@ -98,6 +100,10 @@ class UserService extends ServiceBase {
if (roles && roles.length > 0) { if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t }); await u.setRoles(roles, { transaction: t });
} }
}*/
var roles = await self.roleDao.model.findAll({ where: { id: { [self.db.Op.in]: rolecodes }}, transaction: t });
if (roles && roles.length > 0) {
await u.setRoles(roles, { transaction: t });
} }
//创建统一账号 to add extra fields //创建统一账号 to add extra fields
......
...@@ -46,21 +46,21 @@ class CompanyService extends ServiceBase { ...@@ -46,21 +46,21 @@ class CompanyService extends ServiceBase {
//查询出角色 //查询出角色
let roleids=curNodeData.roles let roleids=curNodeData.roles
// let 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}) // let 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})
let rs=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:roleids},company_id:p.company_id},transaction:t}) //需要添加访客角色
if (roleids && roleids.length > 0) {
if (roleids.indexOf(settings.pmroleid["pr"]) < 0) {
roleids.push(settings.pmroleid["pr"])
}
}
let rs=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:roleids}},transaction:t})
for(let u of us){ for(let u of us){
await u.setRoles(rs,{transaction:t}) await u.setRoles(rs,{transaction:t})
//令用户缓存失效 //令用户缓存失效
await self.cacheManager["UserCache"].invalidate(u.userName) await self.cacheManager["UserCache"].invalidate(u.userName)
} }
// users.forEach((u)=>{
// await u.setRoles(rs, { transaction: t });
// })
} }
//用户缓存也要失效 let companytmp=await self.dao.model.findOne({where:{id:p.company_id},transaction:t});
//缓存失效
await self.cacheManager["CompanyCache"].invalidate(cmk)
let companytmp=await self.dao.model.findOne({where:{companykey:cmk},transaction:t});
return {orgJson:JSON.parse(companytmp.orgJson)} return {orgJson:JSON.parse(companytmp.orgJson)}
}) })
} }
......
...@@ -36,7 +36,7 @@ class ProductpriceService extends ServiceBase { ...@@ -36,7 +36,7 @@ class ProductpriceService extends ServiceBase {
} }
}) })
let codeval=String(areainfos[0].code).padEnd(6,'0') let codeval=String(areainfos[0].code).padEnd(6,'0')
if(areainfos[0].name.indexOf("天津") ||areainfos[0].name.indexOf("北京") || areainfos[0].name.indexOf("上海") || areainfos[0].name.indexOf("重庆")){ if(areainfos[0].name.indexOf("天津")>=0 ||areainfos[0].name.indexOf("北京")>=0 || areainfos[0].name.indexOf("上海") >=0 || areainfos[0].name.indexOf("重庆")>=0){
codeval=String(areainfos[0].code+"01").padEnd(6,'0') codeval=String(areainfos[0].code+"01").padEnd(6,'0')
} }
if(!cacheregions[codeval]){ if(!cacheregions[codeval]){
......
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