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.TPfSysOplog;
import com.blueland.service.ISysOplogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blueland.bo.SysOplogEntity;
import com.blueland.dao.SysOplogDao;

@Service
public class SysOplogServiceImpl extends ServiceImpl<SysOplogDao, TPfSysOplog> implements ISysOplogService {
	@Autowired
	//SysOplog对应的DAO类,主要用于数据库的增删改查等操作
	private SysOplogDao sysOplogDao;
	
	/**
	 * 根据条件查询列表(分页)
	 */
	@Override
	public Page<SysOplogEntity> findSysOplogPageListByParams(Map<String,Object> tagSysOplog,int curPage,int pageSize){
		Page<SysOplogEntity> page = new Page<>(curPage, pageSize);
		Page<SysOplogEntity> list = sysOplogDao.findSysOplogPageByParams(page, tagSysOplog);
	   
	   return list;
	}

	@Override
	public TPfSysOplog get(SysOplogEntity model) {
		return sysOplogDao.selectOne(buildQueryWrapper(model));
	}

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

	private LambdaQueryWrapper<TPfSysOplog> buildQueryWrapper(SysOplogEntity bo) {
		LambdaQueryWrapper<TPfSysOplog> lqw = Wrappers.lambdaQuery();
		lqw.eq(ObjectUtil.isNotEmpty(bo.getId()), TPfSysOplog::getId, bo.getId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getUserId()), TPfSysOplog::getUserId, bo.getUserId());
		lqw.like(ObjectUtil.isNotEmpty(bo.getUserName()), TPfSysOplog::getUserName, bo.getUserName());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getBizId()), TPfSysOplog::getBizId, bo.getBizId());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getBizType()), TPfSysOplog::getBizType, bo.getBizType());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getType()), TPfSysOplog::getType, bo.getType());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getStatus()), TPfSysOplog::getStatus, bo.getStatus());
		lqw.like(ObjectUtil.isNotEmpty(bo.getContent()), TPfSysOplog::getContent, bo.getContent());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getAceessIp()), TPfSysOplog::getAceessIp, bo.getAceessIp());
		lqw.eq(ObjectUtil.isNotEmpty(bo.getAceessBrowse()), TPfSysOplog::getAceessBrowse, bo.getAceessBrowse());
		lqw.like(ObjectUtil.isNotEmpty(bo.getRemark()), TPfSysOplog::getRemark, bo.getRemark());
		return lqw;
	}
}
