package com.railway.system.service.impl;

import com.railway.common.utils.SecurityUtils;
import com.railway.system.domain.SysScheduledTask;
import com.railway.system.mapper.SysScheduledTaskMapper;
import com.railway.system.service.ISysScheduledTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
/**
* 系统计划任务表
* @author author
* @date 2021/12/09
*/
@Service
@Transactional(readOnly = true)
public class SysScheduledTaskServiceImpl implements ISysScheduledTaskService {
@Autowired
private SysScheduledTaskMapper sysScheduledTaskMapper;

	/**
	* 新增
	*/
	@Transactional(rollbackFor = Exception.class)
	public int create(SysScheduledTask sysScheduledTask) {
	    sysScheduledTask.setCreateTime(new Date());
        sysScheduledTask.setCreateBy(SecurityUtils.getUsername());
		return sysScheduledTaskMapper.insert(sysScheduledTask);
	}

	/**
	* 删除
	*/
	@Transactional(rollbackFor = Exception.class)
	public int delete(String[] ids) {
		int r =0;
		for (String id : ids) {
			int j= sysScheduledTaskMapper.delete(id);
			r = r + j;
		}
		return	r;
	}

	/**
	* 更新
	*/
	@Transactional(rollbackFor = Exception.class)
	public int update(SysScheduledTask sysScheduledTask) {
		sysScheduledTask.setUpdateTime(new Date());
    	sysScheduledTask.setUpdateBy(SecurityUtils.getUsername());
		return sysScheduledTaskMapper.update(sysScheduledTask);
	}

	/**
	* 获取单个
	*/
	public SysScheduledTask getInfo(String id) {
		return sysScheduledTaskMapper.getInfo(id);
	}

	@Override
	public SysScheduledTask getInfoByName(String name) {
		return sysScheduledTaskMapper.getInfoByName(name);
	}

	/**
	* 查询列表
	*/
	public List<SysScheduledTask> getList(SysScheduledTask sysScheduledTask) {
		return sysScheduledTaskMapper.getList(sysScheduledTask);
	}
}
