forked from DataLinkDC/dinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
2,560 additions
and
461 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
65 changes: 65 additions & 0 deletions
65
dinky-admin/src/main/java/org/dinky/controller/SuggestionController.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,65 @@ | ||
/* | ||
* | ||
* 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.dinky.controller; | ||
|
||
import org.dinky.data.dto.SuggestionDTO; | ||
import org.dinky.data.model.suggestion.Suggestion; | ||
import org.dinky.data.result.Result; | ||
import org.dinky.service.SuggestionService; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.annotations.Api; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RestController | ||
@Api(tags = "Suggestion Controller") | ||
@RequestMapping("/api/suggestion") | ||
@RequiredArgsConstructor | ||
public class SuggestionController { | ||
|
||
private final SuggestionService suggestionService; | ||
|
||
@PostMapping("/queryAllSuggestions") | ||
public Result<List<Suggestion>> queryAllSuggestions(@RequestBody SuggestionDTO suggestionDTO) { | ||
return Result.succeed(suggestionService.getSuggestions(suggestionDTO.isEnableSchemaSuggestion())); | ||
} | ||
|
||
@PostMapping("/queryAllSuggestionsByKeyWord") | ||
public Result<List<Suggestion>> queryAllSuggestionsByKeyWord(@RequestBody SuggestionDTO suggestionDTO) { | ||
return Result.succeed(suggestionService.getSuggestionsByKeyWord( | ||
suggestionDTO.isEnableSchemaSuggestion(), suggestionDTO.getKeyWord())); | ||
} | ||
|
||
@PostMapping("/queryAllSuggestionsBySqlStatement") | ||
public Result<List<Suggestion>> queryAllSuggestionsBySqlStatement(@RequestBody SuggestionDTO suggestionDTO) { | ||
return Result.succeed(suggestionService.getSuggestionsBySqlStatement( | ||
suggestionDTO.isEnableSchemaSuggestion(), | ||
suggestionDTO.getSqlStatement(), | ||
suggestionDTO.getPosition())); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
dinky-admin/src/main/java/org/dinky/data/dto/SuggestionDTO.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,34 @@ | ||
/* | ||
* | ||
* 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.dinky.data.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SuggestionDTO { | ||
private boolean enableSchemaSuggestion; | ||
private String keyWord; | ||
private String sqlStatement; | ||
private int position; | ||
} |
76 changes: 76 additions & 0 deletions
76
dinky-admin/src/main/java/org/dinky/data/model/suggestion/Suggestion.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,76 @@ | ||
/* | ||
* | ||
* 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.dinky.data.model.suggestion; | ||
|
||
import java.io.Serializable; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class Suggestion implements Serializable { | ||
|
||
private static final long serialVersionUID = 4631906403475634212L; | ||
// label | ||
private SuggestionLabel label; | ||
// kind | ||
/** | ||
* 此字段值可选为: | ||
* <p> | ||
* Method = 0, // 方法 | ||
* Function = 1, // 函数 | ||
* Constructor = 2, // 构造函数 | ||
* Field = 3, // 字段 | ||
* Variable = 4, // 变量 | ||
* Class = 5, // 类 | ||
* Struct = 6, // 结构体 | ||
* Interface = 7, // 接口 | ||
* Module = 8, // 模块 | ||
* Property = 9, // 属性 | ||
* Event = 10, // 事件 | ||
* Operator = 11, // 操作符 | ||
* Unit = 12, // 单元 | ||
* Value = 13, // 值 | ||
* Constant = 14, // 常量 | ||
* Enum = 15, // 枚举 | ||
* EnumMember = 16, // 枚举成员 | ||
* Keyword = 17, // 关键字 | ||
* Text = 18, // 文本 | ||
* Color = 19, // 颜色 | ||
* File = 20, // 文件 | ||
* Reference = 21, // 引用 | ||
* Customcolor = 22, // 自定义颜色 | ||
* Folder = 23, // 文件夹 | ||
* TypeParameter = 24, // 类型参数 | ||
* User = 25, // 用户 | ||
* Issue = 26, // 问题 | ||
* Snippet = 27 // 代码片段 | ||
*/ | ||
private int kind; | ||
// insertText | ||
private String insertText; | ||
// detail | ||
private String detail; | ||
} |
43 changes: 43 additions & 0 deletions
43
dinky-admin/src/main/java/org/dinky/data/model/suggestion/SuggestionLabel.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,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 org.dinky.data.model.suggestion; | ||
|
||
import java.io.Serializable; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class SuggestionLabel implements Serializable { | ||
|
||
private static final long serialVersionUID = 4631906403475634212L; | ||
|
||
// label | ||
private String label; | ||
// value | ||
private String detail; | ||
// description | ||
private String description; | ||
} |
50 changes: 50 additions & 0 deletions
50
dinky-admin/src/main/java/org/dinky/service/SuggestionService.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,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 org.dinky.service; | ||
|
||
import org.dinky.data.model.suggestion.Suggestion; | ||
|
||
import java.util.List; | ||
|
||
public interface SuggestionService { | ||
|
||
/** | ||
* 获取编辑器的建议列表 | ||
* @param enableSchemaSuggestion 是否启用schema建议 | ||
* @return 建议列表 | ||
*/ | ||
List<Suggestion> getSuggestions(boolean enableSchemaSuggestion); | ||
|
||
/** | ||
* 根据关键词获取建议列表 | ||
* @param enableSchemaSuggestion 是否启用schema建议 | ||
* @param keyWord 关键词 | ||
* @return 建议列表 | ||
*/ | ||
List<Suggestion> getSuggestionsByKeyWord(boolean enableSchemaSuggestion, String keyWord); | ||
|
||
/** | ||
* 根据sql获取建议列表 | ||
* @param enableSchemaSuggestion 是否启用schema建议 | ||
* @param sqlStatement sql语句 | ||
* @return 建议列表 | ||
*/ | ||
List<Suggestion> getSuggestionsBySqlStatement(boolean enableSchemaSuggestion, String sqlStatement, int position); | ||
} |
Oops, something went wrong.