package com.blueland.service.impl;


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

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blueland.model.TPfSysPvlog;
import com.blueland.service.ISysPvlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blueland.bo.SysPvlogEntity;
import com.blueland.dao.SysPvlogDao;

@Service
public class SysPvlogServiceImpl extends ServiceImpl<SysPvlogDao, TPfSysPvlog> implements ISysPvlogService {
	@Autowired
	//SysPvlog对应的DAO类,主要用于数据库的增删改查等操作
	private SysPvlogDao sysPvlogDao;
	
	/**
	 * 根据条件查询列表(分页)
	 */
	@Override
	public Page<SysPvlogEntity> findSysPvlogPageListByParams(Map<String,Object> tagSysPvlog,int curPage,int pageSize){
		Page<SysPvlogEntity> page = new Page<>(curPage,pageSize);
		Page<SysPvlogEntity> list = sysPvlogDao.findSysPvlogPageByParams(page, tagSysPvlog);
	   
	   return list;
	}

	@Override
	public TPfSysPvlog get(SysPvlogEntity bo){
		return sysPvlogDao.selectOne(buildQueryWrapper(bo));
	}

	@Override
	public Page<SysPvlogEntity> findPage(SysPvlogEntity bo) {
		Page<SysPvlogEntity> page = new Page(bo.getPageNum(), bo.getPageSize());
		return this.baseMapper.findPage(page, bo);
	}

	private LambdaQueryWrapper<TPfSysPvlog> buildQueryWrapper(SysPvlogEntity bo) {
		LambdaQueryWrapper<TPfSysPvlog> lqw = Wrappers.lambdaQuery();
		lqw.eq(ObjectUtil.isNotEmpty(bo.getId()), TPfSysPvlog::getId, bo.getId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getUserId()), TPfSysPvlog::getUserId, bo.getUserId());
		lqw.like(ObjectUtil.isNotEmpty(bo.getUserName()), TPfSysPvlog::getUserName, bo.getUserName());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getBizId()), TPfSysPvlog::getBizId, bo.getBizId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getBizType()), TPfSysPvlog::getBizType, bo.getBizType());
		lqw.like(ObjectUtil.isNotEmpty(bo.getAceessTitle()), TPfSysPvlog::getAceessTitle, bo.getAceessTitle());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getAceessUrl()), TPfSysPvlog::getAceessUrl, bo.getAceessUrl());
		lqw.like(ObjectUtil.isNotEmpty(bo.getAceessSource()), TPfSysPvlog::getAceessSource, bo.getAceessSource());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getAceessIp()), TPfSysPvlog::getAceessIp, bo.getAceessIp());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getAceessBrowse()), TPfSysPvlog::getAceessBrowse, bo.getAceessBrowse());
		lqw.like(ObjectUtil.isNotEmpty(bo.getRemark()), TPfSysPvlog::getRemark, bo.getRemark());
		return lqw;
	}
}
