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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventRustMapper;
import com.railway.business.baseinfo.domain.BasePreventRust;
import com.railway.business.baseinfo.service.IBasePreventRustService;
import org.springframework.beans.factory.annotation.Autowired;
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 wuhonghao
* @date 2021/11/12
*/
@Service
@Transactional(readOnly = true)
public class BasePreventRustServiceImpl implements IBasePreventRustService{
@Autowired
private BasePreventRustMapper basePreventRustMapper;

	/**
	* 新增
	*/
	@Transactional(rollbackFor = Exception.class)
	public int create(BasePreventRust basePreventRust) {
	    basePreventRust.setCreateTime(new Date());
        basePreventRust.setCreateBy(SecurityUtils.getUsername());
		if(basePreventRust.getPiecewise()==null||basePreventRust.getPiecewise().equals("")){
			basePreventRust.setPiecewise("changchun");
		}
		return basePreventRustMapper.insert(basePreventRust);
	}

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventRust> getList(BasePreventRust basePreventRust) {
		return basePreventRustMapper.getList(basePreventRust);
	}
}
