package com.sqx.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sqx.common.utils.PageUtils;
import com.sqx.modules.sys.dao.SysLogDao;
import com.sqx.modules.sys.entity.SysLogEntity;
import com.sqx.modules.sys.service.SysLogService;
import com.sqx.modules.utils.ParamPageUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

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


@Service("sysLogService")
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLogEntity> implements SysLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");

        PageHelper.startPage(ParamPageUtils.getPageNum(params), ParamPageUtils.getPageSize(params));
        List<SysLogEntity> list = baseMapper.selectList(new QueryWrapper<SysLogEntity>().like(StringUtils.isNotBlank(key), "username", key));
        PageInfo<SysLogEntity> pageInfo = new PageInfo<>(list);
        return PageUtils.page(pageInfo);
    }
}
