package com.lantone.security.aop;

import com.lantone.security.facade.base.DataAuthFacade;
import com.lantone.security.client.MessageService;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description: 用户数据权限变更统一处理切面
 * @author: rengb
 * @time: 2021/8/26 10:43
 */
@Aspect
@Component
public class DataAuthInitAspect {

    @Autowired
    private MessageService messageService;

    @Pointcut("execution(public * com.lantone.security.web.RoleManagementController.addRole(..))" +
            "||execution(public * com.lantone.security.web.RoleManagementController.deleteRole(..))" +
            "||execution(public * com.lantone.security.web.RoleManagementController.disableRole(..))" +
            "||execution(public * com.lantone.security.web.RoleManagementController.updateRole(..))" +
            "||execution(public * com.lantone.security.web.HospitalManagementController.addHospital(..))" +
            "||execution(public * com.lantone.security.web.HospitalManagementController.updateHospital(..))" +
            "||execution(public * com.lantone.security.web.HospitalManagementController.disableHospital(..))" +
            "||execution(public * com.lantone.security.web.HospitalManagementController.deleteHospital(..))" +
            "||execution(public * com.lantone.security.web.UserManagementController.addUser(..))" +
            "||execution(public * com.lantone.security.web.UserManagementController.updateUser(..))" +
            "||execution(public * com.lantone.security.web.UserManagementController.disableUser(..))" +
            "||execution(public * com.lantone.security.web.UserManagementController.deleteUser(..))" +
            "||execution(public * com.lantone.security.web.DataAuthManagementController.addAuth(..))" +
            "||execution(public * com.lantone.security.web.DataAuthManagementController.updateAuth(..))" +
            "||execution(public * com.lantone.security.web.DataAuthManagementController.deleteAuth(..))" +
            "||execution(public * com.lantone.security.web.DataAuthManagementController.disableAuth(..))"
    )
    public void basicInfoChange() {
    }

    @After("basicInfoChange()")
    public void aspectAfter() {
        messageService.redisRefresh("initUserDataAuth");
    }

}