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

import java.util.Collections;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.vipLevel.service.VipLevelValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ss.vipLevel.mapper.VipLevelMapper;
import com.ruoyi.ss.vipLevel.domain.VipLevel;
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
import com.ruoyi.ss.vipLevel.domain.VipLevelQuery;
import com.ruoyi.ss.vipLevel.service.VipLevelService;

/**
 * 会员等级Service业务层处理
 *
 * @author ruoyi
 * @date 2024-12-09
 */
@Service
public class VipLevelServiceImpl implements VipLevelService
{
    @Autowired
    private VipLevelMapper vipLevelMapper;

    @Autowired
    private VipLevelValidator vipLevelValidator;

    /**
     * 查询会员等级
     *
     * @param id 会员等级主键
     * @return 会员等级
     */
    @Override
    public VipLevelVO selectVipLevelById(Long id)
    {
        return vipLevelMapper.selectVipLevelById(id);
    }

    /**
     * 查询会员等级列表
     *
     * @param vipLevel 会员等级
     * @return 会员等级
     */
    @Override
    public List<VipLevelVO> selectVipLevelList(VipLevelQuery vipLevel)
    {
        return vipLevelMapper.selectVipLevelList(vipLevel);
    }

    /**
     * 新增会员等级
     *
     * @param vipLevel 会员等级
     * @return 结果
     */
    @Override
    public int insertVipLevel(VipLevel vipLevel)
    {
        vipLevel.setCreateTime(DateUtils.getNowDate());
        return vipLevelMapper.insertVipLevel(vipLevel);
    }

    /**
     * 修改会员等级
     *
     * @param vipLevel 会员等级
     * @return 结果
     */
    @Override
    public int updateVipLevel(VipLevel vipLevel)
    {
        return vipLevelMapper.updateVipLevel(vipLevel);
    }

    /**
     * 批量删除会员等级
     *
     * @param ids 需要删除的会员等级主键
     * @return 结果
     */
    @Override
    public int deleteVipLevelByIds(List<Long> ids) {
        if (CollectionUtils.isEmptyElement(ids)) {
            return 0;
        }
        vipLevelValidator.beforeDel(ids);
        return vipLevelMapper.deleteVipLevelByIds(ids);
    }

    /**
     * 删除会员等级信息
     *
     * @param id 会员等级主键
     * @return 结果
     */
    @Override
    public int deleteVipLevelById(Long id)
    {
        return vipLevelMapper.deleteVipLevelById(id);
    }

    @Override
    public List<VipLevelVO> selectByIds(List<Long> ids) {
        if (CollectionUtils.isEmptyElement(ids)) {
            return Collections.emptyList();
        }
        VipLevelQuery query = new VipLevelQuery();
        query.setIds(ids);
        return this.selectVipLevelList(query);
    }
}
