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

import com.railway.business.baseinfo.domain.BusDmcgyq;
import com.railway.business.baseinfo.mapper.BusDmcgyqMapper;
import com.railway.business.baseinfo.service.IBusDmcgyqService;
import com.railway.common.utils.SecurityUtils;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 基础数据-地面磁感应器
* @author zcf
* @date 2021/10/26
*/
@Service
@Transactional(readOnly = true)
public class BusDmcgyqServiceImpl implements IBusDmcgyqService{

	private final BusDmcgyqMapper busDmcgyqMapper;

	public BusDmcgyqServiceImpl(BusDmcgyqMapper busDmcgyqMapper) {
		this.busDmcgyqMapper = busDmcgyqMapper;
	}

	/**
	* 新增
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int create(BusDmcgyq busDmcgyq) {
	    busDmcgyq.setCreateTime(new Date());
	    busDmcgyq.setCreateBy(SecurityUtils.getUsername());
		return busDmcgyqMapper.insert(busDmcgyq);
	}

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

	/**
	* 更新
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int update(BusDmcgyq busDmcgyq) {
		busDmcgyq.setUpdateTime(new Date());
    	busDmcgyq.setUpdateBy(SecurityUtils.getUsername());
		return busDmcgyqMapper.update(busDmcgyq);
	}

	/**
	* 获取单个
	*/
	@Override
	public BusDmcgyq getInfo(String id) {
		return busDmcgyqMapper.getInfo(id);
	}

	/**
	* 查询列表
	*/
	@Override
	public List<BusDmcgyq> getList(BusDmcgyq busDmcgyq) {
		return busDmcgyqMapper.getList(busDmcgyq);
	}
}
