package cn.pluss.platform.merchantChannel;

import cn.pluss.platform.entity.MerchantChannel;
import cn.pluss.platform.entity.MerchantChannelStatus;
import cn.pluss.platform.mapper.MerchantChannelMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.val;

import java.util.List;

/**
 * @author DJH
 */
public interface MerchantChannelService extends IService<MerchantChannel> {

    /**
     * 获取有效的通道记录，
     * @param channelId 通道id
     * @return      通道记录
     */
    default MerchantChannel getValidChannel(String channelId) {
        MerchantChannel merchantChannel = new MerchantChannel().setId(Integer.parseInt(channelId));
        return getBaseMapper().selectOne(new QueryWrapper<>(merchantChannel));
    }

    /**
     * 获取所有有效的通道
     * @return 通道记录
     */
    default List<MerchantChannel> getValidChannelList() {
        MerchantChannel merchantChannel = new MerchantChannel().setStatus("1");
        return getBaseMapper().selectList(new QueryWrapper<>(merchantChannel));
    }

    /**
     * 获取所有有效的通道id
     * @return 通道记录
     */
    default List<Integer> getValidChannelIdList() {
        return ((MerchantChannelMapper) getBaseMapper()).selectValidIdList();
    }
}
