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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventForeignMapper;
import com.railway.business.baseinfo.domain.BasePreventForeign;
import com.railway.business.baseinfo.service.IBasePreventForeignService;
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 BasePreventForeignServiceImpl implements IBasePreventForeignService{
@Autowired
private BasePreventForeignMapper basePreventForeignMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventForeign> getList(BasePreventForeign basePreventForeign) {
		return basePreventForeignMapper.getList(basePreventForeign);
	}
}
