微服务springBoot,AOP实现菜单管理权限(附表结构)

权限注解:

@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface CheckPermissions {

    String value() default "";
}

切入点:

@Aspect
@Component
public class CheckPermissionsAspect extends BaseController {

    @Autowired
    private OrgMenuService menuService;

    @Autowired
    private OrgEmpRoleService empRoleService;

    @Autowired
    private OrgRoleMenuService roleMenuService;

    @Autowired
    private OrgEmpService empService;

    @Pointcut("@annotation(com.bcl.yiliao.annotation.CheckPermissions)")
    public void CheckPermissionsAspect() {
    }

    @Before("CheckPermissionsAspect()")
    public void doBefore(JoinPoint joinpoint) throws Throwable {
       
        //获取用户的ID
        Long userId = getCurrentUserId();
        if(userId == 0){
   

猜你喜欢

转载自blog.csdn.net/DDDM456/article/details/126485663
今日推荐