|
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl
|
|
import com.gxzc.zen.api.sys.mapper.SysMenuRoleMapper
|
|
import com.gxzc.zen.api.sys.mapper.SysMenuRoleMapper
|
|
import com.gxzc.zen.api.sys.model.SysMenuRole
|
|
import com.gxzc.zen.api.sys.model.SysMenuRole
|
|
import com.gxzc.zen.api.sys.service.ISysMenuRoleService
|
|
import com.gxzc.zen.api.sys.service.ISysMenuRoleService
|
|
|
|
+import com.gxzc.zen.orm.annotation.ZenTransactional
|
|
|
|
+import com.gxzc.zen.umps.constant.ZenHttpSession
|
|
|
|
+import com.gxzc.zen.umps.util.ShiroRedisUtil
|
|
import org.springframework.stereotype.Service
|
|
import org.springframework.stereotype.Service
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -17,7 +20,6 @@ import org.springframework.stereotype.Service
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
class SysMenuRoleServiceImpl : ServiceImpl<SysMenuRoleMapper, SysMenuRole>(), ISysMenuRoleService {
|
|
class SysMenuRoleServiceImpl : ServiceImpl<SysMenuRoleMapper, SysMenuRole>(), ISysMenuRoleService {
|
|
-
|
|
|
|
override fun removeByMenuId(menuId: Long) {
|
|
override fun removeByMenuId(menuId: Long) {
|
|
val condition = SysMenuRole().apply {
|
|
val condition = SysMenuRole().apply {
|
|
this.menuId = menuId
|
|
this.menuId = menuId
|
|
@@ -25,4 +27,44 @@ class SysMenuRoleServiceImpl : ServiceImpl<SysMenuRoleMapper, SysMenuRole>(), IS
|
|
baseMapper.physicalDelete(EntityWrapper(condition))
|
|
baseMapper.physicalDelete(EntityWrapper(condition))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun getMenuIdListByRoleId(roleId: Long): List<Long> {
|
|
|
|
+ val condition = SysMenuRole().apply {
|
|
|
|
+ this.roleId = roleId
|
|
|
|
+ }
|
|
|
|
+ return baseMapper.selectWOLogic(EntityWrapper(condition)).map {
|
|
|
|
+ it.menuId!!
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ZenTransactional
|
|
|
|
+ override fun updateMenuRole(roleId: Long, menuIdList: List<Long>) {
|
|
|
|
+ // 先获取roleid的所有menuid
|
|
|
|
+ val oldMenuIdList = getMenuIdListByRoleId(roleId)
|
|
|
|
+ val deleteIds = oldMenuIdList.subtract(menuIdList)
|
|
|
|
+ val insertIds = menuIdList.subtract(oldMenuIdList)
|
|
|
|
+
|
|
|
|
+ var eff = false
|
|
|
|
+ if (deleteIds.isNotEmpty()) {
|
|
|
|
+ baseMapper.physicalDelete(EntityWrapper<SysMenuRole>().eq("role_id", roleId).`in`("menu_id", deleteIds))
|
|
|
|
+ eff = true
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (insertIds.isNotEmpty()) {
|
|
|
|
+ val entityList = mutableListOf<SysMenuRole>()
|
|
|
|
+ insertIds.forEach {
|
|
|
|
+ entityList.add(SysMenuRole().apply {
|
|
|
|
+ this.roleId = roleId
|
|
|
|
+ this.menuId = it
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this.insertBatch(entityList)
|
|
|
|
+ eff = true
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (eff) {
|
|
|
|
+ // 更新一下缓存SESSION_KEY_USER_MENU
|
|
|
|
+ ShiroRedisUtil.removeAllSessionsAttributeKey(ZenHttpSession.SESSION_KEY_USER_MENU)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|