1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
epp/weixin-miniprogram/utils/getUserGroupByRole.js

30 lines
707 B
JavaScript
Raw Permalink Normal View History

const ENUM = require('./const.js');
function getUserGroupByRole(userRole) {
const role = ENUM.user.role;
userRole = Number(userRole);
let userGroupDict = {
'visitor': [
role.VISITOR,
].includes(userRole),
'user': [
role.RESIDENTS_OWNER,
role.RESIDENTS_MEMBER,
role.RESIDENTS_TENENT,
].includes(userRole),
'admin': [
role.ADMIN,
role.STAFF,
].includes(userRole)
}
console.log("userGroupDict", userGroupDict, userRole, role)
for (let userGroup of Object.keys(userGroupDict)) {
if (userGroupDict[userGroup]) {
return userGroup;
}
}
return 'unknown';
}
module.exports = getUserGroupByRole;