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

import com.railway.business.app.domain.AppUpgrade;
import com.railway.business.app.mapper.AppUpgradeMapper;
import com.railway.business.app.service.IAppUpgradeService;
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;

/**
 * apk版本升级表
 *
 * @author zhaomn
 * @date 2021/12/13
 */
@Service
public class AppUpgradeServiceImpl implements IAppUpgradeService {

  private final AppUpgradeMapper appUpgradeMapper;

	public AppUpgradeServiceImpl(AppUpgradeMapper appUpgradeMapper) {
		this.appUpgradeMapper = appUpgradeMapper;
	}

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

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

  /**
   * 删除
   */
  @Override
  public int delete(Long id) {
    return appUpgradeMapper.delete(id);
  }

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

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

  /**
   * 查询列表
   */
	@Override
  public List<AppUpgrade> getList(AppUpgrade appUpgrade) {
    return appUpgradeMapper.getList(appUpgrade);
  }

  /**
   * 获取单个
   */
  @Override
  public AppUpgrade getNewestInfo() {
    return appUpgradeMapper.getNewestInfo();
  }

}
