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

import cn.hutool.core.map.MapProxy;
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.Constant;
import com.sqx.common.utils.PageUtils;
import com.sqx.modules.job.dao.ScheduleJobLogDao;
import com.sqx.modules.job.entity.ScheduleJobLogEntity;
import com.sqx.modules.job.service.ScheduleJobLogService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService {

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

		MapProxy proxy = MapProxy.create(params);
		long pageNum = proxy.getLong(Constant.PAGE, 1L);
		long pageSize = proxy.getLong(Constant.LIMIT, 10L);
		PageHelper.startPage((int) pageNum, (int) pageSize);
		return PageUtils.page(new PageInfo<>(this.list(new QueryWrapper<ScheduleJobLogEntity>().like(StringUtils.isNotBlank(jobId),"job_id", jobId).orderByDesc("create_time"))));
	}

}
