package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.dto.MarkingCouponDataReportDto;
import com.iformall.domain.po.WxUserVisit;
import com.iformall.domain.vo.TouchUsersReportVo;
import com.iformall.mapper.WxUserVisitMapper;
import com.iformall.service.WxUserVisitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class WxUserVisitServiceImpl implements WxUserVisitService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxUserVisitMapper wxUserVisitMapper;


    @Override
    public PageInfo<WxUserVisit> listAsPage(WxUserVisit record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxUserVisitMapper.findList(record));
    }

    @Override
    public List<WxUserVisit> getList(WxUserVisit record) {
        return wxUserVisitMapper.findList(record);
    }

    @Override
    public WxUserVisit getById(Long id) {
        return wxUserVisitMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(WxUserVisit record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            wxUserVisitMapper.insert(record);
        } else {
            wxUserVisitMapper.updateById(record);
        }
    }

    @Override
    public void deleteById(Long id) {
        wxUserVisitMapper.deleteById(id);
    }

	@Override
	public List<TouchUsersReportVo> touchUsersReportList(MarkingCouponDataReportDto markingCouponDataReportDto) {
		return  wxUserVisitMapper.touchUsersReportList(markingCouponDataReportDto);
	}


    @Override
    public Long queryVisitUv(HashMap<String, Object> params) {
        return wxUserVisitMapper.queryVisitUv(params);
    }
}
