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

import com.railway.business.app.domain.AppFeedback;
import com.railway.business.app.mapper.AppFeedbackMapper;
import com.railway.business.app.service.IAppFeedbackService;
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 ZhaoMn
 * @date 2021/12/25
 */
@Service
public class AppFeedbackServiceImpl implements IAppFeedbackService {

  private final AppFeedbackMapper appFeedbackMapper;

  public AppFeedbackServiceImpl(AppFeedbackMapper appFeedbackMapper) {
    this.appFeedbackMapper = appFeedbackMapper;
  }

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

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

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

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

  /**
   * 查询列表
   */
  @Override
  public List<AppFeedback> getList(AppFeedback appFeedback) {
    return appFeedbackMapper.getList(appFeedback);
  }
}
