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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventWindMapper;
import com.railway.business.baseinfo.domain.BasePreventWind;
import com.railway.business.baseinfo.service.IBasePreventWindService;
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/13
*/
@Service
@Transactional(readOnly = true)
public class BasePreventWindServiceImpl implements IBasePreventWindService{
@Autowired
private BasePreventWindMapper basePreventWindMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventWind> getList(BasePreventWind basePreventWind) {
		return basePreventWindMapper.getList(basePreventWind);
	}
}
