|
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl
|
|
|
import com.gxzc.zen.api.sys.mapper.SysUserRoleMapper
|
|
|
import com.gxzc.zen.api.sys.model.SysRole
|
|
|
import com.gxzc.zen.api.sys.model.SysUserRole
|
|
|
+import com.gxzc.zen.api.sys.service.ISysRoleService
|
|
|
import com.gxzc.zen.api.sys.service.ISysUserRoleService
|
|
|
+import org.springframework.beans.factory.annotation.Autowired
|
|
|
import org.springframework.stereotype.Service
|
|
|
|
|
|
/**
|
|
@@ -18,13 +20,23 @@ import org.springframework.stereotype.Service
|
|
|
*/
|
|
|
@Service
|
|
|
class SysUserRoleServiceImpl : ServiceImpl<SysUserRoleMapper, SysUserRole>(), ISysUserRoleService {
|
|
|
+ @Autowired
|
|
|
+ private lateinit var sysRoleService: ISysRoleService
|
|
|
+
|
|
|
override fun getUserRoleListByUserId(id: Long): MutableList<SysRole> {
|
|
|
return baseMapper.selectUserRoleListByUserId(id)
|
|
|
}
|
|
|
|
|
|
- override fun getUserRoleList(): Map<Int, MutableList<SysRole>> {
|
|
|
+ override fun getUserRoleList(): Map<Long, MutableList<SysRole>> {
|
|
|
val allSysUserRole = baseMapper.selectList(EntityWrapper<SysUserRole>())
|
|
|
- allSysUserRole.
|
|
|
- return baseMapper.selectUserRoleList()
|
|
|
+ val groupUserRole = allSysUserRole.groupBy({ it.userId }, { it.roleId })
|
|
|
+ val result = mutableMapOf<Long, MutableList<SysRole>>()
|
|
|
+ for (item in groupUserRole) {
|
|
|
+ if (item.key == null) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ result[item.key!!] = sysRoleService.selectBatchIds(item.value)
|
|
|
+ }
|
|
|
+ return result
|
|
|
}
|
|
|
}
|