Commit c97dba72 by 蒋勇

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

parents 7535ff74 a8d78fe7
const CacheBase = require("../cache.base"); const CacheBase = require("../cache.base");
const system = require("../../system"); const system = require("../../system");
const settings = require("../../../config/settings"); const settings = require("../../../config/settings");
class UserCache extends CacheBase{ class UserCache extends CacheBase {
constructor(){ constructor() {
super(); super();
this.userDao=system.getObject("db.auth.userDao"); this.userDao = system.getObject("db.auth.userDao");
} }
isdebug(){ isdebug() {
return settings.env=="dev"; return settings.env == "dev";
} }
desc(){ desc() {
return "缓存本地应用对象"; return "缓存本地应用对象";
} }
prefix(){ prefix() {
return "g_userlocal_cm:" return "g_userlocal_cm:"
} }
async buildCacheVal(cachekey,inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.userDao.model.findAll({ const configValue = await this.userDao.model.findAll({
where: { userName: inputkey, app_id: settings.pmappid,isEnabled:true}, where: { userName: inputkey, app_id: settings.pmappid, isEnabled: true },
attributes: ['id','userName', 'nickName','headUrl','jwtkey','jwtsecret','created_at','isSuper','isAdmin','isAllocated','mail','mobile','opath','ptags'], attributes: ['id', 'userName', 'nickName', 'headUrl', 'jwtkey', 'jwtsecret', 'created_at', 'isSuper', 'isAdmin', 'isAllocated', 'mail', 'mobile', 'opath', 'ptags'],
include: [ include: [
{ model: this.db.models.company,attributes:['id','name','companykey','appids'],raw:true}, { model: this.db.models.company, attributes: ['id', 'name', 'companykey', 'appids', "code"], raw: true },
{model:this.db.models.role,as:"Roles",attributes:["id","code"],} { model: this.db.models.role, as: "Roles", attributes: ["id", "code"], }
], ],
}); });
if (configValue && configValue[0]) { if (configValue && configValue[0]) {
return JSON.stringify(configValue[0]); return JSON.stringify(configValue[0]);
} }
return null; return null;
} }
} }
module.exports=UserCache; module.exports = UserCache;
\ No newline at end of file \ 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