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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.railway.business.baseinfo.mapper.BasePreventThawMapper;
import com.railway.business.baseinfo.domain.BasePreventThaw;
import com.railway.business.baseinfo.service.IBasePreventThawService;
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 BasePreventThawServiceImpl implements IBasePreventThawService{
@Autowired
private BasePreventThawMapper basePreventThawMapper;

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

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

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

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

	/**
	* 查询列表
	*/
	public List<BasePreventThaw> getList(BasePreventThaw basePreventThaw) {
		return basePreventThawMapper.getList(basePreventThaw);
	}
}
