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

import cn.hutool.json.JSONUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.scriptcase.api.inputSet.service.AtuInputSetApiService;
import net.northking.cctp.scriptcase.db.entity.AtuInputSet;
import net.northking.cctp.scriptcase.dto.inputSet.AtuPlanInputQueryDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 输入项数据集 => Restful 类型 HTTP/HTTPS 接口
 *
 * @author maven-cctp-plugin
 * @since 1.0
 */
@Api(tags = "输入项数据集")
@RequestMapping("/pub/AtuInputSets")
@RestController
public class AtuInputSetPubCtrl
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(AtuInputSetPubCtrl.class);

  @Autowired
  private AtuInputSetApiService apiService;

  /**
   * 根据环境和脚本查询脚本输入项信息
   * @param queryDto 查询参数 环境id集合+脚本id集合
   * @return 查询结果
   */
  @ApiOperation(value = "根据环境和脚本查询脚本输入项信息")
  @PostMapping(value = "/queryByEnvIdAndScriptId")
  ResultWrapper<List<AtuInputSet>> queryByEnvIdAndScriptId(@RequestBody AtuPlanInputQueryDto queryDto){

    logger.info("start queryByEnvIdAndScriptId ... ");
    logger.info("queryByEnvIdAndScriptId params => " + JSONUtil.toJsonStr(queryDto));

    ResultWrapper<List<AtuInputSet>> wrapper = new ResultWrapper<>();
    List<AtuInputSet> inputSetList = apiService.queryInputByEnvIdAndScriptId(queryDto);

    logger.info("end queryByEnvIdAndScriptId ... ");

    return wrapper.success(inputSetList);
  }
}
