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

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.project.api.env.service.CpProjectEnvSysApiService;
import net.northking.cctp.project.dto.env.CpProjectEnvSysUrlSearchDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

/**
 * 系统环境被测系统信息 => Restful 类型 HTTP/HTTPS 接口
 *
 * @author maven-cctp-plugin
 * @since 1.0
 */
@Api(tags = "系统环境数据源信息")
@RequestMapping("/pub/CpProjectEnvSyss")
@RestController
public class CpProjectEnvSysPubCtrl
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(CpProjectEnvSysPubCtrl.class);

  @Autowired
  private CpProjectEnvSysApiService apiService;

  /**
   * 查询被测系统地址
   * @param searchDto 参数
   * @return 连接信息
   */
  @ApiOperation(value = "查询被测系统地址")
  @PostMapping("/querySysUrl")
  public ResultWrapper<String> querySysUrl(@Validated @RequestBody CpProjectEnvSysUrlSearchDto searchDto){

    logger.info("start CpProjectEnvSys querySysUrl  params => {}", JSON.toJSONString(searchDto));

    ResultWrapper<String> wrapper = new ResultWrapper<>();
    String resultStr = apiService.querySysUrl(searchDto);

    logger.info("end CpProjectEnvSys querySysUrl  ");

    return wrapper.success(resultStr);
  }

}
