修复角色权限注解失效问题

pull/88/head
RuoYi 2019-05-16 13:10:08 +08:00
parent efa3dbbd43
commit 1818af2a08
4 changed files with 36 additions and 3 deletions

View File

@ -1,6 +1,5 @@
package com.ruoyi; package com.ruoyi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -11,7 +10,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.ruoyi.*.mapper")
public class RuoYiApplication public class RuoYiApplication
{ {
public static void main(String[] args) public static void main(String[] args)

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.utils.spring; package com.ruoyi.common.utils.spring;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
@ -98,4 +99,16 @@ public final class SpringUtils implements BeanFactoryPostProcessor
{ {
return beanFactory.getAliases(name); return beanFactory.getAliases(name);
} }
/**
* aop
*
* @param invoker
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T getAopProxy(T invoker)
{
return (T) AopContext.currentProxy();
}
} }

View File

@ -0,0 +1,20 @@
package com.ruoyi.framework.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
*
*
* @author ruoyi
*/
@Configuration
// 表示通过aop框架暴露该代理对象,AopContext能够访问
@EnableAspectJAutoProxy(exposeProxy = true)
// 指定要扫描的Mapper类的包的路径
@MapperScan("com.ruoyi.*.mapper")
public class ApplicationConfig
{
}

View File

@ -13,6 +13,7 @@ import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysRoleMenu;
@ -110,7 +111,7 @@ public class SysRoleServiceImpl implements ISysRoleService
@Override @Override
public List<SysRole> selectRoleAll() public List<SysRole> selectRoleAll()
{ {
return selectRoleList(new SysRole()); return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
} }
/** /**
@ -315,6 +316,7 @@ public class SysRoleServiceImpl implements ISysRoleService
{ {
return roleMapper.updateRole(role); return roleMapper.updateRole(role);
} }
/** /**
* *
* *