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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventIceMapper;
import com.railway.business.baseinfo.domain.BasePreventIce;
import com.railway.business.baseinfo.service.IBasePreventIceService;
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 BasePreventIceServiceImpl implements IBasePreventIceService{
@Autowired
private BasePreventIceMapper basePreventIceMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventIce> getList(BasePreventIce basePreventIce) {
		return basePreventIceMapper.getList(basePreventIce);
	}
}
