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

import com.railway.business.safetool.domain.SecExperimentTool;
import com.railway.business.safetool.mapper.SecExperimentToolMapper;
import com.railway.business.safetool.service.ISecExperimentToolService;
import org.springframework.stereotype.Service;
import com.railway.common.utils.SecurityUtils;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Date;
/**
* 送检记录工具表
* @author lijie
* @date 2021/12/25
*/
@Service
public class SecExperimentToolServiceImpl implements ISecExperimentToolService {

	private final SecExperimentToolMapper secExperimentToolMapper;

	public SecExperimentToolServiceImpl(SecExperimentToolMapper secExperimentToolMapper) {
		this.secExperimentToolMapper = secExperimentToolMapper;
	}

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

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

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

	/**
	* 获取单个
	*/
	@Override
	public SecExperimentTool getInfo(Long id) {
		return secExperimentToolMapper.getInfo(id);
	}

	/**
	* 查询列表
	*/
	@Override
	public List<SecExperimentTool> getList(SecExperimentTool secExperimentTool) {
		return secExperimentToolMapper.getList(secExperimentTool);
	}
}
