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 index d412f9b55..18f5f85de 100644 --- 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 @@ -21,9 +21,8 @@ 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.dataservice.service.param.DataserviceConfigSaveParam; import cn.sliew.scaleph.system.model.ResponseVO; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -48,23 +47,24 @@ public class DataserviceConfigController { @Logging @GetMapping @Operation(summary = "查询 config 列表", description = "查询 config 列表") - public ResponseEntity>> get(@Valid DataserviceConfigListParam param) throws ParseException { + public ResponseEntity> get(@Valid DataserviceConfigListParam param) throws ParseException { Page result = dataserviceConfigService.list(param); - return new ResponseEntity<>(ResponseVO.success(result), HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } @Logging @PutMapping @Operation(summary = "新增 config", description = "新增 config") - public ResponseEntity insert(@Valid @RequestBody DataserviceConfigAddParam param) throws ParseException { + public ResponseEntity insert(@Valid @RequestBody DataserviceConfigSaveParam param) throws ParseException { dataserviceConfigService.insert(param); return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); } @Logging - @PostMapping + @PostMapping("{id}") @Operation(summary = "修改 config", description = "修改 config") - public ResponseEntity update(@Valid @RequestBody DataserviceConfigUpdateParam param) throws ParseException { + public ResponseEntity update(@PathVariable("id") Long id, @Valid @RequestBody DataserviceConfigSaveParam param) throws ParseException { + param.setId(id); dataserviceConfigService.update(param); return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK); } diff --git a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/DictType.java b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/DictType.java index 9aa0b158f..89d48a574 100644 --- a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/DictType.java +++ b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/DictType.java @@ -23,6 +23,8 @@ import cn.sliew.scaleph.common.dict.catalog.CatalogFunctionLanguage; import cn.sliew.scaleph.common.dict.catalog.CatalogTableKind; import cn.sliew.scaleph.common.dict.common.*; +import cn.sliew.scaleph.common.dict.dataservice.HttpMethod; +import cn.sliew.scaleph.common.dict.dataservice.QueryType; import cn.sliew.scaleph.common.dict.ds.RedisMode; import cn.sliew.scaleph.common.dict.flink.*; import cn.sliew.scaleph.common.dict.flink.kubernetes.*; @@ -116,6 +118,9 @@ public enum DictType implements DictDefinition { SCHEDULE_STATUS("schedule_status", "Schedule Status", ScheduleStatus.class), REDIS_MODE("redis_mode", "Redis Mode", RedisMode.class), + + HTTP_METHOD("http_method", "Http Method", HttpMethod.class), + QUERY_TYPE("query_type", "Query Type", QueryType.class), ; @JsonCreator diff --git a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/HttpMethod.java b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/HttpMethod.java new file mode 100644 index 000000000..6b356b26a --- /dev/null +++ b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/HttpMethod.java @@ -0,0 +1,61 @@ +/* + * 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.common.dict.dataservice; + +import cn.sliew.scaleph.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum HttpMethod implements DictInstance { + + GET("GET", "GET"), + POST("POST", "POST"), + ; + + @JsonCreator + public static HttpMethod of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(HttpMethod.class, value)); + } + + @EnumValue + private String value; + private String label; + + HttpMethod(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } + +} diff --git a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/QueryType.java b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/QueryType.java new file mode 100644 index 000000000..0ebdeb82b --- /dev/null +++ b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/dataservice/QueryType.java @@ -0,0 +1,64 @@ +/* + * 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.common.dict.dataservice; + +import cn.sliew.scaleph.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum QueryType implements DictInstance { + + SELECT("SELECT", "SELECT"), + UPSERT("UPSERT", "UPSERT"), + INSERT("INSERT", "INSERT"), + UPDATE("UPDATE", "UPDATE"), + DELETE("DELETE", "DELETE"), + ; + + @JsonCreator + public static QueryType of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(QueryType.class, value)); + } + + @EnumValue + private String value; + private String label; + + QueryType(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } + +} 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 index 1a2303f4c..d5ffa69a4 100644 --- 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 @@ -64,6 +64,12 @@ public class DataserviceConfig extends BaseDO { @TableField(exist = false) private DataserviceResultMap resultMap; + @TableField("`type`") + private String type; + + @TableField("query") + private String query; + @TableField("remark") private String remark; 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 index a7897143f..98e6681cf 100644 --- 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 @@ -50,6 +50,8 @@ + + @@ -64,8 +66,8 @@ create_time, editor, update_time, - project_id, `name`, path, method, content_type, `status`, - parameter_map_id, result_map_id, remark + project_id, `name`, `path`, `method`, content_type, `status`, + parameter_map_id, result_map_id, `type`, query, remark