Skip to content

Commit

Permalink
refactor dva
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Nov 1, 2023
1 parent cc00f4d commit 7ef9387
Show file tree
Hide file tree
Showing 60 changed files with 2,560 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
Expand Down Expand Up @@ -81,7 +82,7 @@ public class DataBaseController {
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Result}< {@link Void}>
*/
@PutMapping
@PutMapping("/saveOrUpdateDataBase")
@Log(title = "Insert Or Update DataBase", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update DataBase")
@ApiImplicitParam(
Expand Down Expand Up @@ -110,24 +111,17 @@ public Result<Void> saveOrUpdateDataBase(@RequestBody DataBaseDTO dataBaseDTO) {
* @param para {@link JsonNode}
* @return {@link ProTableResult}< {@link DataBase}>
*/
@PostMapping
@GetMapping("/listAll")
@ApiOperation("DataBase Get All")
@ApiImplicitParam(
name = "para",
value = "JsonNode",
required = true,
dataType = "JsonNode",
paramType = "body",
dataTypeClass = JsonNode.class)
public ProTableResult<DataBase> listDataBases(@RequestBody JsonNode para) {
final ProTableResult<DataBase> result = databaseService.selectForProTable(para);
public Result<List<DataBase>> listDataBases() {
final List<DataBase> dataBaseList = databaseService.list();
// 密码不返回
if (result != null && result.getData() != null) {
for (DataBase data : result.getData()) {
if (CollUtil.isNotEmpty(dataBaseList)) {
for (DataBase data : dataBaseList) {
data.setPassword(null);
}
}
return result;
return Result.succeed(dataBaseList);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import org.dinky.service.FragmentVariableService;
import org.dinky.utils.FragmentVariableUtils;

import java.util.List;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -91,7 +94,6 @@ public Result<Void> saveOrUpdateFragment(@RequestBody FragmentVariable fragmentV
* @return {@link ProTableResult} of {@link FragmentVariable}
*/
@PostMapping
@Log(title = "FragmentVariable List", businessType = BusinessType.QUERY)
@ApiOperation("FragmentVariable List")
@ApiImplicitParam(
name = "para",
Expand All @@ -112,6 +114,16 @@ public ProTableResult<FragmentVariable> listFragmentVariable(@RequestBody JsonNo
}
return result;
}
/**
* query list enable
* @return {@link Result} of {@link List<FragmentVariable>}
*/
@GetMapping("/listEnable")
@Log(title = "FragmentVariable List Enable All", businessType = BusinessType.QUERY)
@ApiOperation("FragmentVariable List Enable All")
public Result<List<FragmentVariable>> listFragmentVariableEnable() {
return Result.succeed(fragmentVariableService.listEnabledAll());
}

/**
* delete by id
Expand Down
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 dinky-admin/src/main/java/org/dinky/data/dto/SuggestionDTO.java
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;
}
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;
}
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 dinky-admin/src/main/java/org/dinky/service/SuggestionService.java
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);
}
Loading

0 comments on commit 7ef9387

Please sign in to comment.