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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventFloodMapper;
import com.railway.business.baseinfo.domain.BasePreventFlood;
import com.railway.business.baseinfo.service.IBasePreventFloodService;
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 BasePreventFloodServiceImpl implements IBasePreventFloodService{
@Autowired
private BasePreventFloodMapper basePreventFloodMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventFlood> getList(BasePreventFlood basePreventFlood) {
		return basePreventFloodMapper.getList(basePreventFlood);
	}
}
