-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][catalog] Streampark start job ship catalogstore plugin and …
…database crud.
- Loading branch information
Showing
43 changed files
with
863 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...-console-service/src/main/java/org/apache/streampark/console/core/bean/DatabaseParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.apache.streampark.console.core.bean; | ||
|
||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
|
||
@Data | ||
public class DatabaseParam { | ||
|
||
@NotBlank(message = "invalid.databaseName") | ||
private String name; | ||
|
||
@NotBlank(message = "invalid.catalogId") | ||
private Long catalogId; | ||
|
||
private String catalogName; | ||
private boolean ignoreIfExits; | ||
private boolean cascade; | ||
private String description; | ||
} |
57 changes: 56 additions & 1 deletion
57
...rvice/src/main/java/org/apache/streampark/console/core/controller/DatabaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,67 @@ | ||
/* | ||
* 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 org.apache.streampark.console.core.controller; | ||
|
||
import org.apache.streampark.console.base.domain.RestRequest; | ||
import org.apache.streampark.console.base.domain.RestResponse; | ||
import org.apache.streampark.console.core.bean.DatabaseParam; | ||
import org.apache.streampark.console.core.service.DatabaseService; | ||
|
||
import org.apache.shiro.authz.annotation.RequiresPermissions; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@Validated | ||
@RestController | ||
@RequestMapping("flink/database") | ||
public class DatabaseController {} | ||
public class DatabaseController { | ||
|
||
@Autowired | ||
DatabaseService databaseService; | ||
|
||
@PostMapping("create") | ||
@RequiresPermissions("database:create") | ||
public RestResponse create(DatabaseParam databaseParam) throws IOException { | ||
boolean saved = databaseService.createDatabase(databaseParam); | ||
return RestResponse.success(saved); | ||
} | ||
|
||
@PostMapping("list") | ||
@RequiresPermissions("database:view") | ||
public RestResponse list(DatabaseParam databaseParam, RestRequest request) { | ||
List<DatabaseParam> databaseParamList = | ||
databaseService.listDatabases(databaseParam.getCatalogId()); | ||
return RestResponse.success(databaseParamList); | ||
} | ||
|
||
@PostMapping("delete") | ||
@RequiresPermissions("database:delete") | ||
public RestResponse remove(DatabaseParam databaseParam) { | ||
boolean deleted = databaseService.dropDatabase(databaseParam); | ||
return RestResponse.success(deleted); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ark-console-service/src/main/java/org/apache/streampark/console/core/entity/Database.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.apache.streampark.console.core.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Database { | ||
|
||
private String name; | ||
|
||
private Integer catalogId; | ||
|
||
private String catalogName; | ||
|
||
private String description; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...nsole-service/src/main/java/org/apache/streampark/console/core/mapper/DatabaseMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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 org.apache.streampark.console.core.mapper; | ||
|
||
import org.apache.streampark.console.core.entity.Database; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
|
||
@Mapper | ||
public interface DatabaseMapper extends BaseMapper<Database> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ole-service/src/main/java/org/apache/streampark/console/core/service/DatabaseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.apache.streampark.console.core.service; | ||
|
||
import org.apache.streampark.console.core.bean.DatabaseParam; | ||
import org.apache.streampark.console.core.entity.Database; | ||
|
||
import com.baomidou.mybatisplus.extension.service.IService; | ||
|
||
import java.util.List; | ||
|
||
public interface DatabaseService extends IService<Database> { | ||
|
||
/** | ||
* Checks if the specified database exists. | ||
* | ||
* @param databaseParam The database to check | ||
* @return true if the database exists, false otherwise | ||
*/ | ||
boolean databaseExists(DatabaseParam databaseParam); | ||
|
||
/** | ||
* Creates a new database given {@link Database}. | ||
* | ||
* @param databaseParam The {@link DatabaseParam} object that contains the detail of the created | ||
* database | ||
* @return true if the operation is successful, false otherwise | ||
*/ | ||
boolean createDatabase(DatabaseParam databaseParam); | ||
|
||
/** | ||
* Lists databases given catalog id. | ||
* | ||
* @return The list of databases of given catalog | ||
*/ | ||
List<DatabaseParam> listDatabases(Long catalogId); | ||
|
||
/** | ||
* Drops database given database name. | ||
* | ||
* @param databaseParam The dropping database | ||
* @return true if the operation is successful, false otherwise | ||
*/ | ||
boolean dropDatabase(DatabaseParam databaseParam); | ||
} |
Oops, something went wrong.