package com.platform.service.custom;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.entity.TmGoodsDetailLog;
import com.platform.service.impl.TmGoodsDetailLogServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * @author abnerhou
 * @date 2020/9/27 16:24
 * @desciption
 */
@Service
@Slf4j
public class GoodsDetailLogService extends TmGoodsDetailLogServiceImpl {

    public long countByVisitDate(LocalDate visitDate , String sceneNum){
        QueryWrapper<TmGoodsDetailLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("visit_date" , visitDate);
        queryWrapper.eq("enable" , 1);
        queryWrapper.eq("scene_num" , sceneNum);
        IPage<TmGoodsDetailLog> page = new Page<>(1 , 10);
        IPage<TmGoodsDetailLog> resultPage = null;
        resultPage = getBaseMapper().selectPage(page , queryWrapper);
        if(null == resultPage){
            return 0;
        }
        return resultPage.getTotal();
    }
}
