package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;

import cn.estsh.i3plus.core.api.iservice.busi.ISysTaskTimeRecordingService;
import cn.estsh.i3plus.pojo.platform.platbean.SysLogTaskTime;
import cn.estsh.i3plus.pojo.platform.repository.SysTaskTimeRecordingRepository;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description : 定时任务执行记录业务接口实现
 * @Reference :
 * @Author : wei.peng
 * @Date : 2018-10-22 16:58:44.011
 * @Modify :
 **/
@Service
public class SysTaskTimeRecordingService implements ISysTaskTimeRecordingService {

    public static final Logger LOGGER = LoggerFactory.getLogger(SysTaskTimeRecordingService.class);

    @Autowired
    private SysTaskTimeRecordingRepository taskTimeRecordingRDao;

    @Override
    @ApiOperation(value = "更新任务周期信息")
    public void updateSysTaskTimeRecording(SysLogTaskTime taskTimeRecording) {
        LOGGER.info("定时任务执行记录 TASK_TIMED_RECORDING :{}", taskTimeRecording);
        taskTimeRecordingRDao.update(taskTimeRecording);
    }

    @Override
    @ApiOperation(value = "删除任务周期信息",notes = "根据 ID 删除任务周期信息")
    public void deleteSysTaskTimeRecordingById(Long id) {
        LOGGER.info("定时任务执行记录 TASK_TIMED_RECORDING Key:{}", id);
        taskTimeRecordingRDao.deleteById(id);
    }

    @Override
    @ApiOperation(value = "新增任务周期信息")
    public SysLogTaskTime insertSysTaskTimeRecording(SysLogTaskTime taskTimeRecording) {
        LOGGER.info("定时任务执行记录 TASK_TIMED_RECORDING :{}", taskTimeRecording);
        return taskTimeRecordingRDao.insert(taskTimeRecording);
    }

    @Override
    @ApiOperation(value = "查询任务周期信息",notes = "查询所有任务周期信息")
    public List<SysLogTaskTime> findSysTaskTimeRecordingAll() {
        LOGGER.info("定时任务执行记录 TASK_TIMED_RECORDING find All");
        return taskTimeRecordingRDao.findAll();
    }

    @Override
    @ApiOperation(value = "查询任务周期信息",notes = "查询 ID 任务周期信息")
    public SysLogTaskTime getSysTaskTimeRecordingById(Long id) {
        LOGGER.info("定时任务执行记录 TASK_TIMED_RECORDING find id:{}", id);
        return taskTimeRecordingRDao.getOne(id);
    }
}
