package com.sunyard.ssp.modules.monitor.log.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunyard.ssp.modules.monitor.log.entity.SysLog;
import com.sunyard.ssp.modules.monitor.log.mapper.SysLogMapper;
import com.sunyard.ssp.modules.monitor.log.service.ISysLogService;
import com.sunyard.ssp.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fyc
 * @since 2020-03-31
 */
@Slf4j
@Service
@Transactional
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    @Override
    public IPage<SysLog> queryList(Integer pageNumber, Integer pageSize, String keyWord, String startTime, String endTime) {
        Page<SysLog> sysLogPage = new Page<>(pageNumber,pageSize);
        IPage<SysLog> sysLogIPage = sysLogPage.setRecords(sysLogMapper.queryList(sysLogPage,keyWord, DateUtil.StringToDate(startTime),DateUtil.StringToDate(endTime)));
        return sysLogIPage;
    }

    @Override
    public Boolean truncateTable() {
        Integer i = sysLogMapper.truncateTable();
        if (i < 0) {
            return false;
        }
        return true;
    }
}
