package com.railway.business.safetool.service.impl;

import com.railway.business.safetool.domain.SecScheduledTool;
import com.railway.business.safetool.mapper.SecScheduledToolMapper;
import com.railway.business.safetool.service.ISecScheduledToolService;
import com.railway.common.utils.SecurityUtils;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 安全计划和工具关系表
* @author lijie
* @date 2021/12/04
*/
@Service
public class SecScheduledToolServiceImpl implements ISecScheduledToolService{

	private final SecScheduledToolMapper secScheduledToolMapper;

	public SecScheduledToolServiceImpl(SecScheduledToolMapper secScheduledToolMapper) {
		this.secScheduledToolMapper = secScheduledToolMapper;
	}

	/**
	* 新增
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int create(SecScheduledTool secScheduledTool) {
	    secScheduledTool.setCreateTime(new Date());
        secScheduledTool.setCreateBy(SecurityUtils.getUsername());
		return secScheduledToolMapper.insert(secScheduledTool);
	}

	/**
	* 删除
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int delete(String[] ids) {
		int r =0;
		for (String id : ids) {
//需根据需求进行删除
//			int j= secScheduledToolMapper.delete(Long.parseLong(id));
//			r = r + j;
		}
		return	r;
	}

	/**
	* 更新
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int update(SecScheduledTool secScheduledTool) {
		secScheduledTool.setUpdateTime(new Date());
    	secScheduledTool.setUpdateBy(SecurityUtils.getUsername());
		return secScheduledToolMapper.update(secScheduledTool);
	}

	/**
	* 获取单个
	*/
	@Override
	public SecScheduledTool getInfo(String id) {
		return secScheduledToolMapper.getInfo(id);
	}

	/**
	* 查询列表
	*/
	@Override
	public List<SecScheduledTool> getList(SecScheduledTool secScheduledTool) {
		return secScheduledToolMapper.getList(secScheduledTool);
	}
}
