diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0db899fb..daca2dc17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: cache: maven - name: Build with Maven timeout-minutes: 360 - run: mvn -B -U -T 4 clean package --file pom.xml + run: mvn -B -U -T 4C clean package --file pom.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fe1f37320..9a96cbedc 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -47,13 +47,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build scaleph-dist - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast - name: Build scaleph-ui-react-dist run: mvn -B -U package -pl scaleph-ui-react -am -DskipTests - name: Build scaleph-ui-react run: cd scaleph-ui-react && npm install && npm run build --prod - name: Build scaleph-file-fetcher - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher - name: Build image uses: docker/build-push-action@v4 with: diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 7d2834c59..d692b3f2e 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -41,13 +41,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build scaleph-dist - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast - name: Build scaleph-ui-react-dist run: mvn -B -U package -pl scaleph-ui-react -am -DskipTests - name: Build scaleph-ui-react run: cd scaleph-ui-react && npm install && npm run build --prod - name: Build scaleph-file-fetcher - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher - name: Push image uses: docker/build-push-action@v4 with: diff --git a/.github/workflows/release-dist-bin.yml b/.github/workflows/release-dist-bin.yml index daae603b7..01ec6e4a7 100644 --- a/.github/workflows/release-dist-bin.yml +++ b/.github/workflows/release-dist-bin.yml @@ -21,16 +21,16 @@ jobs: name: Prepare JDK 17 uses: actions/setup-java@v3 with: - distribution: 'oracle' + distribution: temurin java-version: 17 - cache: 'maven' + cache: maven - id: get_project_version name: Get Project Version run: | echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null)" >> $GITHUB_ENV - id: run_build name: Run Maven Build - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast - id: upload_assets name: Upload binaries to release uses: svenstaro/upload-release-action@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28b07fa0d..c4525a14c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: - name: Build scaleph-ui-react run: cd scaleph-ui-react && npm install && npm run build --prod - name: Build scaleph-file-fetcher - run: mvn -B -U -T 4 clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher + run: mvn -B -U -T 4C clean package -Pdist -DskipTests -Dfast -am --projects scaleph-file-fetcher - name: Release image uses: docker/build-push-action@v4 with: diff --git a/pom.xml b/pom.xml index b1e6a9f9e..5da6f3dfd 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,7 @@ scaleph-dist scaleph-file-fetcher + scaleph-dataservice @@ -241,6 +242,11 @@ scaleph-config ${project.version} + + ${project.groupId} + scaleph-dataservice + ${project.version} + ${project.groupId} scaleph-datasource diff --git a/scaleph-api/pom.xml b/scaleph-api/pom.xml index 9b41ac12f..87012c16e 100644 --- a/scaleph-api/pom.xml +++ b/scaleph-api/pom.xml @@ -36,6 +36,10 @@ ${project.parent.groupId} scaleph-engine-flink-kubernetes + + ${project.parent.groupId} + scaleph-dataservice + ${project.parent.groupId} scaleph-datasource diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/config/WebSecurityConfig.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/config/WebSecurityConfig.java index 9555b0b37..1511c458a 100644 --- a/scaleph-api/src/main/java/cn/sliew/scaleph/api/config/WebSecurityConfig.java +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/config/WebSecurityConfig.java @@ -19,6 +19,7 @@ package cn.sliew.scaleph.api.config; import cn.sliew.scaleph.api.annotation.AnonymousAccess; +import cn.sliew.scaleph.common.constant.Constants; import cn.sliew.scaleph.common.util.SpringApplicationContextUtil; import cn.sliew.scaleph.security.authentication.CustomAccessDeniedHandler; import cn.sliew.scaleph.security.authentication.CustomAuthenticationEntryPoint; @@ -37,13 +38,14 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.util.ObjectUtils; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter @@ -126,4 +128,21 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { ; return http.build(); } + + /** + * fix When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. + * To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead + */ + @Bean + public CorsFilter corsFilter() { + final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration config = new CorsConfiguration(); + config.setAllowCredentials(true); + config.addAllowedOriginPattern("*"); + config.setAllowedHeaders(Arrays.asList("Origin", "Content-Type", "Accept", "responseType", Constants.TOKEN_KEY)); + config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "OPTIONS", "DELETE", "PATCH")); + source.registerCorsConfiguration("/**", config); + return new CorsFilter(source); + } + } diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceConfigController.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceConfigController.java new file mode 100644 index 000000000..d412f9b55 --- /dev/null +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceConfigController.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.api.controller.dataservice; + +import cn.sliew.scaleph.api.annotation.Logging; +import cn.sliew.scaleph.dataservice.service.DataserviceConfigService; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceConfigDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigUpdateParam; +import cn.sliew.scaleph.system.model.ResponseVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.text.ParseException; +import java.util.List; + +@Tag(name = "数据服务-配置管理") +@RestController +@RequestMapping(path = "/api/dataservice/config") +public class DataserviceConfigController { + + @Autowired + private DataserviceConfigService dataserviceConfigService; + + @Logging + @GetMapping + @Operation(summary = "查询 config 列表", description = "查询 config 列表") + public ResponseEntity>> get(@Valid DataserviceConfigListParam param) throws ParseException { + Page result = dataserviceConfigService.list(param); + return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + } + + @Logging + @PutMapping + @Operation(summary = "新增 config", description = "新增 config") + public ResponseEntity insert(@Valid @RequestBody DataserviceConfigAddParam param) throws ParseException { + dataserviceConfigService.insert(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @PostMapping + @Operation(summary = "修改 config", description = "修改 config") + public ResponseEntity update(@Valid @RequestBody DataserviceConfigUpdateParam param) throws ParseException { + dataserviceConfigService.update(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping("{id}") + @Operation(summary = "删除 config", description = "删除 config") + public ResponseEntity deleteById(@PathVariable("id") Long id) { + dataserviceConfigService.deleteById(id); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping(path = "/batch") + @Operation(summary = "批量删除 config", description = "批量删除 config") + public ResponseEntity deleteBatch(@RequestBody List ids) { + dataserviceConfigService.deleteBatch(ids); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + +} diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceParameterMapController.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceParameterMapController.java new file mode 100644 index 000000000..2d51fb7bb --- /dev/null +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceParameterMapController.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.api.controller.dataservice; + +import cn.sliew.scaleph.api.annotation.Logging; +import cn.sliew.scaleph.dataservice.service.DataserviceParameterMapService; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapUpdateParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMappingReplaceParam; +import cn.sliew.scaleph.system.model.ResponseVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.text.ParseException; +import java.util.List; + +@Tag(name = "数据服务-ParameterMap管理") +@RestController +@RequestMapping(path = "/api/dataservice/parameter-map") +public class DataserviceParameterMapController { + + @Autowired + private DataserviceParameterMapService dataserviceParameterMapService; + + @Logging + @GetMapping + @Operation(summary = "查询 parameterMap 列表", description = "查询 parameterMap 列表") + public ResponseEntity>> get(@Valid DataserviceParameterMapListParam param) throws ParseException { + Page result = dataserviceParameterMapService.list(param); + return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + } + + @Logging + @GetMapping("{parameterMapId}/mappings") + @Operation(summary = "查询 parameterMapping 列表", description = "查询 parameterMapping 列表") + public ResponseEntity>> listMappings(@PathVariable("parameterMapId") Long parameterMapId) throws ParseException { + List result = dataserviceParameterMapService.listMappings(parameterMapId); + return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + } + + @Logging + @PutMapping + @Operation(summary = "新增 parameterMap", description = "新增 parameterMap") + public ResponseEntity insert(@Valid @RequestBody DataserviceParameterMapAddParam param) throws ParseException { + dataserviceParameterMapService.insert(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @PostMapping + @Operation(summary = "修改 parameterMap", description = "修改 parameterMap") + public ResponseEntity update(@Valid @RequestBody DataserviceParameterMapUpdateParam param) throws ParseException { + dataserviceParameterMapService.update(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @PostMapping("mappings/replace") + @Operation(summary = "替换 parameterMapping", description = "替换 parameterMapping") + public ResponseEntity replaceMappings(@Valid @RequestBody DataserviceParameterMappingReplaceParam param) throws ParseException { + dataserviceParameterMapService.replaceMappings(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping("{id}") + @Operation(summary = "删除 parameterMap", description = "删除 parameterMap") + public ResponseEntity deleteById(@PathVariable("id") Long id) { + dataserviceParameterMapService.deleteById(id); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping(path = "/batch") + @Operation(summary = "批量删除 parameterMap", description = "批量删除 parameterMap") + public ResponseEntity deleteBatch(@RequestBody List ids) { + dataserviceParameterMapService.deleteBatch(ids); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + +} diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceResultMapController.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceResultMapController.java new file mode 100644 index 000000000..95fc16b67 --- /dev/null +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/dataservice/DataserviceResultMapController.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.api.controller.dataservice; + +import cn.sliew.scaleph.api.annotation.Logging; +import cn.sliew.scaleph.dataservice.service.DataserviceResultMapService; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceResultMapAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceResultMapListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceResultMapUpdateParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceResultMappingReplaceParam; +import cn.sliew.scaleph.system.model.ResponseVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.text.ParseException; +import java.util.List; + +@Tag(name = "数据服务-ResultMap管理") +@RestController +@RequestMapping(path = "/api/dataservice/result-map") +public class DataserviceResultMapController { + + @Autowired + private DataserviceResultMapService dataserviceResultMapService; + + @Logging + @GetMapping + @Operation(summary = "查询 resultMap 列表", description = "查询 resultMap 列表") + public ResponseEntity>> get(@Valid DataserviceResultMapListParam param) throws ParseException { + Page result = dataserviceResultMapService.list(param); + return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + } + + @Logging + @GetMapping("{resultMapId}/mappings") + @Operation(summary = "查询 resultMapping 列表", description = "查询 resultMapping 列表") + public ResponseEntity>> listMappings(@PathVariable("resultMapId") Long resultMapId) { + List result = dataserviceResultMapService.listMappings(resultMapId); + return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + } + + @Logging + @PutMapping + @Operation(summary = "新增 resultMap", description = "新增 resultMap") + public ResponseEntity insert(@Valid @RequestBody DataserviceResultMapAddParam param) throws ParseException { + dataserviceResultMapService.insert(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @PostMapping + @Operation(summary = "修改 resultMap", description = "修改 resultMap") + public ResponseEntity update(@Valid @RequestBody DataserviceResultMapUpdateParam param) throws ParseException { + dataserviceResultMapService.update(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @PostMapping("mappings/replace") + @Operation(summary = "替换 resultMapping", description = "替换 resultMapping") + public ResponseEntity replaceMappings(@Valid @RequestBody DataserviceResultMappingReplaceParam param) { + dataserviceResultMapService.replaceMappings(param); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping("{id}") + @Operation(summary = "删除 resultMap", description = "删除 resultMap") + public ResponseEntity deleteById(@PathVariable("id") Long id) { + dataserviceResultMapService.deleteById(id); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + + @Logging + @DeleteMapping(path = "/batch") + @Operation(summary = "批量删除 resultMap", description = "批量删除 resultMap") + public ResponseEntity deleteBatch(@RequestBody List ids) { + dataserviceResultMapService.deleteBatch(ids); + return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); + } + +} diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/ws/WsFlinkSqlGatewayController.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/ws/WsFlinkSqlGatewayController.java index abf8bb063..3d9efc230 100644 --- a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/ws/WsFlinkSqlGatewayController.java +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/ws/WsFlinkSqlGatewayController.java @@ -18,12 +18,11 @@ package cn.sliew.scaleph.api.controller.ws; +import cn.sliew.scaleph.engine.sql.gateway.services.WsFlinkSqlGatewayService; import cn.sliew.scaleph.engine.sql.gateway.services.dto.WsFlinkSqlGatewayCreateCatalogParamsDTO; import cn.sliew.scaleph.engine.sql.gateway.services.dto.WsFlinkSqlGatewayQueryParamsDTO; import cn.sliew.scaleph.engine.sql.gateway.services.dto.WsFlinkSqlGatewayQueryResultDTO; import cn.sliew.scaleph.engine.sql.gateway.services.dto.catalog.CatalogInfo; -import cn.sliew.scaleph.engine.sql.gateway.services.WsFlinkSqlGatewayService; -import cn.sliew.scaleph.system.model.PaginationParam; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -32,14 +31,7 @@ import org.apache.flink.table.gateway.api.results.ResultSet; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -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.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Set; @@ -89,12 +81,16 @@ public ResponseEntity executeSql(@PathVariable("clusterId") String clust @Operation(summary = "获取Sql执行结果", description = "获取Sql执行结果") @Parameters({ @Parameter(name = "clusterId", description = "flink kubernetes session-cluster 的 sessionClusterId"), - @Parameter(name = "operationHandleId", description = "查询操作唯一标识,由executeSql()返回") + @Parameter(name = "operationHandleId", description = "查询操作唯一标识,由executeSql()返回"), + @Parameter(name = "token", description = "分页参数。第一页从 0 开始,后续翻页使用返回结果中的 nextToken 字段值。默认值: 0"), + @Parameter(name = "maxRows", description = "分页参数。每页返回数据量。默认值: 20"), }) public ResponseEntity fetchResults(@PathVariable("clusterId") String clusterId, @PathVariable("operationHandleId") String operationHandleId, - PaginationParam param) { - ResultSet resultSet = wsFlinkSqlGatewayService.fetchResults(clusterId, operationHandleId, param.getCurrent() - 1L, param.getPageSize().intValue()); + @RequestParam(value = "token", required = false, defaultValue = "0") Long token, + @RequestParam(value = "maxRows", required = false, defaultValue = "20") int maxRows + ) { + ResultSet resultSet = wsFlinkSqlGatewayService.fetchResults(clusterId, operationHandleId, token, maxRows); try { WsFlinkSqlGatewayQueryResultDTO wsFlinkSqlGatewayQueryResultDTO = WsFlinkSqlGatewayQueryResultDTO.fromResultSet(resultSet); return ResponseEntity.ok(wsFlinkSqlGatewayQueryResultDTO); @@ -159,7 +155,7 @@ public ResponseEntity addCatalog(@PathVariable("clusterId") String clus @Parameter(name = "catalogName", description = "Catalog名称") }) public ResponseEntity removeCatalog(@PathVariable("clusterId") String clusterId, - @RequestParam("catalogName") String catalogName) { + @RequestParam("catalogName") String catalogName) { return ResponseEntity.ok(wsFlinkSqlGatewayService.removeCatalog(clusterId, catalogName)); } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceConfig.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceConfig.java new file mode 100644 index 000000000..1a2303f4c --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceConfig.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.entity.master.dataservice; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + *

+ * 数据服务 配置 + *

+ */ +@Data +@TableName("dataservice_config") +public class DataserviceConfig extends BaseDO { + + private static final long serialVersionUID = 1L; + + @TableField("project_id") + private Long projectId; + + @TableField("`name`") + private String name; + + @TableField("path") + private String path; + + @TableField("method") + private String method; + + @TableField("content_type") + private String contentType; + + @TableField("`status`") + private String status; + + @TableField("parameter_map_id") + private Long parameterMapId; + + @TableField(exist = false) + private DataserviceParameterMap parameterMap; + + @TableField("result_map_id") + private Long resultMapId; + + @TableField(exist = false) + private DataserviceResultMap resultMap; + + @TableField("remark") + private String remark; + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMap.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMap.java new file mode 100644 index 000000000..43f797155 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMap.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.entity.master.dataservice; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.List; + +/** + *

+ * 数据服务 请求参数集 + *

+ */ +@Data +@TableName("dataservice_parameter_map") +public class DataserviceParameterMap extends BaseDO { + + private static final long serialVersionUID = 1L; + + @TableField("project_id") + private Long projectId; + + @TableField("`name`") + private String name; + + @TableField(exist = false) + private List parameterMappings; + + @TableField("remark") + private String remark; + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMapping.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMapping.java new file mode 100644 index 000000000..1df3ee663 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceParameterMapping.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.entity.master.dataservice; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 请求参数映射 + *

+ */ +@Data +@TableName("dataservice_parameter_mapping") +@Schema(name = "DataserviceParameterMapping对象", description = "数据服务 请求参数映射") +public class DataserviceParameterMapping extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "请求参数集id") + @TableField("parameter_map_id") + private Long parameterMapId; + + @Schema(description = "属性") + @TableField("property") + private String property; + + @Schema(description = "java 类型") + @TableField("java_type") + private String javaType; + + @Schema(description = "jdbc 类型") + @TableField("jdbc_type") + private String jdbcType; + + @Schema(description = "类型转换器") + @TableField("type_handler") + private String typeHandler; + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMap.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMap.java new file mode 100644 index 000000000..12ce7d4aa --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMap.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.entity.master.dataservice; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.List; + +/** + *

+ * 数据服务 返回结果集 + *

+ */ +@Data +@TableName("dataservice_result_map") +public class DataserviceResultMap extends BaseDO { + + private static final long serialVersionUID = 1L; + + @TableField("project_id") + private Long projectId; + + @TableField("`name`") + private String name; + + @TableField(exist = false) + private List resultMappings; + + @TableField("remark") + private String remark; + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMapping.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMapping.java new file mode 100644 index 000000000..538407b0a --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dataservice/DataserviceResultMapping.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.entity.master.dataservice; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 返回结果映射 + *

+ */ +@Data +@TableName("dataservice_result_mapping") +@Schema(name = "DataserviceResultMapping对象", description = "数据服务 返回结果映射") +public class DataserviceResultMapping extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "返回结果集id") + @TableField("result_map_id") + private Long resultMapId; + + @Schema(description = "属性") + @TableField("property") + private String property; + + @Schema(description = "java 类型") + @TableField("java_type") + private String javaType; + + @Schema(description = "列") + @TableField("`column`") + private String column; + + @Schema(description = "jdbc 类型") + @TableField("jdbc_type") + private String jdbcType; + + @Schema(description = "类型转换器") + @TableField("type_handler") + private String typeHandler; + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.java new file mode 100644 index 000000000..6d896a655 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.mapper.master.dataservice; + +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +/** + *

+ * 数据服务 配置 Mapper 接口 + *

+ */ +@Repository +public interface DataserviceConfigMapper extends BaseMapper { + + DataserviceConfig getById(@Param("id") Long id); + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.java new file mode 100644 index 000000000..817639d09 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.mapper.master.dataservice; + +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMap; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 数据服务 请求参数集 Mapper 接口 + *

+ */ +@Repository +public interface DataserviceParameterMapMapper extends BaseMapper { + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.java new file mode 100644 index 000000000..0fc6ba979 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.mapper.master.dataservice; + +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMapping; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 数据服务 请求参数映射 Mapper 接口 + *

+ */ +@Repository +public interface DataserviceParameterMappingMapper extends BaseMapper { + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.java new file mode 100644 index 000000000..09da284b9 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.mapper.master.dataservice; + +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMap; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 数据服务 返回结果集 Mapper 接口 + *

+ */ +@Repository +public interface DataserviceResultMapMapper extends BaseMapper { + +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.java new file mode 100644 index 000000000..122969858 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dao.mapper.master.dataservice; + +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMapping; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 数据服务 返回结果映射 Mapper 接口 + *

+ */ +@Repository +public interface DataserviceResultMappingMapper extends BaseMapper { + +} diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.xml new file mode 100644 index 000000000..a7897143f --- /dev/null +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceConfigMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + creator, + create_time, + editor, + update_time, + project_id, `name`, path, method, content_type, `status`, + parameter_map_id, result_map_id, remark + + + + diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.xml new file mode 100644 index 000000000..1fac26088 --- /dev/null +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMapMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + id, + creator, + create_time, + editor, + update_time, + project_id, `name`, remark + + diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.xml new file mode 100644 index 000000000..f5ecb5b6a --- /dev/null +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceParameterMappingMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + id, + creator, + create_time, + editor, + update_time, + parameter_map_id, property, java_type, jdbc_type, type_handler + + + diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.xml new file mode 100644 index 000000000..9107090fa --- /dev/null +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMapMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + id, + creator, + create_time, + editor, + update_time, + project_id, `name`, remark + + diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.xml new file mode 100644 index 000000000..5042536fe --- /dev/null +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dataservice/DataserviceResultMappingMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, + creator, + create_time, + editor, + update_time, + result_map_id, property, java_type, `column`, jdbc_type, type_handler + + + diff --git a/scaleph-dataservice/pom.xml b/scaleph-dataservice/pom.xml new file mode 100644 index 000000000..41fd323e9 --- /dev/null +++ b/scaleph-dataservice/pom.xml @@ -0,0 +1,38 @@ + + + + + 4.0.0 + + cn.sliew + scaleph + 1.0.5-SNAPSHOT + ../pom.xml + + scaleph-dataservice + + + + ${project.parent.groupId} + scaleph-system + + + + \ No newline at end of file diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceConfigService.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceConfigService.java new file mode 100644 index 000000000..4ea95cc57 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceConfigService.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service; + +import cn.sliew.scaleph.dataservice.service.dto.DataserviceConfigDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigUpdateParam; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.List; + +public interface DataserviceConfigService { + + Page list(DataserviceConfigListParam param); + + DataserviceConfigDTO selectOne(Long id); + + int insert(DataserviceConfigAddParam param); + + int update(DataserviceConfigUpdateParam param); + + int deleteById(Long id); + + int deleteBatch(List ids); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceParameterMapService.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceParameterMapService.java new file mode 100644 index 000000000..136868434 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceParameterMapService.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service; + +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMapUpdateParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceParameterMappingReplaceParam; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.List; + +public interface DataserviceParameterMapService { + + Page list(DataserviceParameterMapListParam param); + + List listMappings(Long parameterMapId); + + DataserviceParameterMapDTO selectOne(Long id); + + int insert(DataserviceParameterMapAddParam param); + + int update(DataserviceParameterMapUpdateParam param); + + int replaceMappings(DataserviceParameterMappingReplaceParam param); + + int deleteById(Long id); + + int deleteBatch(List ids); + + int deleteMappings(Long parameterMapId); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceResultMapService.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceResultMapService.java new file mode 100644 index 000000000..3b73ec038 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/DataserviceResultMapService.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service; + +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.*; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.List; + +public interface DataserviceResultMapService { + + Page list(DataserviceResultMapListParam param); + + List listMappings(Long resultMapId); + + DataserviceResultMapDTO selectOne(Long id); + + int insert(DataserviceResultMapAddParam param); + + int update(DataserviceResultMapUpdateParam param); + + int replaceMappings(DataserviceResultMappingReplaceParam param); + + int deleteById(Long id); + + int deleteBatch(List ids); + + int deleteMappings(Long resultMapId); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceConfigConvert.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceConfigConvert.java new file mode 100644 index 000000000..f17121e0d --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceConfigConvert.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.convert; + +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.common.util.BeanUtil; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceConfig; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceConfigDTO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DataserviceConfigConvert extends BaseConvert { + DataserviceConfigConvert INSTANCE = Mappers.getMapper(DataserviceConfigConvert.class); + + @Override + default DataserviceConfig toDo(DataserviceConfigDTO dto) { + DataserviceConfig entity = BeanUtil.copy(dto, new DataserviceConfig()); + if (dto.getParameterMap() != null) { + entity.setParameterMapId(dto.getParameterMap().getId()); + entity.setParameterMap(DataserviceParameterMapConvert.INSTANCE.toDo(dto.getParameterMap())); + } + if (dto.getResultMap() != null) { + entity.setResultMapId(dto.getResultMap().getId()); + entity.setResultMap(DataserviceResultMapConvert.INSTANCE.toDo(dto.getResultMap())); + } + return entity; + } + + @Override + default DataserviceConfigDTO toDto(DataserviceConfig entity) { + DataserviceConfigDTO dto = BeanUtil.copy(entity, new DataserviceConfigDTO()); + if (entity.getParameterMap() != null) { + dto.setParameterMap(DataserviceParameterMapConvert.INSTANCE.toDto(entity.getParameterMap())); + } + if (entity.getResultMap() != null) { + dto.setResultMap(DataserviceResultMapConvert.INSTANCE.toDto(entity.getResultMap())); + } + return dto; + } +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMapConvert.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMapConvert.java new file mode 100644 index 000000000..81f6cdd63 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMapConvert.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.convert; + +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMap; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMapDTO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DataserviceParameterMapConvert extends BaseConvert { + DataserviceParameterMapConvert INSTANCE = Mappers.getMapper(DataserviceParameterMapConvert.class); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMappingConvert.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMappingConvert.java new file mode 100644 index 000000000..d402e99fa --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceParameterMappingConvert.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.convert; + +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMapping; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMappingDTO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DataserviceParameterMappingConvert extends BaseConvert { + DataserviceParameterMappingConvert INSTANCE = Mappers.getMapper(DataserviceParameterMappingConvert.class); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMapConvert.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMapConvert.java new file mode 100644 index 000000000..0d1ea66a6 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMapConvert.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.convert; + +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMap; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMapDTO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DataserviceResultMapConvert extends BaseConvert { + DataserviceResultMapConvert INSTANCE = Mappers.getMapper(DataserviceResultMapConvert.class); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMappingConvert.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMappingConvert.java new file mode 100644 index 000000000..64d8f2c06 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/convert/DataserviceResultMappingConvert.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.convert; + +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMapping; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMappingDTO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DataserviceResultMappingConvert extends BaseConvert { + DataserviceResultMappingConvert INSTANCE = Mappers.getMapper(DataserviceResultMappingConvert.class); + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceConfigDTO.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceConfigDTO.java new file mode 100644 index 000000000..c324e3505 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceConfigDTO.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.dto; + +import cn.sliew.scaleph.system.model.BaseDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 配置 + *

+ */ +@Data +@Schema(name = "DataserviceConfig对象", description = "数据服务 配置") +public class DataserviceConfigDTO extends BaseDTO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; + + @Schema(description = "uri path") + private String path; + + @Schema(description = "http method") + private String method; + + @Schema(description = "http content type") + private String contentType; + + @Schema(description = "status, disabled or enabled") + private String status; + + @Schema(description = "parameter map") + private DataserviceParameterMapDTO parameterMap; + + @Schema(description = "result map") + private DataserviceResultMapDTO resultMap; + + @Schema(description = "备注") + private String remark; + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMapDTO.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMapDTO.java new file mode 100644 index 000000000..f00c99e40 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMapDTO.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.dto; + +import cn.sliew.scaleph.system.model.BaseDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 请求参数集 + *

+ */ +@Data +@Schema(name = "DataserviceParameterMap对象", description = "数据服务 请求参数集") +public class DataserviceParameterMapDTO extends BaseDTO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMappingDTO.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMappingDTO.java new file mode 100644 index 000000000..c6f8f0cb1 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceParameterMappingDTO.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.dto; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 请求参数映射 + *

+ */ +@Data +@Schema(name = "DataserviceParameterMapping对象", description = "数据服务 请求参数映射") +public class DataserviceParameterMappingDTO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "请求参数集id") + private Long parameterMapId; + + @Schema(description = "属性") + private String property; + + @Schema(description = "java 类型") + private String javaType; + + @Schema(description = "jdbc 类型") + private String jdbcType; + + @Schema(description = "类型转换器") + private String typeHandler; + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMapDTO.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMapDTO.java new file mode 100644 index 000000000..c8dbe1df3 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMapDTO.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.dto; + +import cn.sliew.scaleph.system.model.BaseDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 返回结果集 + *

+ */ +@Data +@Schema(name = "DataserviceResultMap对象", description = "数据服务 返回结果集") +public class DataserviceResultMapDTO extends BaseDTO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMappingDTO.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMappingDTO.java new file mode 100644 index 000000000..f94f7be31 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/dto/DataserviceResultMappingDTO.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.dto; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + *

+ * 数据服务 返回结果映射 + *

+ */ +@Data +@Schema(name = "DataserviceResultMapping对象", description = "数据服务 返回结果映射") +public class DataserviceResultMappingDTO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @Schema(description = "返回结果集id") + private Long resultMapId; + + @Schema(description = "属性") + private String property; + + @Schema(description = "java 类型") + private String javaType; + + @Schema(description = "列") + private String column; + + @Schema(description = "jdbc 类型") + private String jdbcType; + + @Schema(description = "类型转换器") + private String typeHandler; + +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceConfigServiceImpl.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceConfigServiceImpl.java new file mode 100644 index 000000000..44c4dcbee --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceConfigServiceImpl.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.impl; + +import cn.sliew.scaleph.common.util.BeanUtil; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceConfig; +import cn.sliew.scaleph.dao.mapper.master.dataservice.DataserviceConfigMapper; +import cn.sliew.scaleph.dataservice.service.DataserviceConfigService; +import cn.sliew.scaleph.dataservice.service.convert.DataserviceConfigConvert; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceConfigDTO; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigAddParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigListParam; +import cn.sliew.scaleph.dataservice.service.param.DataserviceConfigUpdateParam; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; + +import static cn.sliew.milky.common.check.Ensures.checkState; + +@Service +public class DataserviceConfigServiceImpl implements DataserviceConfigService { + + @Autowired + private DataserviceConfigMapper dataserviceConfigMapper; + + @Override + public Page list(DataserviceConfigListParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceConfig.class) + .eq(DataserviceConfig::getProjectId, param.getProjectId()) + .like(StringUtils.hasText(param.getName()), DataserviceConfig::getName, param.getName()); + + Page dataserviceConfigPage = dataserviceConfigMapper.selectPage(page, queryWrapper); + Page result = new Page<>(dataserviceConfigPage.getCurrent(), dataserviceConfigPage.getSize(), dataserviceConfigPage.getTotal()); + List dataserviceConfigDTOS = DataserviceConfigConvert.INSTANCE.toDto(dataserviceConfigPage.getRecords()); + result.setRecords(dataserviceConfigDTOS); + return result; + } + + @Override + public DataserviceConfigDTO selectOne(Long id) { + DataserviceConfig record = dataserviceConfigMapper.getById(id); + checkState(record != null, () -> "data service config not exists for id: " + id); + return DataserviceConfigConvert.INSTANCE.toDto(record); + } + + @Override + public int insert(DataserviceConfigAddParam param) { + DataserviceConfig record = BeanUtil.copy(param, new DataserviceConfig()); + return dataserviceConfigMapper.insert(record); + } + + @Override + public int update(DataserviceConfigUpdateParam param) { + DataserviceConfig record = BeanUtil.copy(param, new DataserviceConfig()); + return dataserviceConfigMapper.updateById(record); + } + + @Override + public int deleteById(Long id) { + return dataserviceConfigMapper.deleteById(id); + } + + @Override + public int deleteBatch(List ids) { + return dataserviceConfigMapper.deleteBatchIds(ids); + } +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceParameterMapServiceImpl.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceParameterMapServiceImpl.java new file mode 100644 index 000000000..cfe285437 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceParameterMapServiceImpl.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.impl; + +import cn.sliew.scaleph.common.util.BeanUtil; +import cn.sliew.scaleph.dao.DataSourceConstants; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMap; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceParameterMapping; +import cn.sliew.scaleph.dao.mapper.master.dataservice.DataserviceParameterMapMapper; +import cn.sliew.scaleph.dao.mapper.master.dataservice.DataserviceParameterMappingMapper; +import cn.sliew.scaleph.dataservice.service.DataserviceParameterMapService; +import cn.sliew.scaleph.dataservice.service.convert.DataserviceParameterMapConvert; +import cn.sliew.scaleph.dataservice.service.convert.DataserviceParameterMappingConvert; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceParameterMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.*; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.List; + +import static cn.sliew.milky.common.check.Ensures.checkState; + +@Service +public class DataserviceParameterMapServiceImpl implements DataserviceParameterMapService { + + @Autowired + private DataserviceParameterMapMapper dataserviceParameterMapMapper; + @Autowired + private DataserviceParameterMappingMapper dataserviceParameterMappingMapper; + + @Override + public Page list(DataserviceParameterMapListParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceParameterMap.class) + .eq(DataserviceParameterMap::getProjectId, param.getProjectId()) + .like(StringUtils.hasText(param.getName()), DataserviceParameterMap::getName, param.getName()); + + Page dataserviceParameterMapPage = dataserviceParameterMapMapper.selectPage(page, queryWrapper); + Page result = new Page<>(dataserviceParameterMapPage.getCurrent(), dataserviceParameterMapPage.getSize(), dataserviceParameterMapPage.getTotal()); + List dataserviceParameterMapDTOS = DataserviceParameterMapConvert.INSTANCE.toDto(dataserviceParameterMapPage.getRecords()); + result.setRecords(dataserviceParameterMapDTOS); + return result; + } + + @Override + public List listMappings(Long parameterMapId) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceParameterMapping.class) + .eq(DataserviceParameterMapping::getParameterMapId, parameterMapId) + .orderByAsc(DataserviceParameterMapping::getProperty); + List dataserviceParameterMappings = dataserviceParameterMappingMapper.selectList(queryWrapper); + return DataserviceParameterMappingConvert.INSTANCE.toDto(dataserviceParameterMappings); + } + + @Override + public DataserviceParameterMapDTO selectOne(Long id) { + DataserviceParameterMap record = dataserviceParameterMapMapper.selectById(id); + checkState(record != null, () -> "data service parameter map not exists for id: " + id); + return DataserviceParameterMapConvert.INSTANCE.toDto(record); + } + + @Override + public int insert(DataserviceParameterMapAddParam param) { + DataserviceParameterMap record = BeanUtil.copy(param, new DataserviceParameterMap()); + return dataserviceParameterMapMapper.insert(record); + } + + @Override + public int update(DataserviceParameterMapUpdateParam param) { + DataserviceParameterMap record = BeanUtil.copy(param, new DataserviceParameterMap()); + return dataserviceParameterMapMapper.updateById(record); + } + + @Transactional(transactionManager = DataSourceConstants.MASTER_TRANSACTION_MANAGER_FACTORY) + @Override + public int replaceMappings(DataserviceParameterMappingReplaceParam param) { + int deleted = deleteMappings(param.getParameterMapId()); + if (CollectionUtils.isEmpty(param.getMappings())) { + return deleted; + } + for (DataserviceParameterMappingParam mappingParam : param.getMappings()) { + DataserviceParameterMapping entity = BeanUtil.copy(mappingParam, new DataserviceParameterMapping()); + entity.setParameterMapId(param.getParameterMapId()); + dataserviceParameterMappingMapper.insert(entity); + } + return param.getMappings().size(); + } + + @Override + public int deleteById(Long id) { + return dataserviceParameterMapMapper.deleteById(id); + } + + @Override + public int deleteBatch(List ids) { + return dataserviceParameterMapMapper.deleteBatchIds(ids); + } + + @Override + public int deleteMappings(Long parameterMapId) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceParameterMapping.class) + .eq(DataserviceParameterMapping::getParameterMapId, parameterMapId); + return dataserviceParameterMappingMapper.delete(queryWrapper); + } +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceResultMapServiceImpl.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceResultMapServiceImpl.java new file mode 100644 index 000000000..453e36218 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/impl/DataserviceResultMapServiceImpl.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.impl; + +import cn.sliew.scaleph.common.util.BeanUtil; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMap; +import cn.sliew.scaleph.dao.entity.master.dataservice.DataserviceResultMapping; +import cn.sliew.scaleph.dao.mapper.master.dataservice.DataserviceResultMapMapper; +import cn.sliew.scaleph.dao.mapper.master.dataservice.DataserviceResultMappingMapper; +import cn.sliew.scaleph.dataservice.service.DataserviceResultMapService; +import cn.sliew.scaleph.dataservice.service.convert.DataserviceResultMapConvert; +import cn.sliew.scaleph.dataservice.service.convert.DataserviceResultMappingConvert; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMapDTO; +import cn.sliew.scaleph.dataservice.service.dto.DataserviceResultMappingDTO; +import cn.sliew.scaleph.dataservice.service.param.*; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.List; + +import static cn.sliew.milky.common.check.Ensures.checkState; + +@Service +public class DataserviceResultMapServiceImpl implements DataserviceResultMapService { + + @Autowired + private DataserviceResultMapMapper dataserviceResultMapMapper; + @Autowired + private DataserviceResultMappingMapper dataserviceResultMappingMapper; + + @Override + public Page list(DataserviceResultMapListParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceResultMap.class) + .eq(DataserviceResultMap::getProjectId, param.getProjectId()) + .like(StringUtils.hasText(param.getName()), DataserviceResultMap::getName, param.getName()); + + Page dataserviceResultMapPage = dataserviceResultMapMapper.selectPage(page, queryWrapper); + Page result = new Page<>(dataserviceResultMapPage.getCurrent(), dataserviceResultMapPage.getSize(), dataserviceResultMapPage.getTotal()); + List dataserviceResultMapDTOS = DataserviceResultMapConvert.INSTANCE.toDto(dataserviceResultMapPage.getRecords()); + result.setRecords(dataserviceResultMapDTOS); + return result; + } + + @Override + public List listMappings(Long resultMapId) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceResultMapping.class) + .eq(DataserviceResultMapping::getResultMapId, resultMapId) + .orderByAsc(DataserviceResultMapping::getColumn); + List dataserviceResultMappings = dataserviceResultMappingMapper.selectList(queryWrapper); + return DataserviceResultMappingConvert.INSTANCE.toDto(dataserviceResultMappings); + } + + @Override + public DataserviceResultMapDTO selectOne(Long id) { + DataserviceResultMap record = dataserviceResultMapMapper.selectById(id); + checkState(record != null, () -> "data service result map not exists for id: " + id); + return DataserviceResultMapConvert.INSTANCE.toDto(record); + } + + @Override + public int insert(DataserviceResultMapAddParam param) { + DataserviceResultMap record = BeanUtil.copy(param, new DataserviceResultMap()); + return dataserviceResultMapMapper.insert(record); + } + + @Override + public int update(DataserviceResultMapUpdateParam param) { + DataserviceResultMap record = BeanUtil.copy(param, new DataserviceResultMap()); + return dataserviceResultMapMapper.updateById(record); + } + + @Override + public int replaceMappings(DataserviceResultMappingReplaceParam param) { + int deleted = deleteMappings(param.getResultMapId()); + if (CollectionUtils.isEmpty(param.getMappings())) { + return deleted; + } + for (DataserviceResultMappingParam mappingParam : param.getMappings()) { + DataserviceResultMapping entity = BeanUtil.copy(mappingParam, new DataserviceResultMapping()); + entity.setResultMapId(param.getResultMapId()); + dataserviceResultMappingMapper.insert(entity); + } + return param.getMappings().size(); + } + + @Override + public int deleteById(Long id) { + return dataserviceResultMapMapper.deleteById(id); + } + + @Override + public int deleteBatch(List ids) { + return dataserviceResultMapMapper.deleteBatchIds(ids); + } + + @Override + public int deleteMappings(Long resultMapId) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DataserviceResultMapping.class) + .eq(DataserviceResultMapping::getResultMapId, resultMapId); + return dataserviceResultMappingMapper.delete(queryWrapper); + } +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigAddParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigAddParam.java new file mode 100644 index 000000000..47e2e9866 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigAddParam.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceConfigAddParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @NotBlank + @Schema(description = "name") + private String name; + + @NotBlank + @Schema(description = "uri path") + private String path; + + @NotBlank + @Schema(description = "http method") + private String method; + + @NotBlank + @Schema(description = "http content type") + private String contentType; + + @NotBlank + @Schema(description = "status, disabled or enabled") + private String status; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigListParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigListParam.java new file mode 100644 index 000000000..2332ab262 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigListParam.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import cn.sliew.scaleph.system.model.PaginationParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceConfigListParam extends PaginationParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigUpdateParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigUpdateParam.java new file mode 100644 index 000000000..300ea3aa1 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceConfigUpdateParam.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceConfigUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @Schema(description = "name") + private String name; + + @Schema(description = "uri path") + private String path; + + @Schema(description = "http method") + private String method; + + @Schema(description = "http content type") + private String contentType; + + @Schema(description = "status, disabled or enabled") + private String status; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapAddParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapAddParam.java new file mode 100644 index 000000000..9db89784b --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapAddParam.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceParameterMapAddParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @NotBlank + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapListParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapListParam.java new file mode 100644 index 000000000..4ca17ba3d --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapListParam.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import cn.sliew.scaleph.system.model.PaginationParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceParameterMapListParam extends PaginationParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapUpdateParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapUpdateParam.java new file mode 100644 index 000000000..4d9ecc6af --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMapUpdateParam.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceParameterMapUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingParam.java new file mode 100644 index 000000000..e6553e82f --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingParam.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceParameterMappingParam { + + @NotNull + @Schema(description = "属性") + private String property; + + @NotNull + @Schema(description = "java 类型") + private String javaType; + + @Schema(description = "jdbc 类型") + private String jdbcType; + + @Schema(description = "类型转换器") + private String typeHandler; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingReplaceParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingReplaceParam.java new file mode 100644 index 000000000..f6903d42c --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceParameterMappingReplaceParam.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class DataserviceParameterMappingReplaceParam { + + @NotNull + @Schema(description = "请求参数集id") + private Long parameterMapId; + + @Schema(description = "parameter mappings") + private List mappings; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapAddParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapAddParam.java new file mode 100644 index 000000000..b986d9408 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapAddParam.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceResultMapAddParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @NotBlank + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapListParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapListParam.java new file mode 100644 index 000000000..72aaa2eed --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapListParam.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import cn.sliew.scaleph.system.model.PaginationParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceResultMapListParam extends PaginationParam { + + @NotNull + @Schema(description = "project id") + private Long projectId; + + @Schema(description = "name") + private String name; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapUpdateParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapUpdateParam.java new file mode 100644 index 000000000..e9122784c --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMapUpdateParam.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceResultMapUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @Schema(description = "name") + private String name; + + @Schema(description = "备注") + private String remark; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingParam.java new file mode 100644 index 000000000..e220bf68a --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingParam.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class DataserviceResultMappingParam { + + @NotNull + @Schema(description = "属性") + private String property; + + @Schema(description = "java 类型") + private String javaType; + + @NotNull + @Schema(description = "列") + private String column; + + @Schema(description = "jdbc 类型") + private String jdbcType; + + @Schema(description = "类型转换器") + private String typeHandler; +} diff --git a/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingReplaceParam.java b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingReplaceParam.java new file mode 100644 index 000000000..bfd548539 --- /dev/null +++ b/scaleph-dataservice/src/main/java/cn/sliew/scaleph/dataservice/service/param/DataserviceResultMappingReplaceParam.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.dataservice.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class DataserviceResultMappingReplaceParam { + + @NotNull + @Schema(description = "响应结果集id") + private Long resultMapId; + + @Schema(description = "result mappings") + private List mappings; +} diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/lifecycle/ResourceLifecycleState.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/lifecycle/ResourceLifecycleState.java index d88d6f77f..09faef7b4 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/lifecycle/ResourceLifecycleState.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/lifecycle/ResourceLifecycleState.java @@ -29,6 +29,7 @@ * Enum encapsulating the lifecycle state of a Flink resource. */ public enum ResourceLifecycleState { + CREATED(false, "The resource was created in Kubernetes but not yet handled by the operator"), SUSPENDED(true, "The resource (job) has been suspended"), UPGRADING(false, "The resource is being upgraded"), diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/spec/FlinkVersion.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/spec/FlinkVersion.java index 7fedfc52a..5899776ad 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/spec/FlinkVersion.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/spec/FlinkVersion.java @@ -26,7 +26,8 @@ public enum FlinkVersion { v1_14, v1_15, v1_16, - v1_17; + v1_17, + v1_18; public boolean isNewerVersionThan(FlinkVersion otherVersion) { return this.ordinal() > otherVersion.ordinal(); diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/CommonStatus.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/CommonStatus.java index c0ad22cf2..a9ba8365d 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/CommonStatus.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/CommonStatus.java @@ -56,10 +56,12 @@ public abstract class CommonStatus { public abstract ReconciliationStatus getReconciliationStatus(); public ResourceLifecycleState getLifecycleState() { - ReconciliationStatus reconciliationStatus = getReconciliationStatus(); + var reconciliationStatus = getReconciliationStatus(); if (reconciliationStatus.isBeforeFirstDeployment()) { - return StringUtils.isEmpty(error) ? ResourceLifecycleState.CREATED : ResourceLifecycleState.FAILED; + return StringUtils.isEmpty(error) + ? ResourceLifecycleState.CREATED + : ResourceLifecycleState.FAILED; } switch (reconciliationStatus.getState()) { diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/ReconciliationStatus.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/ReconciliationStatus.java index 44fe5154d..b870298ec 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/ReconciliationStatus.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/ReconciliationStatus.java @@ -20,6 +20,7 @@ import cn.sliew.scaleph.engine.flink.kubernetes.operator.AbstractFlinkResource; import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.AbstractFlinkSpec; +import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.JobState; import cn.sliew.scaleph.engine.flink.kubernetes.operator.util.SpecUtils; import cn.sliew.scaleph.engine.flink.kubernetes.operator.util.SpecWithMeta; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -102,4 +103,14 @@ public boolean isLastReconciledSpecStable() { public boolean isBeforeFirstDeployment() { return lastReconciledSpec == null; } + + @JsonIgnore + public boolean scalingInProgress() { + if (isBeforeFirstDeployment() || state != ReconciliationState.UPGRADING) { + return false; + } + var job = deserializeLastReconciledSpec().getJob(); + // For regular full upgrades the jobstate is suspended in UPGRADING state + return job != null && job.getState() == JobState.RUNNING; + } } diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/SavepointInfo.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/SavepointInfo.java index f2cd174db..08936a359 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/SavepointInfo.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/status/SavepointInfo.java @@ -34,6 +34,7 @@ @AllArgsConstructor @Builder public class SavepointInfo { + /** * Last completed savepoint by the operator. */ diff --git a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/util/SpecUtils.java b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/util/SpecUtils.java index b96f561b4..edfac11e6 100644 --- a/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/util/SpecUtils.java +++ b/scaleph-engine/scaleph-engine-flink-kubernetes/src/main/java/cn/sliew/scaleph/engine/flink/kubernetes/operator/util/SpecUtils.java @@ -18,10 +18,11 @@ package cn.sliew.scaleph.engine.flink.kubernetes.operator.util; -import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.engine.flink.kubernetes.operator.AbstractFlinkResource; import cn.sliew.scaleph.engine.flink.kubernetes.operator.reconciler.ReconciliationMetadata; import cn.sliew.scaleph.engine.flink.kubernetes.operator.spec.AbstractFlinkSpec; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import javax.annotation.Nullable; @@ -30,8 +31,8 @@ * Spec utilities. */ public class SpecUtils { - public static final String INTERNAL_METADATA_JSON_KEY = "resource_metadata"; + private static final ObjectMapper objectMapper = new ObjectMapper(); /** * Deserializes the spec and custom metadata object from JSON. @@ -41,19 +42,27 @@ public class SpecUtils { * @param Spec type. * @return SpecWithMeta of spec and meta. */ - public static SpecWithMeta deserializeSpecWithMeta(@Nullable String specWithMetaString, Class specClass) { + public static SpecWithMeta deserializeSpecWithMeta( + @Nullable String specWithMetaString, Class specClass) { if (specWithMetaString == null) { return null; } - ObjectNode wrapper = (ObjectNode) JacksonUtil.toJsonNode(specWithMetaString); - ObjectNode internalMeta = (ObjectNode) wrapper.remove(INTERNAL_METADATA_JSON_KEY); - if (internalMeta == null) { - // migrating from old format - wrapper.remove("apiVersion"); - return new SpecWithMeta<>(JacksonUtil.toObject(wrapper, specClass), null); - } else { - return new SpecWithMeta<>(JacksonUtil.toObject(wrapper.get("spec"), specClass), JacksonUtil.toObject(internalMeta, ReconciliationMetadata.class)); + try { + ObjectNode wrapper = (ObjectNode) objectMapper.readTree(specWithMetaString); + ObjectNode internalMeta = (ObjectNode) wrapper.remove(INTERNAL_METADATA_JSON_KEY); + + if (internalMeta == null) { + // migrating from old format + wrapper.remove("apiVersion"); + return new SpecWithMeta<>(objectMapper.treeToValue(wrapper, specClass), null); + } else { + return new SpecWithMeta<>( + objectMapper.treeToValue(wrapper.get("spec"), specClass), + objectMapper.convertValue(internalMeta, ReconciliationMetadata.class)); + } + } catch (JsonProcessingException e) { + throw new RuntimeException("Could not deserialize spec, this indicates a bug...", e); } } @@ -64,7 +73,8 @@ public static SpecWithMeta deserializeSpecWithM * @param relatedResource Related Flink resource for creating the meta object. * @return Serialized json. */ - public static String writeSpecWithMeta(AbstractFlinkSpec spec, AbstractFlinkResource relatedResource) { + public static String writeSpecWithMeta( + AbstractFlinkSpec spec, AbstractFlinkResource relatedResource) { return writeSpecWithMeta(spec, ReconciliationMetadata.from(relatedResource)); } @@ -75,11 +85,19 @@ public static String writeSpecWithMeta(AbstractFlinkSpec spec, AbstractFlinkReso * @param metadata Reconciliation meta object. * @return Serialized json. */ - public static String writeSpecWithMeta(AbstractFlinkSpec spec, ReconciliationMetadata metadata) { - ObjectNode wrapper = JacksonUtil.createObjectNode(); - wrapper.set("spec", JacksonUtil.toJsonNode(checkNotNull(spec))); - wrapper.set(INTERNAL_METADATA_JSON_KEY, JacksonUtil.toJsonNode(checkNotNull(metadata))); - return wrapper.toString(); + public static String writeSpecWithMeta( + AbstractFlinkSpec spec, ReconciliationMetadata metadata) { + + ObjectNode wrapper = objectMapper.createObjectNode(); + + wrapper.set("spec", objectMapper.valueToTree(checkNotNull(spec))); + wrapper.set(INTERNAL_METADATA_JSON_KEY, objectMapper.valueToTree(checkNotNull(metadata))); + + try { + return objectMapper.writeValueAsString(wrapper); + } catch (JsonProcessingException e) { + throw new RuntimeException("Could not serialize spec, this indicates a bug...", e); + } } // We do not have access to Flink's Preconditions from here @@ -95,6 +113,12 @@ public static T clone(T object) { if (object == null) { return null; } - return (T) JacksonUtil.parseJsonString(JacksonUtil.toJsonString(object), object.getClass()); + try { + return (T) + objectMapper.readValue( + objectMapper.writeValueAsString(object), object.getClass()); + } catch (JsonProcessingException e) { + throw new IllegalStateException(e); + } } } diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/CatalogService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/CatalogService.java new file mode 100644 index 000000000..a4c3b3680 --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/CatalogService.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import cn.sliew.scaleph.engine.sql.gateway.services.dto.catalog.CatalogInfo; +import org.apache.flink.table.catalog.CatalogBaseTable; +import org.apache.flink.table.catalog.ObjectIdentifier; +import org.apache.flink.table.catalog.ResolvedCatalogBaseTable; +import org.apache.flink.table.catalog.UnresolvedIdentifier; +import org.apache.flink.table.functions.FunctionDefinition; +import org.apache.flink.table.gateway.api.results.FunctionInfo; +import org.apache.flink.table.gateway.api.results.TableInfo; +import org.apache.flink.table.gateway.api.session.SessionHandle; +import org.apache.flink.table.gateway.api.utils.SqlGatewayException; + +import java.util.Set; + +/** + * 使用用户 id 关联的 session 获取 + */ +public interface CatalogService { + + /** + * List catalogs. + * + * @return Set of catalog information. + */ + Set getCatalogs(SessionHandle sessionHandle) throws SqlGatewayException; + + /** + * Return current catalog name. + * + * @return name of the current catalog. + */ + String getCurrentCatalog(SessionHandle sessionHandle) throws SqlGatewayException; + + /** + * Return all available catalogs in the current session. + * + * @return names of the registered catalogs. + */ + Set listCatalogs(SessionHandle sessionHandle) throws SqlGatewayException; + + /** + * Return all available schemas in the given catalog. + * + * @param catalogName name string of the given catalog. + * @return names of the registered schemas. + */ + Set listDatabases(SessionHandle sessionHandle, String catalogName) throws SqlGatewayException; + + /** + * Return all available tables/views in the given catalog and database. + * + * @param catalogName name of the given catalog. + * @param databaseName name of the given database. + * @param tableKinds used to specify the type of return values. + * @return table info of the registered tables/views. + */ + Set listTables(SessionHandle sessionHandle, String catalogName, String databaseName, Set tableKinds) throws SqlGatewayException; + + /** + * Return table of the given fully qualified name. + * + * @param tableIdentifier fully qualified name of the table. + * @return information of the table. + */ + ResolvedCatalogBaseTable getTable(SessionHandle sessionHandle, ObjectIdentifier tableIdentifier) throws SqlGatewayException; + + /** + * List all user defined functions. + * + * @param catalogName name string of the given catalog. + * @param databaseName name string of the given database. + * @return user defined functions info. + */ + Set listUserDefinedFunctions(SessionHandle sessionHandle, String catalogName, String databaseName) throws SqlGatewayException; + + /** + * List all available system functions. + * + * @return system functions info. + */ + Set listSystemFunctions(SessionHandle sessionHandle) throws SqlGatewayException; + + /** + * Get the specific definition of the function. If the input identifier only contains the + * function name, it is resolved with the order of the temporary system function, system + * function, temporary function and catalog function. + * + * @param functionIdentifier identifier of the function. + * @return the definition of the function. + */ + FunctionDefinition getFunctionDefinition(SessionHandle sessionHandle, UnresolvedIdentifier functionIdentifier) throws SqlGatewayException; +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/FlinkFactoryService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/FlinkFactoryService.java new file mode 100644 index 000000000..02d473a2b --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/FlinkFactoryService.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import org.apache.flink.table.factories.CatalogFactory; +import org.apache.flink.table.factories.DynamicTableSinkFactory; +import org.apache.flink.table.factories.DynamicTableSourceFactory; +import org.apache.flink.table.factories.FormatFactory; + +import java.util.List; + +public interface FlinkFactoryService { + + List findCatalogs(Long id); + + List findFormats(Long id); + + List findSources(Long id); + + List findSinks(Long id); +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/OperationService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/OperationService.java new file mode 100644 index 000000000..00db6feec --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/OperationService.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import org.apache.flink.table.catalog.ResolvedSchema; +import org.apache.flink.table.gateway.api.SqlGatewayService; +import org.apache.flink.table.gateway.api.operation.OperationHandle; +import org.apache.flink.table.gateway.api.operation.OperationStatus; +import org.apache.flink.table.gateway.api.results.OperationInfo; +import org.apache.flink.table.gateway.api.results.ResultSet; +import org.apache.flink.table.gateway.api.session.SessionHandle; +import org.apache.flink.table.gateway.api.utils.SqlGatewayException; + +import java.util.concurrent.Callable; + +public interface OperationService { + + /** + * Submit an operation and execute. The {@link SqlGatewayService} will take care of the + * execution and assign the {@link OperationHandle} for later to retrieve the results. + * + * @param sessionHandle handle to identify the session. + * @param executor the main logic to get the execution results. + * @return Returns the handle for later retrieve results. + */ + OperationHandle submitOperation(SessionHandle sessionHandle, Callable executor) throws SqlGatewayException; + + /** + * Cancel the operation when it is not in terminal status. + * + *

It can't cancel an Operation if it is terminated. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation.JarURLConnection + */ + void cancelOperation(SessionHandle sessionHandle, OperationHandle operationHandle) throws SqlGatewayException; + + /** + * Close the operation and release all used resource by the operation. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation. + */ + void closeOperation(SessionHandle sessionHandle, OperationHandle operationHandle) throws SqlGatewayException; + + /** + * Get the {@link OperationInfo} of the operation. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation. + */ + OperationInfo getOperationInfo(SessionHandle sessionHandle, OperationHandle operationHandle) throws SqlGatewayException; + + /** + * Get the result schema for the specified Operation. + * + *

Note: The result schema is available when the Operation is in the {@link + * OperationStatus#FINISHED}. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation. + */ + ResolvedSchema getOperationResultSchema(SessionHandle sessionHandle, OperationHandle operationHandle) throws SqlGatewayException; + +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/ResultFetcherService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/ResultFetcherService.java new file mode 100644 index 000000000..8667cffdb --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/ResultFetcherService.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import org.apache.flink.table.gateway.api.operation.OperationHandle; +import org.apache.flink.table.gateway.api.results.FetchOrientation; +import org.apache.flink.table.gateway.api.results.ResultSet; +import org.apache.flink.table.gateway.api.session.SessionHandle; +import org.apache.flink.table.gateway.api.utils.SqlGatewayException; + +public interface ResultFetcherService { + + /** + * Fetch the results from the operation. When maxRows is Integer.MAX_VALUE, it means to fetch + * all available data. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation. + * @param token token to identify results. + * @param maxRows max number of rows to fetch. + * @return Returns the results. + */ + ResultSet fetchResults(SessionHandle sessionHandle, OperationHandle operationHandle, long token, int maxRows) throws SqlGatewayException; + + /** + * Fetch the results from the operation. When maxRows is Integer.MAX_VALUE, it means to fetch + * all available data. It promises to return at least one rows if the results is not + * end-of-stream. + * + * @param sessionHandle handle to identify the session. + * @param operationHandle handle to identify the operation. + * @param orientation orientation to fetch the results. + * @param maxRows max number of rows to fetch. + * @return Returns the results. + */ + ResultSet fetchResults(SessionHandle sessionHandle, OperationHandle operationHandle, FetchOrientation orientation, int maxRows) throws SqlGatewayException; +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SessionService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SessionService.java new file mode 100644 index 000000000..9ffa7a75e --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SessionService.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import org.apache.flink.table.gateway.service.session.Session; + +import java.util.Map; + +/** + * 多级的 session 管理。 + * 默认配置。scaleph 系统级别 + * 全局配置。用户全局配置级别 + * 用户级别。和用户 id 关联 || 项目级别。和项目 id 关联 + * + * SessionContext 中信息分为配置信息和状态信息。配置来自 SessoinEnvironment 和 DefaultContext 类的配置信息 + * SessionState 和 OperationManager 信息属于状态信息。SessionState 信息可以通过配置信息重建,OperationManager 信息由 + * OperationService 类管理 + */ +public interface SessionService { + + // ------------------------------------------------------------------------------------------- + // Global Session + // ------------------------------------------------------------------------------------------- + + Map getGlobalSessionConfig() throws Exception; + + void configureGlobalSession(Map config) throws Exception; + + void configureGlobalSession(String statement) throws Exception; + + // ------------------------------------------------------------------------------------------- + // User Session || Project Session + // ------------------------------------------------------------------------------------------- + + Session openSession() throws Exception; + + void closeSession() throws Exception; + + Map getSessionConfig() throws Exception; + + void configureSession(Map config) throws Exception; + + void configureSession(String statement) throws Exception; +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SqlService.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SqlService.java new file mode 100644 index 000000000..c63adbd44 --- /dev/null +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/SqlService.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.scaleph.engine.sql.gateway.services; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.table.gateway.api.operation.OperationHandle; +import org.apache.flink.table.gateway.api.session.SessionHandle; +import org.apache.flink.table.gateway.api.utils.SqlGatewayException; + +import java.util.List; + +public interface SqlService { + + Object validate(SessionHandle sessionHandle, String statement, Configuration executionConfig) throws Exception; + + /** + * Returns a list of completion hints for the given statement at the given position. + * + * @param sessionHandle handle to identify the session. + * @param statement sql statement to be completed. + * @param position position of where need completion hints. + * @return completion hints. + */ + List completeStatement(SessionHandle sessionHandle, String statement, int position) throws SqlGatewayException; + + /** + * Execute the submitted statement. + * + * @param sessionHandle handle to identify the session. + * @param statement the SQL to execute. + * @param executionTimeoutMs the execution timeout. Please use non-positive value to forbid the + * timeout mechanism. + * @param executionConfig execution config for the statement. + * @return handle to identify the operation. + */ + OperationHandle executeStatement(SessionHandle sessionHandle, String statement, long executionTimeoutMs, Configuration executionConfig) throws SqlGatewayException; + + OperationHandle previewStatement(SessionHandle sessionHandle, String statement, long executionTimeoutMs, Configuration executionConfig) throws SqlGatewayException; +} diff --git a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/dto/WsFlinkSqlGatewayQueryResultDTO.java b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/dto/WsFlinkSqlGatewayQueryResultDTO.java index 4209cf1e2..cb418fd15 100644 --- a/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/dto/WsFlinkSqlGatewayQueryResultDTO.java +++ b/scaleph-engine/scaleph-engine-sql-gateway/src/main/java/cn/sliew/scaleph/engine/sql/gateway/services/dto/WsFlinkSqlGatewayQueryResultDTO.java @@ -45,7 +45,7 @@ public class WsFlinkSqlGatewayQueryResultDTO { @Schema(description = "SQL 执行状态。NOT_READY: 未就绪,需轮询重试, PAYLOAD: 可查询, EOS: 数据查询已至末尾,后续无数据,不在调用", allowableValues = {"PAYLOAD", "NOT_READY", "EOS"}) private ResultSet.ResultType resultType; - @Schema(description = "结果类型。SUCCESS: 执行成功, SUCCESS_WITH_CONTENT: 执行成功并可获取执行结果", + @Schema(description = "结果类型。SUCCESS: 执行成功, SUCCESS_WITH_CONTENT: 执行成功并可获取数据列表", allowableValues = {"SUCCESS", "SUCCESS_WITH_CONTENT"}) private ResultKind resultKind; @Schema(description = "任务 id") @@ -62,8 +62,11 @@ public class WsFlinkSqlGatewayQueryResultDTO { public static WsFlinkSqlGatewayQueryResultDTO fromResultSet(ResultSet resultSet) { WsFlinkSqlGatewayQueryResultDTOBuilder builder = WsFlinkSqlGatewayQueryResultDTO.builder() .resultType(resultSet.getResultType()); - if (resultSet.getResultType() == ResultSet.ResultType.PAYLOAD || resultSet.getResultType() == ResultSet.ResultType.EOS) { - builder.resultKind(resultSet.getResultKind()).jobID(resultSet.getJobID().toHexString()); + if (resultSet.getResultType() != ResultSet.ResultType.NOT_READY) { + if (resultSet.getJobID() != null) { + builder.jobID(resultSet.getJobID().toHexString()); + } + builder.resultKind(resultSet.getResultKind()); if (resultSet.isQueryResult()) { List columns = resultSet.getResultSchema().getColumns(); builder diff --git a/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java b/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java index 9864d6782..4814e54d4 100644 --- a/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java +++ b/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java @@ -54,7 +54,7 @@ public class MybatisPlusGenerator { /** * just add table names here and run the {@link #main(String[])} method. */ - private static final String[] TABLES = {"ws_flink_kubernetes_job", "ws_flink_kubernetes_job_instance"}; + private static final String[] TABLES = {"dataservice_result_mapping", "dataservice_parameter_mapping"}; public static void main(String[] args) { //自动生成配置 diff --git a/tools/docker/build/scaleph-ui-react/Dockerfile b/tools/docker/build/scaleph-ui-react/Dockerfile index 3056d3dfb..daac594ed 100644 --- a/tools/docker/build/scaleph-ui-react/Dockerfile +++ b/tools/docker/build/scaleph-ui-react/Dockerfile @@ -16,3 +16,5 @@ COPY tools/docker/build/scaleph-ui-react/nginx.conf.template / CMD envsubst '$$SCALEPH_API_URL' < /nginx.conf.template > /etc/nginx/nginx.conf \ && cat /etc/nginx/nginx.conf \ && nginx -g 'daemon off;' + +EXPOSE 8096 8096 \ No newline at end of file diff --git a/tools/docker/build/scaleph-ui-react/nginx.conf.template b/tools/docker/build/scaleph-ui-react/nginx.conf.template index 11f598901..afdcede68 100644 --- a/tools/docker/build/scaleph-ui-react/nginx.conf.template +++ b/tools/docker/build/scaleph-ui-react/nginx.conf.template @@ -20,7 +20,7 @@ http { server ${SCALEPH_API_URL}; } server { - listen 80; + listen 8096; server_name localhost; underscores_in_headers on; diff --git a/tools/docker/deploy/scaleph/docker-compose.yml b/tools/docker/deploy/scaleph/docker-compose.yml index f1fe431ad..4b213b871 100644 --- a/tools/docker/deploy/scaleph/docker-compose.yml +++ b/tools/docker/deploy/scaleph/docker-compose.yml @@ -47,7 +47,7 @@ services: environment: - SCALEPH_API_URL="scaleph-api:8080" ports: - - 80:80 + - 8096:8096 networks: - scaleph diff --git a/tools/docker/mysql/init.d/scaleph-dataserivce-mysql.sql b/tools/docker/mysql/init.d/scaleph-dataserivce-mysql.sql new file mode 100644 index 000000000..93556154d --- /dev/null +++ b/tools/docker/mysql/init.d/scaleph-dataserivce-mysql.sql @@ -0,0 +1,89 @@ +create database if not exists scaleph default character set utf8mb4 collate utf8mb4_unicode_ci; +use scaleph; + +drop table if exists dataservice_config; +create table dataservice_config +( + id bigint not null auto_increment comment '自增主键', + project_id bigint not null comment '项目id', + name varchar(64) not null comment 'name', + path varchar(64) not null comment 'uri path', + method varchar(16) not null comment 'http method', + content_type varchar(64) not null comment 'http content type', + status varchar(4) not null comment 'status, disabled or enabled', + parameter_map_id bigint comment 'paramter map id', + result_map_id bigint comment 'result map id', + remark varchar(256) comment '备注', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + unique key uniq_name (project_id, name), + unique key uniq_path (project_id, path) +) engine = innodb comment = '数据服务 配置'; + +drop table if exists dataservice_parameter_map; +create table dataservice_parameter_map +( + id bigint not null auto_increment comment '自增主键', + project_id bigint not null comment '项目id', + name varchar(64) not null comment 'name', + remark varchar(256) comment '备注', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + unique key uniq_param (project_id, name) +) engine = innodb comment = '数据服务 请求参数集'; + +drop table if exists dataservice_parameter_mapping; +create table dataservice_parameter_mapping +( + id bigint not null auto_increment comment '自增主键', + parameter_map_id bigint not null comment '请求参数集id', + property varchar(64) not null comment '属性', + java_type varchar(256) not null comment 'java 类型', + jdbc_type varchar(256) comment 'jdbc 类型', + type_handler varchar(256) comment '类型转换器', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + unique key uniq_property (parameter_map_id, property) +) engine = innodb comment = '数据服务 请求参数映射'; + +drop table if exists dataservice_result_map; +create table dataservice_result_map +( + id bigint not null auto_increment comment '自增主键', + project_id bigint not null comment '项目id', + name varchar(64) not null comment 'name', + remark varchar(256) comment '备注', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + unique key uniq_param (project_id, name) +) engine = innodb comment = '数据服务 返回结果集'; + +drop table if exists dataservice_result_mapping; +create table dataservice_result_mapping +( + id bigint not null auto_increment comment '自增主键', + result_map_id bigint not null comment '请求参数集id', + property varchar(64) not null comment '属性', + java_type varchar(256) comment 'java 类型', + `column` varchar(128) not null comment '列', + jdbc_type varchar(256) comment 'jdbc 类型', + type_handler varchar(256) comment '类型转换器', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + unique key uniq_property (result_map_id, property, `column`) +) engine = innodb comment = '数据服务 返回结果映射'; \ No newline at end of file diff --git a/tools/docker/mysql/init.d/scaleph-log-mysql.sql b/tools/docker/mysql/init.d/scaleph-log-mysql.sql index f10e37fdb..a912b46b0 100644 --- a/tools/docker/mysql/init.d/scaleph-log-mysql.sql +++ b/tools/docker/mysql/init.d/scaleph-log-mysql.sql @@ -31,7 +31,7 @@ create table log_action user_name varchar(60) comment '用户名', action_time timestamp not null comment '操作时间', ip_address varchar(16) comment 'ip地址', - action_url text comment '操作接口地址', + action_url mediumtext comment '操作接口地址', token varchar(64) comment '会话token字符串', client_info varchar(512) comment '客户端信息', os_info varchar(128) comment '操作系统信息', diff --git a/tools/docker/mysql/init.d/scaleph-ws-mysql.sql b/tools/docker/mysql/init.d/scaleph-ws-mysql.sql index 6d3da50f1..d1d8a6c0b 100644 --- a/tools/docker/mysql/init.d/scaleph-ws-mysql.sql +++ b/tools/docker/mysql/init.d/scaleph-ws-mysql.sql @@ -70,7 +70,7 @@ create table ws_flink_artifact_jar editor varchar(32) comment '修改人', update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', primary key (id), - key idx_flink_artifact (flink_artifact_id) + key idx_flink_artifact (flink_artifact_id) ) engine = innodb comment = 'flink artifact jar'; DROP TABLE IF EXISTS ws_flink_artifact_sql; @@ -86,13 +86,13 @@ CREATE TABLE ws_flink_artifact_sql editor varchar(32), update_time datetime not null default current_timestamp on update current_timestamp, PRIMARY KEY (id), - key idx_flink_artifact (flink_artifact_id) + key idx_flink_artifact (flink_artifact_id) ) ENGINE = INNODB COMMENT = 'flink artifact sql'; INSERT INTO `ws_flink_artifact_sql` (`id`, `flink_artifact_id`, `flink_version`, `script`, `current`, `creator`, `editor`) VALUES (1, 1, '1.17.1', - 'CREATE TEMPORARY TABLE source_table (\n `id` bigint,\n `name` string,\n `age` int,\n `address` string,\n `create_time`TIMESTAMP(3),\n `update_time`TIMESTAMP(3),\n WATERMARK FOR `update_time` AS update_time - INTERVAL \'1\' MINUTE\n)\nCOMMENT \'\'\nWITH (\n \'connector\' = \'datagen\',\n \'number-of-rows\' = \'100\'\n);\n\nCREATE TEMPORARY TABLE `sink_table` (\n `id` BIGINT,\n `name` VARCHAR(2147483647),\n `age` INT,\n `address` VARCHAR(2147483647),\n `create_time` TIMESTAMP(3),\n `update_time` TIMESTAMP(3)\n)\nCOMMENT \'\'\nWITH (\n \'connector\' = \'print\'\n);\n\ninsert into sink_table\nselect id, name, age, address, create_time, update_time from source_table;', + 'CREATE TEMPORARY TABLE source_table (\n `id` bigint,\n `name` string,\n `age` int,\n `address` string,\n `create_time`TIMESTAMP(3),\n `update_time`TIMESTAMP(3),\n WATERMARK FOR `update_time` AS update_time - INTERVAL \'1\' MINUTE\n)\nCOMMENT \'\'\nWITH (\n \' connector\' = \'datagen\',\n \'number-of-rows\' = \'100\'\n);\n\nCREATE TEMPORARY TABLE `sink_table` (\n `id` BIGINT,\n `name` VARCHAR(2147483647),\n `age` INT,\n `address` VARCHAR(2147483647),\n `create_time` TIMESTAMP(3),\n `update_time` TIMESTAMP(3)\n)\nCOMMENT \'\'\nWITH (\n \'connector\' = \'print\'\n);\n\ninsert into sink_table\nselect id, name, age, address, create_time, update_time from source_table;', '1', 'sys', 'sys'); INSERT INTO `ws_flink_artifact_sql` (`id`, `flink_artifact_id`, `flink_version`, `script`, `current`, `creator`, `editor`) @@ -112,7 +112,7 @@ VALUES (4, 6, '1.17.1', INSERT INTO `ws_flink_artifact_sql` (`id`, `flink_artifact_id`, `flink_version`, `script`, `current`, `creator`, `editor`) VALUES (5, 7, '1.17.1', - 'CREATE CATALOG my_catalog WITH (\n \'type\' = \'generic_in_memory\'\n);\n\nCREATE DATABASE my_catalog.my_database;\n\n\nCREATE TABLE my_catalog.my_database.source_table (\n `id` bigint,\n `name` string,\n `age` int,\n `address` string,\n `money` decimal(64, 4),\n `create_time`TIMESTAMP(3),\n `update_time`TIMESTAMP(3),\n WATERMARK FOR `update_time` AS update_time - INTERVAL \'1\' MINUTE\n)\nCOMMENT \'\'\nWITH (\n \'connector\' = \'datagen\',\n \'number-of-rows\' = \'100000\'\n);\n\nSELECT * FROM my_catalog.my_database.source_table;', + 'CREATE CATALOG my_catalog WITH (\n \'type\' = \'generic_in_memory\'\n);\n\nCREATE DATABASE my_catalog.my_database;\n\n\nCREATE TABLE my_catalog.my_database.source_table (\n `id` bigint,\n `name` string,\n `age` int,\n `address` string,\n `money` decimal(64, 4),\n `create_time`TIMESTAMP(3),\n `update_time`TIMESTAMP(3),\n WATERMARK FOR `update_time` AS update_time - INTERVAL \'1\' MINUTE\n)\nCOMMENT \'\'\nWITH (\n \'connector\' = \'datagen\',\n \'number-of-rows\' = \'200\'\n);\n\nSELECT * FROM my_catalog.my_database.source_table;', '1', 'sys', 'sys'); INSERT INTO `ws_flink_artifact_sql` (`id`, `flink_artifact_id`, `flink_version`, `script`, `current`, `creator`, @@ -139,7 +139,7 @@ create table ws_di_job editor varchar(32) comment '修改人', update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', primary key (id), - key idx_flink_artifact (flink_artifact_id) + key idx_flink_artifact (flink_artifact_id) ) engine = innodb comment '数据集成-作业信息'; INSERT INTO ws_di_job (id, flink_artifact_id, job_engine, job_id, current, creator, editor) VALUES (1, 4, 'seatunnel', 'b8e16c94-258c-4487-a88c-8aad40a38b35', 1, 'sys', 'sys'); @@ -455,4 +455,37 @@ CREATE TABLE ws_flink_kubernetes_job_instance_savepoint update_time datetime not null default current_timestamp on update current_timestamp, PRIMARY KEY (id), UNIQUE KEY uniq_key (ws_flink_kubernetes_job_instance_id, time_stamp) -) ENGINE = INNODB COMMENT = 'flink kubernetes job instance savepoint'; \ No newline at end of file +) ENGINE = INNODB COMMENT = 'flink kubernetes job instance savepoint'; + +drop table if exists ws_flink_custom_artifact; +create table ws_flink_custom_artifact +( + id bigint not null auto_increment comment '自增主键', + flink_version varchar(32) not null comment 'flink版本', + type varchar(32) not null comment 'catalog, connector, format', + file_name varchar(255) not null comment '文件名称', + path varchar(255) not null comment '文件路径', + dependencies text comment '依赖 jars', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + key idx_custom (flink_version, type, file_name) +) engine = innodb comment = 'flink custom artifact'; + +drop table if exists ws_flink_custom_factory; +create table ws_flink_custom_factory +( + id bigint not null auto_increment comment '自增主键', + flink_custom_artifact_id bigint not null comment 'artifact id', + factory_class varchar(255) not null comment 'factory class', + `name` varchar(255) not null comment 'name', + properties text comment '属性', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + key idx_custom (flink_custom_artifact_id, factory_class, `name`) +) engine = innodb comment = 'flink custom factory'; \ No newline at end of file