/*
* 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.CpProjectEnvDsApiService;
import net.northking.cctp.project.dto.env.CpProjectEnvDsModuleExecDto;
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;

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

  @Autowired
  private CpProjectEnvDsApiService apiService;

  /**
   * 执行组件sql
   * @param execDto 参数
   * @return 连接信息
   */
  @ApiOperation(value = "执行组件sql")
  @PostMapping("/execute")
  public ResultWrapper<String> executeModuleSql(@RequestBody CpProjectEnvDsModuleExecDto execDto){

    logger.info("start CpProjectEnvDs executeModuleSql  params => {}", JSON.toJSONString(execDto));

    ResultWrapper<String> wrapper = new ResultWrapper<>();
    String resultStr = apiService.executeModuleSql(execDto);

    logger.info("end CpProjectEnvDs executeModuleSql  ");

    return wrapper.success(resultStr);
  }

}
