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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventThunderMapper;
import com.railway.business.baseinfo.domain.BasePreventThunder;
import com.railway.business.baseinfo.service.IBasePreventThunderService;
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 BasePreventThunderServiceImpl implements IBasePreventThunderService{
@Autowired
private BasePreventThunderMapper basePreventThunderMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventThunder> getList(BasePreventThunder basePreventThunder) {
		return basePreventThunderMapper.getList(basePreventThunder);
	}
}
