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

import com.railway.business.baseinfo.domain.vo.BusSmartQueryVo;
import com.railway.business.baseinfo.mapper.BusSdtzMapper;
import com.railway.business.baseinfo.domain.BusSdtz;
import com.railway.business.baseinfo.service.IBusSdtzService;
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/10/26
 */
@Service
@Transactional(readOnly = true)
public class BusSdtzServiceImpl implements IBusSdtzService {

  private final BusSdtzMapper busSdtzMapper;

  public BusSdtzServiceImpl(BusSdtzMapper busSdtzMapper) {
    this.busSdtzMapper = busSdtzMapper;
  }

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

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

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

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

  /**
   * 查询列表
   */
  @Override
  public List<BusSdtz> getList(BusSdtz busSdtz) {
    return busSdtzMapper.getList(busSdtz);
  }


  @Override
  public List<BusSdtz> smartQuery(BusSmartQueryVo busSmartQueryVo) {
    return busSdtzMapper.smartQuery(busSmartQueryVo);
  }
}
