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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventBirdMapper;
import com.railway.business.baseinfo.domain.BasePreventBird;
import com.railway.business.baseinfo.service.IBasePreventBirdService;
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 BasePreventBirdServiceImpl implements IBasePreventBirdService{
@Autowired
private BasePreventBirdMapper basePreventBirdMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventBird> getList(BasePreventBird basePreventBird) {
		return basePreventBirdMapper.getList(basePreventBird);
	}
}
