package com.miaxis.newgzpt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miaxis.common.annotation.DataSource;
import com.miaxis.common.enums.DataSourceTypeEnum;
import com.miaxis.newgzpt.domain.GzptSchActivation;
import com.miaxis.newgzpt.dto.GzptSchActivationListDTO;
import com.miaxis.newgzpt.mapper.GzptSchActivationMapper;
import com.miaxis.newgzpt.service.IGzptSchActivationService;
import com.miaxis.newgzpt.vo.GzptSchActivationListVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 * 视频VIP表 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-01-27
 */
@Service
@DataSource(value = DataSourceTypeEnum.NEWGZPT)
public class GzptSchActivationServiceImpl extends ServiceImpl<GzptSchActivationMapper, GzptSchActivation> implements IGzptSchActivationService {


    @Resource
    private GzptSchActivationMapper mapper;

    @Override
    public void saveSchActivation(GzptSchActivation schActivation) {
        mapper.saveSchActivation(schActivation);
    }

    @Override
    public int isSchActivation(Long userId) {
        GzptSchActivation schActivation= mapper.getSchActivation(userId);
        if(schActivation!=null){
            if(schActivation.getIsDel()!=null && schActivation.getIsDel()==0) {
                return 1;
            } else if (schActivation.getIsDel()!=null && schActivation.getIsDel()==1) {
                return 2;
            }
            return 0;
        } else {
            return 0;
        }
    }

    @Override
    public void delSchActivationByUserId(Long userId) {
        mapper.delSchActivationByUserId(userId);
    }

    @Override
    public void upDelSchActivationByUserId(Long userId,Integer state) { mapper.upDelSchActivationByUserId(userId,state); }

    @Override
    public List<GzptSchActivationListVO> selectSchActivationList(GzptSchActivationListDTO schActivationDTO) {
        List<GzptSchActivationListVO> schActivationList = mapper.selectSchActivationList(schActivationDTO);
        return schActivationList;
    }




}
