content: package com.platform.admin.service.impl;
  
  import com.alibaba.fastjson.JSON;
  import com.platform.admin.dto.FlinkXJsonBuildDto;
  import com.platform.admin.entity.JobDatasource;
  import com.platform.admin.service.FlinkxJsonService;
  import com.platform.admin.service.JobDatasourceService;
  import com.platform.admin.tool.flinkx.FlinkxJsonHelper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import javax.annotation.Resource;
  
  /**
   *
   * @author AllDataDC
   * @date 2023/3/26 11:14
   *  JSON构建实现类
   **/
  @Service
  public class FlinkxJsonServiceImpl implements FlinkxJsonService {
  
      @Resource
      private JobDatasourceService jobJdbcDatasourceService;
  
      @Override
      public String buildJobJson(FlinkXJsonBuildDto FlinkXJsonBuildDto) {
          FlinkxJsonHelper flinkxJsonHelper = new FlinkxJsonHelper();
          // reader
          JobDatasource readerDatasource = jobJdbcDatasourceService.getById(FlinkXJsonBuildDto.getReaderDatasourceId());
          flinkxJsonHelper.initReader(FlinkXJsonBuildDto, readerDatasource);
          // writer
          JobDatasource writerDatasource = jobJdbcDatasourceService.getById(FlinkXJsonBuildDto.getWriterDatasourceId());
          flinkxJsonHelper.initWriter(FlinkXJsonBuildDto, writerDatasource);
  
          return JSON.toJSONString(flinkxJsonHelper.buildJob());
      }
  }
  