无关风月
2 天以前 ce0651907f18a57dae80065e01589e975530f53e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.ruoyi.web.aspect;
 
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
 
@Aspect
@Component
 
public class StateAspect {
 
    @Autowired
    private ISysUserService sysUserService;
 
    @Autowired
    private ISysRoleService roleService;
    @Pointcut("execution(* com.ruoyi.web.controller.manage.*.*(..)) && !execution( * com.ruoyi.web.controller.manage.LoginController.*.*(..))")
    public void state(){}
 
    @Before("state()")
    public void isfrozen(){
        System.err.println("进入切面");
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser sysUser = sysUserService.selectUserById(loginUser.getUserId());
        if (sysUser.getStatus().equals("1")){
            throw new ServiceException("当前账号已停用");
        }
        if (roleService.selectRoleByUserId(sysUser.getUserId()).getStatus()==1){
            throw new ServiceException("当前角色已停用");
        };
 
 
    }
 
 
 }