|
@@ -1,19 +1,17 @@
|
|
|
package com.gxzc.zen.api.sys.service.impl
|
|
|
|
|
|
import com.alibaba.dubbo.config.annotation.Reference
|
|
|
-import com.gxzc.zen.api.sys.model.SysResource
|
|
|
import com.gxzc.zen.api.sys.model.SysRole
|
|
|
import com.gxzc.zen.api.sys.service.ISysPermissionService
|
|
|
import com.gxzc.zen.common.contants.ZenConstants
|
|
|
import com.gxzc.zen.common.util.RedisCacheUtil
|
|
|
-import com.gxzc.zen.rpc.api.sys.RResourceService
|
|
|
+import com.gxzc.zen.rpc.api.sys.RPermissionService
|
|
|
import com.gxzc.zen.rpc.api.sys.RRoleService
|
|
|
import com.gxzc.zen.umps.common.ZenPermission
|
|
|
import com.gxzc.zen.umps.constant.ZenHttpSession
|
|
|
import com.gxzc.zen.umps.util.SSOUtil
|
|
|
import com.gxzc.zen.umps.util.ShiroRedisUtil
|
|
|
import org.apache.shiro.session.Session
|
|
|
-import org.springframework.beans.BeanUtils
|
|
|
import org.springframework.stereotype.Service
|
|
|
|
|
|
/**
|
|
@@ -29,28 +27,18 @@ import org.springframework.stereotype.Service
|
|
|
class SysPermissionServiceImpl : ISysPermissionService {
|
|
|
|
|
|
@Reference(version = "1.0")
|
|
|
- private val sysResourceService: RResourceService? = null
|
|
|
+ private val rPermissionService: RPermissionService? = null
|
|
|
|
|
|
@Reference(version = "1.0")
|
|
|
private val roleService: RRoleService? = null
|
|
|
|
|
|
override fun getAllSysPermission(): MutableList<ZenPermission> {
|
|
|
- var result = RedisCacheUtil.get(ZenConstants.CACHE_KEY_SYS, "allPerms")?.get() as? MutableList<ZenPermission>
|
|
|
- if (result == null || result.isEmpty()) {
|
|
|
- result = mutableListOf()
|
|
|
- val res = sysResourceService?.selectList(null)
|
|
|
- res?.forEach {
|
|
|
- result.add(transResource2ZenPermission(it))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// if (PlatformUtil.getPlatform() == PLATFORM.SYSTEM) {
|
|
|
- if (result.isNotEmpty()) {
|
|
|
- RedisCacheUtil.put(ZenConstants.CACHE_KEY_SYS, "allPerms", result)
|
|
|
-// }
|
|
|
+ // 获取权限
|
|
|
+ var ret = rPermissionService?.getAllPermission()
|
|
|
+ if (ret == null) {
|
|
|
+ ret = mutableListOf()
|
|
|
}
|
|
|
-
|
|
|
- return result
|
|
|
+ return ret
|
|
|
}
|
|
|
|
|
|
override fun getSubjectPermission(): MutableList<ZenPermission> {
|
|
@@ -61,8 +49,10 @@ class SysPermissionServiceImpl : ISysPermissionService {
|
|
|
val roles = getSubjectRoles(session)
|
|
|
val roleIds = roles.map { it.id!! }
|
|
|
|
|
|
- val resources = sysResourceService?.getResourcesByRoleIds(roleIds)
|
|
|
- resources?.forEach { result.add(transResource2ZenPermission(it)) }
|
|
|
+ val perms = rPermissionService?.getPermissionByRoleIds(roleIds)
|
|
|
+ if (perms != null && perms.isNotEmpty()) {
|
|
|
+ result.addAll(perms)
|
|
|
+ }
|
|
|
}
|
|
|
if (result.isNotEmpty()) {
|
|
|
session.setAttribute(ZenHttpSession.SESSION_KEY_USER_PERMS, result)
|
|
@@ -82,15 +72,6 @@ class SysPermissionServiceImpl : ISysPermissionService {
|
|
|
return roles
|
|
|
}
|
|
|
|
|
|
- fun transResource2ZenPermission(source: SysResource): ZenPermission {
|
|
|
- val temp = ZenPermission()
|
|
|
- BeanUtils.copyProperties(source, temp)
|
|
|
- if (!(temp.uri != null && temp.uri!!.startsWith("/"))) {
|
|
|
- temp.uri = "/${temp.uri}"
|
|
|
- }
|
|
|
- return temp
|
|
|
- }
|
|
|
-
|
|
|
override fun updateAllSysPermission() {
|
|
|
RedisCacheUtil.evict(ZenConstants.CACHE_KEY_SYS, "allPerms")
|
|
|
}
|