package com.diagbot.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.dto.UserAndProdutDTO;
import com.diagbot.entity.OpenedProducts;
import com.diagbot.entity.OpenedProductsIndex;
import com.diagbot.entity.wrapper.OpendProductWrapper;
import com.diagbot.mapper.OpenedProductsMapper;
import com.diagbot.service.OpenedProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 已开通产品 服务实现类
 * </p>
 *
 * @author gaodm
 * @since 2018-09-18
 */
@Service
public class OpenedProductsServiceImpl extends ServiceImpl<OpenedProductsMapper, OpenedProducts> implements OpenedProductsService {

    @Autowired
    OpenedProductsMapper openedProductsMapper;

    @Override
    public IPage<OpenedProducts> selectOpendInfoByUserId(Page<OpenedProducts> page, int userId) {
        return baseMapper.selectOpendInfoByUserId(page,userId);
    }

    /**
     * 查询已开通产品
     * @param map 查询条件
     * @return
     */
    public List<OpenedProducts> selectOpenedProducts(Map<String,Object> map){
        return baseMapper.selectOpenedProducts(map);
    }

    @Override
    public List<OpenedProducts> getByAppkeyAndSecret(Map<String, Object> map) {
        return openedProductsMapper.getByAppkeyAndSecret(map);
    }

	@Override
	public List<UserAndProdutDTO> getInformationAvailableByUserId(Long userId) {
		// TODO Auto-generated method stub
		return openedProductsMapper.getInformationAvailableByUserId(userId);
	}

	@Override
	public boolean startAndendByuserId(OpenedProducts openedProducts) {
		// TODO Auto-generated method stub
		return openedProductsMapper.startAndendByuserId(openedProducts);
	}

	@Override
	public boolean delInformationAvailable(OpenedProducts openedProducts) {
		// TODO Auto-generated method stub
		return openedProductsMapper.delInformationAvailable(openedProducts);
	}

	@Override
	public boolean modifyOpeningTime(OpenedProducts openedProducts) {
		// TODO Auto-generated method stub
		return openedProductsMapper.modifyOpeningTime(openedProducts);
	}

    @Override
    public List<OpendProductWrapper> getByProductId(OpenedProductsIndex openedProductsIndex) {
        return baseMapper.getByProductId(openedProductsIndex);
    }
}
