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

import com.railway.business.baseinfo.mapper.BusJcxcMapper;
import com.railway.business.baseinfo.domain.BusJcxc;
import com.railway.business.baseinfo.service.IBusJcxcService;
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 zcf
 * @date 2021/10/26
 */
@Service
@Transactional(readOnly = true)
public class BusJcxcServiceImpl implements IBusJcxcService {

  private final BusJcxcMapper busJcxcMapper;

  public BusJcxcServiceImpl(BusJcxcMapper busJcxcMapper) {
    this.busJcxcMapper = busJcxcMapper;
  }

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

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

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

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

  /**
   * 查询列表
   */
  @Override
  public List<BusJcxc> getList(BusJcxc busJcxc) {
    return busJcxcMapper.getList(busJcxc);
  }
}
