package com.ruoyi.ss.vipLevel.service.impl;

import org.springframework.stereotype.Service;

import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
import com.ruoyi.ss.vipLevel.domain.enums.VipLevelLimitType;
import com.ruoyi.ss.vipLevel.service.VipLevelValidator;

@Service
public class VipLevelValidatorImpl implements VipLevelValidator {

    @Override
    public void afterValid(VipLevelVO vo) {
        ServiceUtil.assertion(vo == null, "VIP等级定价不存在");
        
        // 判断限制次数是否必填
        if (!VipLevelLimitType.NONE.getType().equals(vo.getLimitType())) { 
            ServiceUtil.assertion(vo.getLimitCount() == null, "限制次数不能为空");
            ServiceUtil.assertion(vo.getLimitCount() <= 0, "限制次数不能小于等于0");
        }
    }

}
