package com.hzya.frame.sysnew.integtationTaskLog.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sysnew.integtationTaskLog.entity.IntegrationTaskLogEntity;
import com.hzya.frame.sysnew.integtationTaskLog.dao.IIntegrationTaskLogDao;
import com.hzya.frame.sysnew.integtationTaskLog.service.IIntegrationTaskLogService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.hzya.frame.basedao.service.impl.BaseService;

import java.util.List;

/**
 * 集成任务-实例详情(IntegrationTaskLog)表服务实现类
 *
 * @author makejava
 * @since 2024-05-06 15:37:55
 */
@Service(value = "integrationTaskLogService")
public class IntegrationTaskLogServiceImpl extends BaseService<IntegrationTaskLogEntity, String> implements IIntegrationTaskLogService {
     
    private IIntegrationTaskLogDao integrationTaskLogDao;
    
    @Autowired
	public void setIntegrationTaskLogDao(IIntegrationTaskLogDao dao) {
		this.integrationTaskLogDao = dao;
		this.dao = dao;
	}

	/**
	 * @param jsonObject
	 * @return com.hzya.frame.web.entity.JsonResultEntity
	 * @Author lvleigang
	 * @Description 查询任务日志列表分页
	 * @Date 11:52 上午 2024/3/27
	 **/
	@Override
	public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
		IntegrationTaskLogEntity entity = getData("jsonStr", jsonObject, IntegrationTaskLogEntity.class);
		//判断分页
		if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
			return BaseResult.getFailureMessageEntity("分页查询参数不存在");
		}
		PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
		List<IntegrationTaskLogEntity> list = integrationTaskLogDao.queryByLike(entity);
		PageInfo pageInfo = new PageInfo(list);
		return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
	}


	/**
	 * @param jsonObject
	 * @return com.hzya.frame.web.entity.JsonResultEntity
	 * @Author lvleigang
	 * @Description 获取任务日志
	 * @Date 2:36 下午 2024/3/27
	 **/
	@Override
	public JsonResultEntity getEntity(JSONObject jsonObject) {
		IntegrationTaskLogEntity entity = getData("jsonStr", jsonObject, IntegrationTaskLogEntity.class);
		if (entity == null) {
			return BaseResult.getFailureMessageEntity("参数不允许为空");
		}
		if (entity.getId() == null || "".equals(entity.getId())) {
			return BaseResult.getFailureMessageEntity("系统错误");
		}
		entity = integrationTaskLogDao.get(entity.getId());
		if (entity == null) {
			return BaseResult.getFailureMessageEntity("获取任务日志失败");
		}
		return BaseResult.getSuccessMessageEntity("获取任务日志成功", entity);
	}
}
