package com.ruoyi.novel.vip;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

// VipAccessAspect.java
@Aspect
@Component
public class VipAccessAspect {

    @Before("@annotation(vipAccess)")
    public void checkVipAccess(JoinPoint joinPoint, VipAccess vipAccess) {
        // 校验用户VIP状态
        if(!userService.isVip(SecurityUtils.getUserId())) {
            throw new ServiceException("请开通VIP后阅读此章节");
        }
    }
}
