/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.scriptcase.api.atuScript.service;

import com.hzbank.testteam.autotest.dependencies.baseDefineDependency.dto.TagDto;
import com.hzbank.testteam.autotest.dependencies.baseDefineDependency.vo.ResponseVO;
import net.northking.cctp.common.db.BasicService;
import net.northking.cctp.common.db.excel.AbstractExcelService;
import net.northking.cctp.common.db.excel.ExcelHeader;
import net.northking.cctp.scriptcase.db.entity.AtuScriptTag;
import net.northking.cctp.scriptcase.db.service.AtuScriptTagService;
import net.northking.cctp.scriptcase.dto.atuScript.atuScriptTag.AtuScriptTagAddDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 脚本标签表服务实现类
 *
 * @author maven-cctp-plugin
 * @since 1.0
 */

@Service
@ConditionalOnMissingBean(name = "AtuScriptTagApiServiceImpl")
public class AtuScriptTagApiServiceImpl extends AbstractExcelService<AtuScriptTag> implements AtuScriptTagApiService
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(AtuScriptTagApiServiceImpl.class);

  @Autowired
  private AtuScriptTagService atuScriptTagService;

  //= Excel 导入导出相关代码 start ==================//
  @Override
  public BasicService<AtuScriptTag> getService()
  {
    return this.atuScriptTagService;
  }

  @Override
  public ExcelHeader[] excelHeaders()
  {
    ExcelHeader scriptId = new ExcelHeader("脚本ID", "scriptId", String.class);
    ExcelHeader tagId = new ExcelHeader("标签ID", "tagId", String.class);
    ExcelHeader projectId = new ExcelHeader("系统ID", "projectId", String.class);
    ExcelHeader tenentId = new ExcelHeader("租户号", "tenentId", String.class);
    ExcelHeader createdBy = new ExcelHeader("创建人", "createdBy", String.class);
    ExcelHeader createdTime = new ExcelHeader("创建时间", "createdTime", Date.class);
    ExcelHeader updatedBy = new ExcelHeader("更新人", "updatedBy", String.class);
    ExcelHeader updatedTime = new ExcelHeader("更新时间", "updatedTime", Date.class);
    return new ExcelHeader[]{};
  }

  /**
   * Excel导入，入库之前的处理
   * @param records 从Excel读取到的记录
   * @return 待入库的记录
   */
  @Override
  protected List<AtuScriptTag> beforeInsertBatch(List<AtuScriptTag> records)
  {
    return records;
  }

  /**
   * 写入Excel之前的处理<br>
   * 数据的特殊处理在此处加工处理
   *
   * @param record 来自数据库记录
   * @return 待写入Excel的记录
   */
  @Override
  protected AtuScriptTag beforeWriteExcel(AtuScriptTag record)
  {
    return record;
  }

  //= Excel 导入导出相关代码 end =======================//

  //= 增删改查 相关代码 start ==================//


  @Override
  public ResponseVO<Integer> addScriptTagList(AtuScriptTagAddDto addDto) {
    return this.atuScriptTagService.addScriptTagList(addDto);
  }

  @Override
  public Integer deleteScriptTag(String scriptId, Long tagId) {
    return this.atuScriptTagService.deleteScriptTag(scriptId,tagId);
  }

  @Override
  public List<TagDto> queryScriptTag(String scriptId) {
    return this.atuScriptTagService.queryScriptTag(scriptId);
  }


}
