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

import com.railway.business.baseinfo.domain.BusGlkg;
import com.railway.business.baseinfo.mapper.BusGlkgMapper;
import com.railway.business.baseinfo.service.IBusGlkgService;
import com.railway.common.enums.DelFlagEnum;
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 author
* @date 2021/10/26
*/
@Service
@Transactional(readOnly = true)
public class BusGlkgServiceImpl implements IBusGlkgService{

	private final BusGlkgMapper busGlkgMapper;

	public BusGlkgServiceImpl(BusGlkgMapper busGlkgMapper) {
		this.busGlkgMapper = busGlkgMapper;
	}

	/**
	* 新增
	*/
	@Override
	@Transactional(rollbackFor = Exception.class)
	public int create(BusGlkg busGlkg) {
	    busGlkg.setCreateTime(new Date());
        busGlkg.setCreateBy(SecurityUtils.getUsername());
		busGlkg.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
		return busGlkgMapper.insert(busGlkg);
	}

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

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

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

	/**
	* 查询列表
	*/
	@Override
	public List<BusGlkg> getList(BusGlkg busGlkg) {
		return busGlkgMapper.getList(busGlkg);
	}
}
