Commit eabb360b authored by wenmo's avatar wenmo

admin 代码美化

parent a4a8eb83
...@@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
/** /**
* Dlink 启动器 * Dlink 启动器
*
* @author wenmo * @author wenmo
* @since 2021/5/28 * @since 2021/5/28
*/ */
......
...@@ -14,10 +14,6 @@ import com.dlink.model.Task; ...@@ -14,10 +14,6 @@ import com.dlink.model.Task;
*/ */
public interface Assert { public interface Assert {
static boolean checkNotNull(Object object){
return object!=null;
}
static void check(Cluster cluster) { static void check(Cluster cluster) {
if (cluster.getId() == null) { if (cluster.getId() == null) {
throw new BusException("Flink 集群【" + cluster.getId() + "】不存在"); throw new BusException("Flink 集群【" + cluster.getId() + "】不存在");
......
...@@ -29,46 +29,46 @@ public class APIController { ...@@ -29,46 +29,46 @@ public class APIController {
@GetMapping(value = "/submitTask") @GetMapping(value = "/submitTask")
public Result submitTask(@RequestParam Integer id) { public Result submitTask(@RequestParam Integer id) {
return Result.succeed(taskService.submitTask(id),"执行成功"); return Result.succeed(taskService.submitTask(id), "执行成功");
} }
@PostMapping("/executeSql") @PostMapping("/executeSql")
public Result executeSql(@RequestBody APIExecuteSqlDTO apiExecuteSqlDTO) { public Result executeSql(@RequestBody APIExecuteSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.executeSql(apiExecuteSqlDTO),"执行成功"); return Result.succeed(apiService.executeSql(apiExecuteSqlDTO), "执行成功");
} }
@PostMapping("/explainSql") @PostMapping("/explainSql")
public Result explainSql(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) { public Result explainSql(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.explainSql(apiExecuteSqlDTO),"执行成功"); return Result.succeed(apiService.explainSql(apiExecuteSqlDTO), "执行成功");
} }
@PostMapping("/getJobPlan") @PostMapping("/getJobPlan")
public Result getJobPlan(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) { public Result getJobPlan(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.getJobPlan(apiExecuteSqlDTO),"执行成功"); return Result.succeed(apiService.getJobPlan(apiExecuteSqlDTO), "执行成功");
} }
@PostMapping("/getStreamGraph") @PostMapping("/getStreamGraph")
public Result getStreamGraph(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) { public Result getStreamGraph(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.getStreamGraph(apiExecuteSqlDTO),"执行成功"); return Result.succeed(apiService.getStreamGraph(apiExecuteSqlDTO), "执行成功");
} }
@GetMapping("/getJobData") @GetMapping("/getJobData")
public Result getJobData(@RequestParam String jobId) { public Result getJobData(@RequestParam String jobId) {
return Result.succeed(studioService.getJobData(jobId),"获取成功"); return Result.succeed(studioService.getJobData(jobId), "获取成功");
} }
@PostMapping("/cancel") @PostMapping("/cancel")
public Result cancel(@RequestBody APICancelDTO apiCancelDTO) { public Result cancel(@RequestBody APICancelDTO apiCancelDTO) {
return Result.succeed(apiService.cancel(apiCancelDTO),"执行成功"); return Result.succeed(apiService.cancel(apiCancelDTO), "执行成功");
} }
@PostMapping("/savepoint") @PostMapping("/savepoint")
public Result savepoint(@RequestBody APISavePointDTO apiSavePointDTO) { public Result savepoint(@RequestBody APISavePointDTO apiSavePointDTO) {
return Result.succeed(apiService.savepoint(apiSavePointDTO),"执行成功"); return Result.succeed(apiService.savepoint(apiSavePointDTO), "执行成功");
} }
@PostMapping("/executeJar") @PostMapping("/executeJar")
public Result executeJar(@RequestBody APIExecuteJarDTO apiExecuteJarDTO) { public Result executeJar(@RequestBody APIExecuteJarDTO apiExecuteJarDTO) {
return Result.succeed(apiService.executeJar(apiExecuteJarDTO),"执行成功"); return Result.succeed(apiService.executeJar(apiExecuteJarDTO), "执行成功");
} }
} }
...@@ -31,10 +31,10 @@ public class AdminController { ...@@ -31,10 +31,10 @@ public class AdminController {
*/ */
@PostMapping("/login") @PostMapping("/login")
public Result login(@RequestBody LoginUTO loginUTO) { public Result login(@RequestBody LoginUTO loginUTO) {
if(Asserts.isNull(loginUTO.isAutoLogin())){ if (Asserts.isNull(loginUTO.isAutoLogin())) {
loginUTO.setAutoLogin(false); loginUTO.setAutoLogin(false);
} }
return userService.loginUser(loginUTO.getUsername(), loginUTO.getPassword(),loginUTO.isAutoLogin()); return userService.loginUser(loginUTO.getUsername(), loginUTO.getPassword(), loginUTO.isAutoLogin());
} }
/** /**
...@@ -51,9 +51,9 @@ public class AdminController { ...@@ -51,9 +51,9 @@ public class AdminController {
*/ */
@GetMapping("/current") @GetMapping("/current")
public Result current() throws Exception { public Result current() throws Exception {
try{ try {
return Result.succeed(StpUtil.getSession().get("user"), "获取成功"); return Result.succeed(StpUtil.getSession().get("user"), "获取成功");
}catch (Exception e){ } catch (Exception e) {
return Result.failed("获取失败"); return Result.failed("获取失败");
} }
} }
......
...@@ -40,9 +40,9 @@ public class AlertGroupController { ...@@ -40,9 +40,9 @@ public class AlertGroupController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody AlertGroup alertGroup) throws Exception { public Result saveOrUpdate(@RequestBody AlertGroup alertGroup) throws Exception {
if(alertGroupService.saveOrUpdate(alertGroup)){ if (alertGroupService.saveOrUpdate(alertGroup)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -60,20 +60,20 @@ public class AlertGroupController { ...@@ -60,20 +60,20 @@ public class AlertGroupController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!alertGroupService.removeById(id)){ if (!alertGroupService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -84,7 +84,7 @@ public class AlertGroupController { ...@@ -84,7 +84,7 @@ public class AlertGroupController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody AlertGroup alertGroup) throws Exception { public Result getOneById(@RequestBody AlertGroup alertGroup) throws Exception {
alertGroup = alertGroupService.getById(alertGroup.getId()); alertGroup = alertGroupService.getById(alertGroup.getId());
return Result.succeed(alertGroup,"获取成功"); return Result.succeed(alertGroup, "获取成功");
} }
/** /**
...@@ -92,7 +92,7 @@ public class AlertGroupController { ...@@ -92,7 +92,7 @@ public class AlertGroupController {
*/ */
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
return Result.succeed(alertGroupService.listEnabledAll(),"获取成功"); return Result.succeed(alertGroupService.listEnabledAll(), "获取成功");
} }
/** /**
......
...@@ -35,9 +35,9 @@ public class AlertHistoryController { ...@@ -35,9 +35,9 @@ public class AlertHistoryController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody AlertHistory alertHistory) throws Exception { public Result saveOrUpdate(@RequestBody AlertHistory alertHistory) throws Exception {
if(alertHistoryService.saveOrUpdate(alertHistory)){ if (alertHistoryService.saveOrUpdate(alertHistory)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -55,20 +55,20 @@ public class AlertHistoryController { ...@@ -55,20 +55,20 @@ public class AlertHistoryController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!alertHistoryService.removeById(id)){ if (!alertHistoryService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -79,6 +79,6 @@ public class AlertHistoryController { ...@@ -79,6 +79,6 @@ public class AlertHistoryController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody AlertHistory alertHistory) throws Exception { public Result getOneById(@RequestBody AlertHistory alertHistory) throws Exception {
alertHistory = alertHistoryService.getById(alertHistory.getId()); alertHistory = alertHistoryService.getById(alertHistory.getId());
return Result.succeed(alertHistory,"获取成功"); return Result.succeed(alertHistory, "获取成功");
} }
} }
...@@ -37,10 +37,10 @@ public class AlertInstanceController { ...@@ -37,10 +37,10 @@ public class AlertInstanceController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody AlertInstance alertInstance) throws Exception { public Result saveOrUpdate(@RequestBody AlertInstance alertInstance) throws Exception {
if(alertInstanceService.saveOrUpdate(alertInstance)){ if (alertInstanceService.saveOrUpdate(alertInstance)) {
AlertPool.remove(alertInstance.getName()); AlertPool.remove(alertInstance.getName());
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -58,20 +58,20 @@ public class AlertInstanceController { ...@@ -58,20 +58,20 @@ public class AlertInstanceController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!alertInstanceService.removeById(id)){ if (!alertInstanceService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -82,7 +82,7 @@ public class AlertInstanceController { ...@@ -82,7 +82,7 @@ public class AlertInstanceController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody AlertInstance alertInstance) throws Exception { public Result getOneById(@RequestBody AlertInstance alertInstance) throws Exception {
alertInstance = alertInstanceService.getById(alertInstance.getId()); alertInstance = alertInstanceService.getById(alertInstance.getId());
return Result.succeed(alertInstance,"获取成功"); return Result.succeed(alertInstance, "获取成功");
} }
/** /**
...@@ -90,6 +90,6 @@ public class AlertInstanceController { ...@@ -90,6 +90,6 @@ public class AlertInstanceController {
*/ */
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
return Result.succeed(alertInstanceService.listEnabledAll(),"获取成功"); return Result.succeed(alertInstanceService.listEnabledAll(), "获取成功");
} }
} }
...@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -31,17 +32,17 @@ public class CatalogueController { ...@@ -31,17 +32,17 @@ public class CatalogueController {
private CatalogueService catalogueService; private CatalogueService catalogueService;
@PostMapping("/upload/{id}") @PostMapping("/upload/{id}")
public Result<String> upload(MultipartFile file,@PathVariable Integer id) { public Result<String> upload(MultipartFile file, @PathVariable Integer id) {
//获取上传的路径 //获取上传的路径
String filePath = System.getProperty("user.dir"); String filePath = System.getProperty("user.dir");
//获取源文件的名称 //获取源文件的名称
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String zipPath = filePath+File.separator+fileName; String zipPath = filePath + File.separator + fileName;
String unzipFileName = fileName.substring(0,fileName.lastIndexOf(".")); String unzipFileName = fileName.substring(0, fileName.lastIndexOf("."));
String unzipPath = filePath+File.separator+unzipFileName; String unzipPath = filePath + File.separator + unzipFileName;
File unzipFile = new File(unzipPath); File unzipFile = new File(unzipPath);
File zipFile = new File(zipPath); File zipFile = new File(zipPath);
if(unzipFile.exists()){ if (unzipFile.exists()) {
FileUtil.del(zipFile); FileUtil.del(zipFile);
return Result.failed("工程已存在"); return Result.failed("工程已存在");
} }
...@@ -49,55 +50,55 @@ public class CatalogueController { ...@@ -49,55 +50,55 @@ public class CatalogueController {
//文件写入上传的路径 //文件写入上传的路径
FileUtil.writeBytes(file.getBytes(), zipPath); FileUtil.writeBytes(file.getBytes(), zipPath);
Thread.sleep(1L); Thread.sleep(1L);
if(!unzipFile.exists()){ if (!unzipFile.exists()) {
ZipUtil.unzip(zipPath,filePath); ZipUtil.unzip(zipPath, filePath);
Catalogue cata = getCatalogue(id, unzipFileName); Catalogue cata = getCatalogue(id, unzipFileName);
traverseFile(unzipPath,cata); traverseFile(unzipPath, cata);
} }
} catch (Exception e) { } catch (Exception e) {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
}finally { } finally {
FileUtil.del(zipFile); FileUtil.del(zipFile);
} }
return Result.succeed("上传zip包并创建工程成功"); return Result.succeed("上传zip包并创建工程成功");
} }
private void traverseFile(String sourcePath, Catalogue catalog) throws Exception{ private void traverseFile(String sourcePath, Catalogue catalog) throws Exception {
File file = new File(sourcePath); File file = new File(sourcePath);
File[] fs = file.listFiles(); File[] fs = file.listFiles();
if(fs == null){ if (fs == null) {
throw new RuntimeException("目录层级有误"); throw new RuntimeException("目录层级有误");
} }
for (File fl : fs) { for (File fl : fs) {
if(fl.isFile()){ if (fl.isFile()) {
System.out.println(fl.getName()); System.out.println(fl.getName());
CatalogueTaskDTO dto = getCatalogueTaskDTO(fl.getName(), catalogueService.findByParentIdAndName(catalog.getParentId(), catalog.getName()).getId()); CatalogueTaskDTO dto = getCatalogueTaskDTO(fl.getName(), catalogueService.findByParentIdAndName(catalog.getParentId(), catalog.getName()).getId());
String fileText = getFileText(fl); String fileText = getFileText(fl);
catalogueService.createCatalogAndFileTask(dto,fileText); catalogueService.createCatalogAndFileTask(dto, fileText);
}else{ } else {
Catalogue newCata = getCatalogue(catalogueService.findByParentIdAndName(catalog.getParentId(), catalog.getName()).getId(), fl.getName()); Catalogue newCata = getCatalogue(catalogueService.findByParentIdAndName(catalog.getParentId(), catalog.getName()).getId(), fl.getName());
traverseFile(fl.getPath(),newCata); traverseFile(fl.getPath(), newCata);
} }
} }
} }
private String getFileText(File sourceFile){ private String getFileText(File sourceFile) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
BufferedReader br = null; BufferedReader br = null;
try{ try {
if(sourceFile.isFile() && sourceFile.exists()){ if (sourceFile.isFile() && sourceFile.exists()) {
InputStreamReader isr = new InputStreamReader(new FileInputStream(sourceFile)); InputStreamReader isr = new InputStreamReader(new FileInputStream(sourceFile));
br = new BufferedReader(isr); br = new BufferedReader(isr);
String lineText = null; String lineText = null;
while ((lineText = br.readLine()) != null){ while ((lineText = br.readLine()) != null) {
sb.append(lineText).append("\n"); sb.append(lineText).append("\n");
} }
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
if(br != null){ if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -108,7 +109,7 @@ public class CatalogueController { ...@@ -108,7 +109,7 @@ public class CatalogueController {
return sb.toString(); return sb.toString();
} }
private Catalogue getCatalogue(Integer parentId, String name){ private Catalogue getCatalogue(Integer parentId, String name) {
Catalogue subcata = new Catalogue(); Catalogue subcata = new Catalogue();
subcata.setTaskId(null); subcata.setTaskId(null);
subcata.setName(name); subcata.setName(name);
...@@ -119,9 +120,9 @@ public class CatalogueController { ...@@ -119,9 +120,9 @@ public class CatalogueController {
return subcata; return subcata;
} }
private CatalogueTaskDTO getCatalogueTaskDTO(String alias, Integer parentId){ private CatalogueTaskDTO getCatalogueTaskDTO(String alias, Integer parentId) {
CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO(); CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO();
catalogueTaskDTO.setName(UUID.randomUUID().toString().substring(0,6)+alias); catalogueTaskDTO.setName(UUID.randomUUID().toString().substring(0, 6) + alias);
catalogueTaskDTO.setAlias(alias); catalogueTaskDTO.setAlias(alias);
catalogueTaskDTO.setId(null); catalogueTaskDTO.setId(null);
catalogueTaskDTO.setParentId(parentId); catalogueTaskDTO.setParentId(parentId);
...@@ -135,9 +136,9 @@ public class CatalogueController { ...@@ -135,9 +136,9 @@ public class CatalogueController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Catalogue catalogue) throws Exception { public Result saveOrUpdate(@RequestBody Catalogue catalogue) throws Exception {
if(catalogueService.saveOrUpdate(catalogue)){ if (catalogueService.saveOrUpdate(catalogue)) {
return Result.succeed("创建成功"); return Result.succeed("创建成功");
}else { } else {
return Result.failed("创建失败"); return Result.failed("创建失败");
} }
} }
...@@ -155,21 +156,21 @@ public class CatalogueController { ...@@ -155,21 +156,21 @@ public class CatalogueController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
boolean isAdmin = false; boolean isAdmin = false;
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!catalogueService.removeCatalogueAndTaskById(id)){ if (!catalogueService.removeCatalogueAndTaskById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0&&!isAdmin) { if (error.size() == 0 && !isAdmin) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -180,7 +181,7 @@ public class CatalogueController { ...@@ -180,7 +181,7 @@ public class CatalogueController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Catalogue catalogue) throws Exception { public Result getOneById(@RequestBody Catalogue catalogue) throws Exception {
catalogue = catalogueService.getById(catalogue.getId()); catalogue = catalogueService.getById(catalogue.getId());
return Result.succeed(catalogue,"获取成功"); return Result.succeed(catalogue, "获取成功");
} }
/** /**
...@@ -189,7 +190,7 @@ public class CatalogueController { ...@@ -189,7 +190,7 @@ public class CatalogueController {
@PostMapping("/getCatalogueTreeData") @PostMapping("/getCatalogueTreeData")
public Result getCatalogueTreeData() throws Exception { public Result getCatalogueTreeData() throws Exception {
List<Catalogue> catalogues = catalogueService.getAllData(); List<Catalogue> catalogues = catalogueService.getAllData();
return Result.succeed(catalogues,"获取成功"); return Result.succeed(catalogues, "获取成功");
} }
/** /**
...@@ -198,9 +199,9 @@ public class CatalogueController { ...@@ -198,9 +199,9 @@ public class CatalogueController {
@PutMapping("/createTask") @PutMapping("/createTask")
public Result createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) throws Exception { public Result createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) throws Exception {
Catalogue catalogue = catalogueService.createCatalogueAndTask(catalogueTaskDTO); Catalogue catalogue = catalogueService.createCatalogueAndTask(catalogueTaskDTO);
if(catalogue.getId()!=null){ if (catalogue.getId() != null) {
return Result.succeed(catalogue,"创建成功"); return Result.succeed(catalogue, "创建成功");
}else { } else {
return Result.failed("创建失败"); return Result.failed("创建失败");
} }
} }
...@@ -210,9 +211,9 @@ public class CatalogueController { ...@@ -210,9 +211,9 @@ public class CatalogueController {
*/ */
@PutMapping("/toRename") @PutMapping("/toRename")
public Result toRename(@RequestBody Catalogue catalogue) throws Exception { public Result toRename(@RequestBody Catalogue catalogue) throws Exception {
if(catalogueService.toRename(catalogue)){ if (catalogueService.toRename(catalogue)) {
return Result.succeed("重命名成功"); return Result.succeed("重命名成功");
}else { } else {
return Result.failed("重命名失败"); return Result.failed("重命名失败");
} }
} }
......
...@@ -39,9 +39,9 @@ public class ClusterConfigurationController { ...@@ -39,9 +39,9 @@ public class ClusterConfigurationController {
public Result saveOrUpdate(@RequestBody ClusterConfiguration clusterConfiguration) { public Result saveOrUpdate(@RequestBody ClusterConfiguration clusterConfiguration) {
TestResult testResult = clusterConfigurationService.testGateway(clusterConfiguration); TestResult testResult = clusterConfigurationService.testGateway(clusterConfiguration);
clusterConfiguration.setAvailable(testResult.isAvailable()); clusterConfiguration.setAvailable(testResult.isAvailable());
if(clusterConfigurationService.saveOrUpdate(clusterConfiguration)){ if (clusterConfigurationService.saveOrUpdate(clusterConfiguration)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -59,20 +59,20 @@ public class ClusterConfigurationController { ...@@ -59,20 +59,20 @@ public class ClusterConfigurationController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!clusterConfigurationService.removeById(id)){ if (!clusterConfigurationService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -83,7 +83,7 @@ public class ClusterConfigurationController { ...@@ -83,7 +83,7 @@ public class ClusterConfigurationController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody ClusterConfiguration clusterConfiguration) { public Result getOneById(@RequestBody ClusterConfiguration clusterConfiguration) {
clusterConfiguration = clusterConfigurationService.getById(clusterConfiguration.getId()); clusterConfiguration = clusterConfigurationService.getById(clusterConfiguration.getId());
return Result.succeed(clusterConfiguration,"获取成功"); return Result.succeed(clusterConfiguration, "获取成功");
} }
/** /**
...@@ -91,8 +91,8 @@ public class ClusterConfigurationController { ...@@ -91,8 +91,8 @@ public class ClusterConfigurationController {
*/ */
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
List<ClusterConfiguration >clusters = clusterConfigurationService.listEnabledAll(); List<ClusterConfiguration> clusters = clusterConfigurationService.listEnabledAll();
return Result.succeed(clusters,"获取成功"); return Result.succeed(clusters, "获取成功");
} }
/** /**
...@@ -101,9 +101,9 @@ public class ClusterConfigurationController { ...@@ -101,9 +101,9 @@ public class ClusterConfigurationController {
@PostMapping("/testConnect") @PostMapping("/testConnect")
public Result testConnect(@RequestBody ClusterConfiguration clusterConfiguration) { public Result testConnect(@RequestBody ClusterConfiguration clusterConfiguration) {
TestResult testResult = clusterConfigurationService.testGateway(clusterConfiguration); TestResult testResult = clusterConfigurationService.testGateway(clusterConfiguration);
if(testResult.isAvailable()){ if (testResult.isAvailable()) {
return Result.succeed("测试链接成功"); return Result.succeed("测试链接成功");
}else { } else {
return Result.failed(testResult.getError()); return Result.failed(testResult.getError());
} }
} }
......
...@@ -36,7 +36,7 @@ public class ClusterController { ...@@ -36,7 +36,7 @@ public class ClusterController {
public Result saveOrUpdate(@RequestBody Cluster cluster) throws Exception { public Result saveOrUpdate(@RequestBody Cluster cluster) throws Exception {
cluster.setAutoRegisters(false); cluster.setAutoRegisters(false);
clusterService.registersCluster(cluster); clusterService.registersCluster(cluster);
return Result.succeed(Asserts.isNotNull(cluster.getId())?"修改成功":"新增成功"); return Result.succeed(Asserts.isNotNull(cluster.getId()) ? "修改成功" : "新增成功");
} }
/** /**
...@@ -61,20 +61,20 @@ public class ClusterController { ...@@ -61,20 +61,20 @@ public class ClusterController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!clusterService.removeById(id)){ if (!clusterService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -85,7 +85,7 @@ public class ClusterController { ...@@ -85,7 +85,7 @@ public class ClusterController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Cluster cluster) throws Exception { public Result getOneById(@RequestBody Cluster cluster) throws Exception {
cluster = clusterService.getById(cluster.getId()); cluster = clusterService.getById(cluster.getId());
return Result.succeed(cluster,"获取成功"); return Result.succeed(cluster, "获取成功");
} }
/** /**
...@@ -93,8 +93,8 @@ public class ClusterController { ...@@ -93,8 +93,8 @@ public class ClusterController {
*/ */
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
List<Cluster >clusters = clusterService.listEnabledAll(); List<Cluster> clusters = clusterService.listEnabledAll();
return Result.succeed(clusters,"获取成功"); return Result.succeed(clusters, "获取成功");
} }
/** /**
...@@ -102,8 +102,8 @@ public class ClusterController { ...@@ -102,8 +102,8 @@ public class ClusterController {
*/ */
@GetMapping("/listSessionEnable") @GetMapping("/listSessionEnable")
public Result listSessionEnable() { public Result listSessionEnable() {
List<Cluster >clusters = clusterService.listSessionEnable(); List<Cluster> clusters = clusterService.listSessionEnable();
return Result.succeed(clusters,"获取成功"); return Result.succeed(clusters, "获取成功");
} }
/** /**
...@@ -124,7 +124,7 @@ public class ClusterController { ...@@ -124,7 +124,7 @@ public class ClusterController {
*/ */
@GetMapping("/clear") @GetMapping("/clear")
public Result clear() { public Result clear() {
return Result.succeed(clusterService.clearCluster(),"回收完成"); return Result.succeed(clusterService.clearCluster(), "回收完成");
} }
} }
...@@ -36,10 +36,10 @@ public class DataBaseController { ...@@ -36,10 +36,10 @@ public class DataBaseController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody DataBase database) { public Result saveOrUpdate(@RequestBody DataBase database) {
if(databaseService.saveOrUpdateDataBase(database)){ if (databaseService.saveOrUpdateDataBase(database)) {
DriverPool.remove(database.getName()); DriverPool.remove(database.getName());
return Result.succeed("更新成功"); return Result.succeed("更新成功");
}else { } else {
return Result.failed("更新失败"); return Result.failed("更新失败");
} }
} }
...@@ -57,20 +57,20 @@ public class DataBaseController { ...@@ -57,20 +57,20 @@ public class DataBaseController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!databaseService.removeById(id)){ if (!databaseService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -81,7 +81,7 @@ public class DataBaseController { ...@@ -81,7 +81,7 @@ public class DataBaseController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody DataBase database) { public Result getOneById(@RequestBody DataBase database) {
database = databaseService.getById(database.getId()); database = databaseService.getById(database.getId());
return Result.succeed(database,"获取成功"); return Result.succeed(database, "获取成功");
} }
/** /**
...@@ -90,18 +90,19 @@ public class DataBaseController { ...@@ -90,18 +90,19 @@ public class DataBaseController {
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
List<DataBase> dataBases = databaseService.listEnabledAll(); List<DataBase> dataBases = databaseService.listEnabledAll();
return Result.succeed(dataBases,"获取成功"); return Result.succeed(dataBases, "获取成功");
} }
/** /**
* 连接测试 * 连接测试
*/ */
@PostMapping("/testConnect") @PostMapping("/testConnect")
public Result testConnect(@RequestBody DataBase database) { public Result testConnect(@RequestBody DataBase database) {
String msg = databaseService.testConnect(database); String msg = databaseService.testConnect(database);
boolean isHealthy = Asserts.isEquals(CommonConstant.HEALTHY,msg); boolean isHealthy = Asserts.isEquals(CommonConstant.HEALTHY, msg);
if(isHealthy){ if (isHealthy) {
return Result.succeed("数据源连接测试成功!"); return Result.succeed("数据源连接测试成功!");
}else{ } else {
return Result.failed(msg); return Result.failed(msg);
} }
} }
...@@ -126,10 +127,10 @@ public class DataBaseController { ...@@ -126,10 +127,10 @@ public class DataBaseController {
@GetMapping("/checkHeartBeatById") @GetMapping("/checkHeartBeatById")
public Result checkHeartBeatById(@RequestParam Integer id) { public Result checkHeartBeatById(@RequestParam Integer id) {
DataBase dataBase = databaseService.getById(id); DataBase dataBase = databaseService.getById(id);
Asserts.checkNotNull(dataBase,"该数据源不存在!"); Asserts.checkNotNull(dataBase, "该数据源不存在!");
databaseService.checkHeartBeat(dataBase); databaseService.checkHeartBeat(dataBase);
databaseService.updateById(dataBase); databaseService.updateById(dataBase);
return Result.succeed(dataBase,"状态刷新完成"); return Result.succeed(dataBase, "状态刷新完成");
} }
/** /**
...@@ -137,22 +138,22 @@ public class DataBaseController { ...@@ -137,22 +138,22 @@ public class DataBaseController {
*/ */
@GetMapping("/getSchemasAndTables") @GetMapping("/getSchemasAndTables")
public Result getSchemasAndTables(@RequestParam Integer id) { public Result getSchemasAndTables(@RequestParam Integer id) {
return Result.succeed(databaseService.getSchemasAndTables(id),"获取成功"); return Result.succeed(databaseService.getSchemasAndTables(id), "获取成功");
} }
/** /**
* 获取元数据的指定表的列 * 获取元数据的指定表的列
*/ */
@GetMapping("/listColumns") @GetMapping("/listColumns")
public Result listColumns(@RequestParam Integer id,@RequestParam String schemaName,@RequestParam String tableName) { public Result listColumns(@RequestParam Integer id, @RequestParam String schemaName, @RequestParam String tableName) {
return Result.succeed(databaseService.listColumns(id,schemaName,tableName),"获取成功"); return Result.succeed(databaseService.listColumns(id, schemaName, tableName), "获取成功");
} }
/** /**
* 获取 SqlGeneration * 获取 SqlGeneration
*/ */
@GetMapping("/getSqlGeneration") @GetMapping("/getSqlGeneration")
public Result getSqlGeneration(@RequestParam Integer id,@RequestParam String schemaName,@RequestParam String tableName) { public Result getSqlGeneration(@RequestParam Integer id, @RequestParam String schemaName, @RequestParam String tableName) {
return Result.succeed(databaseService.getSqlGeneration(id,schemaName,tableName),"获取成功"); return Result.succeed(databaseService.getSqlGeneration(id, schemaName, tableName), "获取成功");
} }
} }
\ No newline at end of file
...@@ -30,9 +30,9 @@ public class DocumentController { ...@@ -30,9 +30,9 @@ public class DocumentController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Document document) throws Exception { public Result saveOrUpdate(@RequestBody Document document) throws Exception {
if(documentService.saveOrUpdate(document)){ if (documentService.saveOrUpdate(document)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -50,20 +50,20 @@ public class DocumentController { ...@@ -50,20 +50,20 @@ public class DocumentController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!documentService.removeById(id)){ if (!documentService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -74,7 +74,7 @@ public class DocumentController { ...@@ -74,7 +74,7 @@ public class DocumentController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Document document) throws Exception { public Result getOneById(@RequestBody Document document) throws Exception {
document = documentService.getById(document.getId()); document = documentService.getById(document.getId());
return Result.succeed(document,"获取成功"); return Result.succeed(document, "获取成功");
} }
/** /**
...@@ -82,6 +82,6 @@ public class DocumentController { ...@@ -82,6 +82,6 @@ public class DocumentController {
*/ */
@GetMapping("/getFillAllByVersion") @GetMapping("/getFillAllByVersion")
public Result getFillAllByVersion(@RequestParam String version) { public Result getFillAllByVersion(@RequestParam String version) {
return Result.succeed(documentService.getFillAllByVersion(version),"获取成功"); return Result.succeed(documentService.getFillAllByVersion(version), "获取成功");
} }
} }
...@@ -38,20 +38,20 @@ public class HistoryController { ...@@ -38,20 +38,20 @@ public class HistoryController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!historyService.removeHistoryById(id)){ if (!historyService.removeHistoryById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -62,7 +62,7 @@ public class HistoryController { ...@@ -62,7 +62,7 @@ public class HistoryController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody History history) throws Exception { public Result getOneById(@RequestBody History history) throws Exception {
history = historyService.getById(history.getId()); history = historyService.getById(history.getId());
return Result.succeed(history,"获取成功"); return Result.succeed(history, "获取成功");
} }
} }
...@@ -36,9 +36,9 @@ public class JarController { ...@@ -36,9 +36,9 @@ public class JarController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Jar jar) throws Exception { public Result saveOrUpdate(@RequestBody Jar jar) throws Exception {
if(jarService.saveOrUpdate(jar)){ if (jarService.saveOrUpdate(jar)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -56,20 +56,20 @@ public class JarController { ...@@ -56,20 +56,20 @@ public class JarController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!jarService.removeById(id)){ if (!jarService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -80,7 +80,7 @@ public class JarController { ...@@ -80,7 +80,7 @@ public class JarController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Jar jar) throws Exception { public Result getOneById(@RequestBody Jar jar) throws Exception {
jar = jarService.getById(jar.getId()); jar = jarService.getById(jar.getId());
return Result.succeed(jar,"获取成功"); return Result.succeed(jar, "获取成功");
} }
/** /**
...@@ -88,7 +88,7 @@ public class JarController { ...@@ -88,7 +88,7 @@ public class JarController {
*/ */
@GetMapping("/listEnabledAll") @GetMapping("/listEnabledAll")
public Result listEnabledAll() { public Result listEnabledAll() {
List<Jar >jars = jarService.listEnabledAll(); List<Jar> jars = jarService.listEnabledAll();
return Result.succeed(jars,"获取成功"); return Result.succeed(jars, "获取成功");
} }
} }
...@@ -75,9 +75,9 @@ public class JobInstanceController { ...@@ -75,9 +75,9 @@ public class JobInstanceController {
*/ */
@GetMapping("/getStatusCount") @GetMapping("/getStatusCount")
public Result getStatusCount() { public Result getStatusCount() {
HashMap<String,Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
result.put("history",jobInstanceService.getStatusCount(true)); result.put("history", jobInstanceService.getStatusCount(true));
result.put("instance",jobInstanceService.getStatusCount(false)); result.put("instance", jobInstanceService.getStatusCount(false));
return Result.succeed(result, "获取成功"); return Result.succeed(result, "获取成功");
} }
......
...@@ -30,9 +30,9 @@ public class SavepointsController { ...@@ -30,9 +30,9 @@ public class SavepointsController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Savepoints savepoints) throws Exception { public Result saveOrUpdate(@RequestBody Savepoints savepoints) throws Exception {
if(savepointsService.saveOrUpdate(savepoints)){ if (savepointsService.saveOrUpdate(savepoints)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -50,20 +50,20 @@ public class SavepointsController { ...@@ -50,20 +50,20 @@ public class SavepointsController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!savepointsService.removeById(id)){ if (!savepointsService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -74,7 +74,7 @@ public class SavepointsController { ...@@ -74,7 +74,7 @@ public class SavepointsController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Savepoints savepoints) throws Exception { public Result getOneById(@RequestBody Savepoints savepoints) throws Exception {
savepoints = savepointsService.getById(savepoints.getId()); savepoints = savepointsService.getById(savepoints.getId());
return Result.succeed(savepoints,"获取成功"); return Result.succeed(savepoints, "获取成功");
} }
/** /**
...@@ -82,6 +82,6 @@ public class SavepointsController { ...@@ -82,6 +82,6 @@ public class SavepointsController {
*/ */
@GetMapping("/listSavepointsByTaskId") @GetMapping("/listSavepointsByTaskId")
public Result listSavepointsByTaskId(@RequestParam Integer taskID) throws Exception { public Result listSavepointsByTaskId(@RequestParam Integer taskID) throws Exception {
return Result.succeed(savepointsService.listSavepointsByTaskId(taskID),"获取成功"); return Result.succeed(savepointsService.listSavepointsByTaskId(taskID), "获取成功");
} }
} }
...@@ -36,9 +36,9 @@ public class StatementController { ...@@ -36,9 +36,9 @@ public class StatementController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Statement statement) throws Exception { public Result saveOrUpdate(@RequestBody Statement statement) throws Exception {
if(statementService.saveOrUpdate(statement)){ if (statementService.saveOrUpdate(statement)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -56,21 +56,21 @@ public class StatementController { ...@@ -56,21 +56,21 @@ public class StatementController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
boolean isAdmin = false; boolean isAdmin = false;
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!statementService.removeById(id)){ if (!statementService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0&&!isAdmin) { if (error.size() == 0 && !isAdmin) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -81,7 +81,7 @@ public class StatementController { ...@@ -81,7 +81,7 @@ public class StatementController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody Statement statement) throws Exception { public Result getOneById(@RequestBody Statement statement) throws Exception {
statement = statementService.getById(statement.getId()); statement = statementService.getById(statement.getId());
return Result.succeed(statement,"获取成功"); return Result.succeed(statement, "获取成功");
} }
} }
...@@ -36,7 +36,7 @@ public class StudioController { ...@@ -36,7 +36,7 @@ public class StudioController {
@PostMapping("/executeSql") @PostMapping("/executeSql")
public Result executeSql(@RequestBody StudioExecuteDTO studioExecuteDTO) { public Result executeSql(@RequestBody StudioExecuteDTO studioExecuteDTO) {
JobResult jobResult = studioService.executeSql(studioExecuteDTO); JobResult jobResult = studioService.executeSql(studioExecuteDTO);
return Result.succeed(jobResult,"执行成功"); return Result.succeed(jobResult, "执行成功");
} }
/** /**
...@@ -44,7 +44,7 @@ public class StudioController { ...@@ -44,7 +44,7 @@ public class StudioController {
*/ */
@PostMapping("/explainSql") @PostMapping("/explainSql")
public Result explainSql(@RequestBody StudioExecuteDTO studioExecuteDTO) { public Result explainSql(@RequestBody StudioExecuteDTO studioExecuteDTO) {
return Result.succeed(studioService.explainSql(studioExecuteDTO),"解释成功"); return Result.succeed(studioService.explainSql(studioExecuteDTO), "解释成功");
} }
/** /**
...@@ -52,7 +52,7 @@ public class StudioController { ...@@ -52,7 +52,7 @@ public class StudioController {
*/ */
@PostMapping("/getStreamGraph") @PostMapping("/getStreamGraph")
public Result getStreamGraph(@RequestBody StudioExecuteDTO studioExecuteDTO) { public Result getStreamGraph(@RequestBody StudioExecuteDTO studioExecuteDTO) {
return Result.succeed(studioService.getStreamGraph(studioExecuteDTO),"获取执行图成功"); return Result.succeed(studioService.getStreamGraph(studioExecuteDTO), "获取执行图成功");
} }
/** /**
...@@ -60,7 +60,7 @@ public class StudioController { ...@@ -60,7 +60,7 @@ public class StudioController {
*/ */
@PostMapping("/getJobPlan") @PostMapping("/getJobPlan")
public Result getJobPlan(@RequestBody StudioExecuteDTO studioExecuteDTO) { public Result getJobPlan(@RequestBody StudioExecuteDTO studioExecuteDTO) {
return Result.succeed(studioService.getJobPlan(studioExecuteDTO),"获取作业计划成功"); return Result.succeed(studioService.getJobPlan(studioExecuteDTO), "获取作业计划成功");
} }
/** /**
...@@ -69,7 +69,7 @@ public class StudioController { ...@@ -69,7 +69,7 @@ public class StudioController {
@PostMapping("/executeDDL") @PostMapping("/executeDDL")
public Result executeDDL(@RequestBody StudioDDLDTO studioDDLDTO) { public Result executeDDL(@RequestBody StudioDDLDTO studioDDLDTO) {
IResult result = studioService.executeDDL(studioDDLDTO); IResult result = studioService.executeDDL(studioDDLDTO);
return Result.succeed(result,"执行成功"); return Result.succeed(result, "执行成功");
} }
/** /**
...@@ -77,7 +77,7 @@ public class StudioController { ...@@ -77,7 +77,7 @@ public class StudioController {
*/ */
@GetMapping("/getJobData") @GetMapping("/getJobData")
public Result getJobData(@RequestParam String jobId) { public Result getJobData(@RequestParam String jobId) {
return Result.succeed(studioService.getJobData(jobId),"获取成功"); return Result.succeed(studioService.getJobData(jobId), "获取成功");
} }
/** /**
...@@ -93,7 +93,7 @@ public class StudioController { ...@@ -93,7 +93,7 @@ public class StudioController {
*/ */
@PutMapping("/createSession") @PutMapping("/createSession")
public Result createSession(@RequestBody SessionDTO sessionDTO) { public Result createSession(@RequestBody SessionDTO sessionDTO) {
return Result.succeed(studioService.createSession(sessionDTO,"admin"),"创建成功"); return Result.succeed(studioService.createSession(sessionDTO, "admin"), "创建成功");
} }
/** /**
...@@ -101,20 +101,20 @@ public class StudioController { ...@@ -101,20 +101,20 @@ public class StudioController {
*/ */
@DeleteMapping("/clearSession") @DeleteMapping("/clearSession")
public Result clearSession(@RequestBody JsonNode para) { public Result clearSession(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<String> error = new ArrayList<>(); List<String> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
String session = item.asText(); String session = item.asText();
if(!studioService.clearSession(session)){ if (!studioService.clearSession(session)) {
error.add(session); error.add(session);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("清除成功"); return Result.succeed("清除成功");
}else { } else {
return Result.succeed("清除部分成功,但"+error.toString()+"清除失败,共"+error.size()+"次失败。"); return Result.succeed("清除部分成功,但" + error.toString() + "清除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要清除的记录"); return Result.failed("请选择要清除的记录");
} }
} }
...@@ -124,7 +124,7 @@ public class StudioController { ...@@ -124,7 +124,7 @@ public class StudioController {
*/ */
@GetMapping("/listSession") @GetMapping("/listSession")
public Result listSession() { public Result listSession() {
return Result.succeed(studioService.listSession("admin"),"获取成功"); return Result.succeed(studioService.listSession("admin"), "获取成功");
} }
/** /**
...@@ -133,23 +133,23 @@ public class StudioController { ...@@ -133,23 +133,23 @@ public class StudioController {
@GetMapping("/listJobs") @GetMapping("/listJobs")
public Result listJobs(@RequestParam Integer clusterId) { public Result listJobs(@RequestParam Integer clusterId) {
List<JsonNode> jobs = studioService.listJobs(clusterId); List<JsonNode> jobs = studioService.listJobs(clusterId);
return Result.succeed(jobs.toArray(),"获取成功"); return Result.succeed(jobs.toArray(), "获取成功");
} }
/** /**
* 停止任务 * 停止任务
*/ */
@GetMapping("/cancel") @GetMapping("/cancel")
public Result cancel(@RequestParam Integer clusterId,@RequestParam String jobId) { public Result cancel(@RequestParam Integer clusterId, @RequestParam String jobId) {
return Result.succeed(studioService.cancel(clusterId,jobId),"停止成功"); return Result.succeed(studioService.cancel(clusterId, jobId), "停止成功");
} }
/** /**
* savepoint * savepoint
*/ */
@GetMapping("/savepoint") @GetMapping("/savepoint")
public Result savepoint(@RequestParam Integer clusterId,@RequestParam String jobId, public Result savepoint(@RequestParam Integer clusterId, @RequestParam String jobId,
@RequestParam String savePointType,@RequestParam String name,@RequestParam Integer taskId) { @RequestParam String savePointType, @RequestParam String name, @RequestParam Integer taskId) {
return Result.succeed(studioService.savepoint(taskId,clusterId,jobId,savePointType,name),"savepoint 成功"); return Result.succeed(studioService.savepoint(taskId, clusterId, jobId, savePointType, name), "savepoint 成功");
} }
} }
...@@ -30,9 +30,9 @@ public class SysConfigController { ...@@ -30,9 +30,9 @@ public class SysConfigController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody SysConfig sysConfig) throws Exception { public Result saveOrUpdate(@RequestBody SysConfig sysConfig) throws Exception {
if(sysConfigService.saveOrUpdate(sysConfig)){ if (sysConfigService.saveOrUpdate(sysConfig)) {
return Result.succeed("新增成功"); return Result.succeed("新增成功");
}else { } else {
return Result.failed("新增失败"); return Result.failed("新增失败");
} }
} }
...@@ -50,20 +50,20 @@ public class SysConfigController { ...@@ -50,20 +50,20 @@ public class SysConfigController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!sysConfigService.removeById(id)){ if (!sysConfigService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -74,7 +74,7 @@ public class SysConfigController { ...@@ -74,7 +74,7 @@ public class SysConfigController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody SysConfig sysConfig) throws Exception { public Result getOneById(@RequestBody SysConfig sysConfig) throws Exception {
sysConfig = sysConfigService.getById(sysConfig.getId()); sysConfig = sysConfigService.getById(sysConfig.getId());
return Result.succeed(sysConfig,"获取成功"); return Result.succeed(sysConfig, "获取成功");
} }
/** /**
...@@ -82,7 +82,7 @@ public class SysConfigController { ...@@ -82,7 +82,7 @@ public class SysConfigController {
*/ */
@GetMapping("/getAll") @GetMapping("/getAll")
public Result getAll() { public Result getAll() {
return Result.succeed(sysConfigService.getAll(),"获取成功"); return Result.succeed(sysConfigService.getAll(), "获取成功");
} }
/** /**
......
...@@ -32,9 +32,9 @@ public class TaskController { ...@@ -32,9 +32,9 @@ public class TaskController {
*/ */
@PutMapping @PutMapping
public Result saveOrUpdate(@RequestBody Task task) throws Exception { public Result saveOrUpdate(@RequestBody Task task) throws Exception {
if(taskService.saveOrUpdateTask(task)){ if (taskService.saveOrUpdateTask(task)) {
return Result.succeed("操作成功"); return Result.succeed("操作成功");
}else { } else {
return Result.failed("操作失败"); return Result.failed("操作失败");
} }
} }
...@@ -52,21 +52,21 @@ public class TaskController { ...@@ -52,21 +52,21 @@ public class TaskController {
*/ */
@DeleteMapping @DeleteMapping
public Result deleteMul(@RequestBody JsonNode para) { public Result deleteMul(@RequestBody JsonNode para) {
if (para.size()>0){ if (para.size() > 0) {
boolean isAdmin = false; boolean isAdmin = false;
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(!taskService.removeById(id)){ if (!taskService.removeById(id)) {
error.add(id); error.add(id);
} }
} }
if(error.size()==0&&!isAdmin) { if (error.size() == 0 && !isAdmin) {
return Result.succeed("删除成功"); return Result.succeed("删除成功");
}else { } else {
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); return Result.succeed("删除部分成功,但" + error.toString() + "删除失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要删除的记录"); return Result.failed("请选择要删除的记录");
} }
} }
...@@ -76,23 +76,23 @@ public class TaskController { ...@@ -76,23 +76,23 @@ public class TaskController {
*/ */
@PostMapping(value = "/submit") @PostMapping(value = "/submit")
public Result submit(@RequestBody JsonNode para) throws Exception { public Result submit(@RequestBody JsonNode para) throws Exception {
if (para.size()>0){ if (para.size() > 0) {
List<JobResult> results = new ArrayList<>(); List<JobResult> results = new ArrayList<>();
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){ for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
JobResult result = taskService.submitTask(id); JobResult result = taskService.submitTask(id);
if(!result.isSuccess()){ if (!result.isSuccess()) {
error.add(id); error.add(id);
} }
results.add(result); results.add(result);
} }
if(error.size()==0) { if (error.size() == 0) {
return Result.succeed(results,"执行成功"); return Result.succeed(results, "执行成功");
}else { } else {
return Result.succeed(results,"执行部分成功,但"+error.toString()+"执行失败,共"+error.size()+"次失败。"); return Result.succeed(results, "执行部分成功,但" + error.toString() + "执行失败,共" + error.size() + "次失败。");
} }
}else{ } else {
return Result.failed("请选择要执行的记录"); return Result.failed("请选择要执行的记录");
} }
} }
...@@ -103,7 +103,7 @@ public class TaskController { ...@@ -103,7 +103,7 @@ public class TaskController {
@GetMapping @GetMapping
public Result getOneById(@RequestParam Integer id) { public Result getOneById(@RequestParam Integer id) {
Task task = taskService.getTaskInfoById(id); Task task = taskService.getTaskInfoById(id);
return Result.succeed(task,"获取成功"); return Result.succeed(task, "获取成功");
} }
/** /**
...@@ -111,7 +111,7 @@ public class TaskController { ...@@ -111,7 +111,7 @@ public class TaskController {
*/ */
@GetMapping(value = "/listFlinkSQLEnv") @GetMapping(value = "/listFlinkSQLEnv")
public Result listFlinkSQLEnv() { public Result listFlinkSQLEnv() {
return Result.succeed(taskService.listFlinkSQLEnv(),"获取成功"); return Result.succeed(taskService.listFlinkSQLEnv(), "获取成功");
} }
/** /**
...@@ -119,7 +119,7 @@ public class TaskController { ...@@ -119,7 +119,7 @@ public class TaskController {
*/ */
@GetMapping(value = "/exportSql") @GetMapping(value = "/exportSql")
public Result exportSql(@RequestParam Integer id) { public Result exportSql(@RequestParam Integer id) {
return Result.succeed(taskService.exportSql(id),"获取成功"); return Result.succeed(taskService.exportSql(id), "获取成功");
} }
/** /**
...@@ -135,7 +135,7 @@ public class TaskController { ...@@ -135,7 +135,7 @@ public class TaskController {
*/ */
@GetMapping(value = "/developTask") @GetMapping(value = "/developTask")
public Result developTask(@RequestParam Integer id) { public Result developTask(@RequestParam Integer id) {
return Result.succeed(taskService.developTask(id),"操作成功"); return Result.succeed(taskService.developTask(id), "操作成功");
} }
/** /**
...@@ -150,8 +150,8 @@ public class TaskController { ...@@ -150,8 +150,8 @@ public class TaskController {
* 下线任务 * 下线任务
*/ */
@GetMapping(value = "/offLineTask") @GetMapping(value = "/offLineTask")
public Result offLineTask(@RequestParam Integer id,@RequestParam String type) { public Result offLineTask(@RequestParam Integer id, @RequestParam String type) {
return taskService.offLineTask(id,type); return taskService.offLineTask(id, type);
} }
/** /**
...@@ -167,7 +167,7 @@ public class TaskController { ...@@ -167,7 +167,7 @@ public class TaskController {
*/ */
@GetMapping(value = "/recoveryTask") @GetMapping(value = "/recoveryTask")
public Result recoveryTask(@RequestParam Integer id) { public Result recoveryTask(@RequestParam Integer id) {
return Result.succeed(taskService.recoveryTask(id),"操作成功"); return Result.succeed(taskService.recoveryTask(id), "操作成功");
} }
/** /**
...@@ -175,7 +175,7 @@ public class TaskController { ...@@ -175,7 +175,7 @@ public class TaskController {
*/ */
@GetMapping(value = "/restartTask") @GetMapping(value = "/restartTask")
public Result restartTask(@RequestParam Integer id) { public Result restartTask(@RequestParam Integer id) {
return Result.succeed(taskService.restartTask(id),"操作成功"); return Result.succeed(taskService.restartTask(id), "操作成功");
} }
} }
...@@ -61,7 +61,7 @@ public class UserController { ...@@ -61,7 +61,7 @@ public class UserController {
List<Integer> error = new ArrayList<>(); List<Integer> error = new ArrayList<>();
for (final JsonNode item : para) { for (final JsonNode item : para) {
Integer id = item.asInt(); Integer id = item.asInt();
if(checkAdmin(id)){ if (checkAdmin(id)) {
error.add(id); error.add(id);
continue; continue;
} }
...@@ -89,7 +89,7 @@ public class UserController { ...@@ -89,7 +89,7 @@ public class UserController {
@PostMapping("/getOneById") @PostMapping("/getOneById")
public Result getOneById(@RequestBody User user) { public Result getOneById(@RequestBody User user) {
user = userService.getById(user.getId()); user = userService.getById(user.getId());
return Result.succeed(user,"获取成功"); return Result.succeed(user, "获取成功");
} }
/** /**
...@@ -97,7 +97,7 @@ public class UserController { ...@@ -97,7 +97,7 @@ public class UserController {
*/ */
@PostMapping("/modifyPassword") @PostMapping("/modifyPassword")
public Result modifyPassword(@RequestBody ModifyPasswordDTO modifyPasswordDTO) { public Result modifyPassword(@RequestBody ModifyPasswordDTO modifyPasswordDTO) {
return userService.modifyPassword(modifyPasswordDTO.getUsername(),modifyPasswordDTO.getPassword(), return userService.modifyPassword(modifyPasswordDTO.getUsername(), modifyPasswordDTO.getPassword(),
modifyPasswordDTO.getNewPassword()); modifyPasswordDTO.getNewPassword());
} }
} }
...@@ -26,7 +26,7 @@ import java.time.LocalDateTime; ...@@ -26,7 +26,7 @@ import java.time.LocalDateTime;
*/ */
@Setter @Setter
@Getter @Getter
public class SuperEntity<T extends Model<?>> extends Model<T> implements Serializable{ public class SuperEntity<T extends Model<?>> extends Model<T> implements Serializable {
/** /**
* 主键ID * 主键ID
*/ */
......
...@@ -20,6 +20,6 @@ public interface ISuperService<T> extends IService<T> { ...@@ -20,6 +20,6 @@ public interface ISuperService<T> extends IService<T> {
ProTableResult<T> selectForProTable(JsonNode para, boolean isDelete); ProTableResult<T> selectForProTable(JsonNode para, boolean isDelete);
ProTableResult<T> selectForProTable(JsonNode para,Map<String, Object> paraMap); ProTableResult<T> selectForProTable(JsonNode para, Map<String, Object> paraMap);
} }
...@@ -37,11 +37,11 @@ public class SuperServiceImpl<M extends SuperMapper<T>, T> extends ServiceImpl<M ...@@ -37,11 +37,11 @@ public class SuperServiceImpl<M extends SuperMapper<T>, T> extends ServiceImpl<M
} }
@Override @Override
public ProTableResult<T> selectForProTable(JsonNode para,boolean isDelete) { public ProTableResult<T> selectForProTable(JsonNode para, boolean isDelete) {
Integer current = para.has("current") ? para.get("current").asInt() : 1; Integer current = para.has("current") ? para.get("current").asInt() : 1;
Integer pageSize = para.has("pageSize") ? para.get("pageSize").asInt() : 10; Integer pageSize = para.has("pageSize") ? para.get("pageSize").asInt() : 10;
QueryWrapper<T> queryWrapper = new QueryWrapper<>(); QueryWrapper<T> queryWrapper = new QueryWrapper<>();
ProTableUtil.autoQueryDefalut(para, queryWrapper,isDelete); ProTableUtil.autoQueryDefalut(para, queryWrapper, isDelete);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
Map<String, Object> param = mapper.convertValue(para, Map.class); Map<String, Object> param = mapper.convertValue(para, Map.class);
Page<T> page = new Page<>(current, pageSize); Page<T> page = new Page<>(current, pageSize);
...@@ -50,16 +50,16 @@ public class SuperServiceImpl<M extends SuperMapper<T>, T> extends ServiceImpl<M ...@@ -50,16 +50,16 @@ public class SuperServiceImpl<M extends SuperMapper<T>, T> extends ServiceImpl<M
} }
@Override @Override
public ProTableResult<T> selectForProTable(JsonNode para,Map<String, Object> paraMap) { public ProTableResult<T> selectForProTable(JsonNode para, Map<String, Object> paraMap) {
Integer current = para.has("current") ? para.get("current").asInt() : 1; Integer current = para.has("current") ? para.get("current").asInt() : 1;
Integer pageSize = para.has("pageSize") ? para.get("pageSize").asInt() : 10; Integer pageSize = para.has("pageSize") ? para.get("pageSize").asInt() : 10;
QueryWrapper<T> queryWrapper = new QueryWrapper<>(); QueryWrapper<T> queryWrapper = new QueryWrapper<>();
ProTableUtil.autoQueryDefalut(para, queryWrapper); ProTableUtil.autoQueryDefalut(para, queryWrapper);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
Map<String, Object> param = mapper.convertValue(para, Map.class); Map<String, Object> param = mapper.convertValue(para, Map.class);
if(Asserts.isNotNull(paraMap)){ if (Asserts.isNotNull(paraMap)) {
for (Map.Entry<String, Object> entry : paraMap.entrySet()) { for (Map.Entry<String, Object> entry : paraMap.entrySet()) {
param.put(entry.getKey(),entry.getValue()); param.put(entry.getKey(), entry.getValue());
} }
} }
Page<T> page = new Page<>(current, pageSize); Page<T> page = new Page<>(current, pageSize);
......
...@@ -22,9 +22,9 @@ public class ProTableUtil { ...@@ -22,9 +22,9 @@ public class ProTableUtil {
* @Param [para, wrapper, camelToUnderscore, isDelete] * @Param [para, wrapper, camelToUnderscore, isDelete]
**/ **/
public static void autoQuery(JsonNode para, QueryWrapper<?> wrapper, boolean camelToUnderscore, boolean isDelete) { public static void autoQuery(JsonNode para, QueryWrapper<?> wrapper, boolean camelToUnderscore, boolean isDelete) {
buildDelete(wrapper,camelToUnderscore,isDelete); buildDelete(wrapper, camelToUnderscore, isDelete);
JsonNode sortField = para.get("sorter"); JsonNode sortField = para.get("sorter");
if(sortField!=null) { if (sortField != null) {
Iterator<Map.Entry<String, JsonNode>> fields = sortField.fields(); Iterator<Map.Entry<String, JsonNode>> fields = sortField.fields();
while (fields.hasNext()) { while (fields.hasNext()) {
Map.Entry<String, JsonNode> entry = fields.next(); Map.Entry<String, JsonNode> entry = fields.next();
...@@ -32,7 +32,7 @@ public class ProTableUtil { ...@@ -32,7 +32,7 @@ public class ProTableUtil {
} }
} }
JsonNode filter = para.get("filter"); JsonNode filter = para.get("filter");
if(filter!=null) { if (filter != null) {
Iterator<Map.Entry<String, JsonNode>> fields2 = filter.fields(); Iterator<Map.Entry<String, JsonNode>> fields2 = filter.fields();
while (fields2.hasNext()) { while (fields2.hasNext()) {
Map.Entry<String, JsonNode> entry = fields2.next(); Map.Entry<String, JsonNode> entry = fields2.next();
...@@ -41,7 +41,7 @@ public class ProTableUtil { ...@@ -41,7 +41,7 @@ public class ProTableUtil {
} }
} }
private static void buildDelete( QueryWrapper<?> wrapper, boolean camelToUnderscore, boolean isDelete){ private static void buildDelete(QueryWrapper<?> wrapper, boolean camelToUnderscore, boolean isDelete) {
if (isDelete) { if (isDelete) {
if (camelToUnderscore) { if (camelToUnderscore) {
wrapper.eq(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, "is_delete"), 0); wrapper.eq(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, "is_delete"), 0);
...@@ -51,40 +51,40 @@ public class ProTableUtil { ...@@ -51,40 +51,40 @@ public class ProTableUtil {
} }
} }
private static void buildSort(String sortField,String sortValue,QueryWrapper<?> wrapper, boolean camelToUnderscore){ private static void buildSort(String sortField, String sortValue, QueryWrapper<?> wrapper, boolean camelToUnderscore) {
if (sortField != null && sortValue != null) { if (sortField != null && sortValue != null) {
if (camelToUnderscore) { if (camelToUnderscore) {
sortField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sortField); sortField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sortField);
} }
if (sortValue.equals("descend")) { if (sortValue.equals("descend")) {
if(!sortField.contains(".")) { if (!sortField.contains(".")) {
wrapper.orderByDesc("a." + sortField); wrapper.orderByDesc("a." + sortField);
} }
} else { } else {
if(!sortField.contains(".")) { if (!sortField.contains(".")) {
wrapper.orderByAsc("a." + sortField); wrapper.orderByAsc("a." + sortField);
} }
} }
} }
} }
private static void buildFilter(String searchField,JsonNode searchValue,QueryWrapper<?> wrapper, boolean camelToUnderscore){ private static void buildFilter(String searchField, JsonNode searchValue, QueryWrapper<?> wrapper, boolean camelToUnderscore) {
if (searchField != null && !searchField.equals("") && searchValue != null) { if (searchField != null && !searchField.equals("") && searchValue != null) {
if (camelToUnderscore) { if (camelToUnderscore) {
searchField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, searchField); searchField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, searchField);
} }
final String field = searchField; final String field = searchField;
List<String> searchValues = new ArrayList<>(); List<String> searchValues = new ArrayList<>();
String type ="String"; String type = "String";
if (searchValue.isArray()){ if (searchValue.isArray()) {
for (final JsonNode objNode : searchValue){ for (final JsonNode objNode : searchValue) {
if(objNode.getNodeType()==JsonNodeType.NUMBER){ if (objNode.getNodeType() == JsonNodeType.NUMBER) {
type ="Number"; type = "Number";
} }
searchValues.add(objNode.asText()); searchValues.add(objNode.asText());
} }
} }
if(searchValues.size()>0) { if (searchValues.size() > 0) {
if ("Number".equals(type)) { if ("Number".equals(type)) {
wrapper.and(qw -> { wrapper.and(qw -> {
for (int i = 0; i < searchValues.size(); i++) { for (int i = 0; i < searchValues.size(); i++) {
...@@ -109,6 +109,7 @@ public class ProTableUtil { ...@@ -109,6 +109,7 @@ public class ProTableUtil {
} }
} }
} }
/** /**
* @return void * @return void
* @Author wenmo * @Author wenmo
...@@ -119,15 +120,13 @@ public class ProTableUtil { ...@@ -119,15 +120,13 @@ public class ProTableUtil {
public static void autoSetFromPara(QueryWrapper<?> wrapper, JsonNode para, String[] blackarr, String[] writearr, boolean camelToUnderscore) { public static void autoSetFromPara(QueryWrapper<?> wrapper, JsonNode para, String[] blackarr, String[] writearr, boolean camelToUnderscore) {
List<String> blacklist = Arrays.asList(blackarr); List<String> blacklist = Arrays.asList(blackarr);
List<String> writelist = Arrays.asList(writearr); List<String> writelist = Arrays.asList(writearr);
if (para.isObject()) if (para.isObject()) {
{
Iterator<Map.Entry<String, JsonNode>> it = para.fields(); Iterator<Map.Entry<String, JsonNode>> it = para.fields();
while (it.hasNext()) while (it.hasNext()) {
{
Map.Entry<String, JsonNode> entry = it.next(); Map.Entry<String, JsonNode> entry = it.next();
String mapKey = entry.getKey(); String mapKey = entry.getKey();
if (blacklist.indexOf(mapKey) == -1 || writelist.indexOf(mapKey) > -1) { if (blacklist.indexOf(mapKey) == -1 || writelist.indexOf(mapKey) > -1) {
if(entry.getValue().getNodeType()== JsonNodeType.NUMBER) { if (entry.getValue().getNodeType() == JsonNodeType.NUMBER) {
Double mapValue = entry.getValue().asDouble(); Double mapValue = entry.getValue().asDouble();
if (mapValue != null) { if (mapValue != null) {
if (camelToUnderscore) { if (camelToUnderscore) {
...@@ -136,9 +135,9 @@ public class ProTableUtil { ...@@ -136,9 +135,9 @@ public class ProTableUtil {
wrapper.eq(mapKey, mapValue); wrapper.eq(mapKey, mapValue);
} }
} }
}else{ } else {
String mapValue = entry.getValue().asText(); String mapValue = entry.getValue().asText();
if (mapValue != null&&!"".equals(mapValue)) { if (mapValue != null && !"".equals(mapValue)) {
if (camelToUnderscore) { if (camelToUnderscore) {
wrapper.eq(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, mapKey), mapValue); wrapper.eq(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, mapKey), mapValue);
} else { } else {
...@@ -175,7 +174,7 @@ public class ProTableUtil { ...@@ -175,7 +174,7 @@ public class ProTableUtil {
autoQuery(para, wrapper, true, false); autoQuery(para, wrapper, true, false);
} }
public static void autoQueryDefalut(JsonNode para, QueryWrapper<?> wrapper,boolean isDelete) { public static void autoQueryDefalut(JsonNode para, QueryWrapper<?> wrapper, boolean isDelete) {
autoQuery(para, wrapper, true, isDelete); autoQuery(para, wrapper, true, isDelete);
} }
......
...@@ -3,13 +3,9 @@ package com.dlink.dto; ...@@ -3,13 +3,9 @@ package com.dlink.dto;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.gateway.config.GatewayConfig; import com.dlink.gateway.config.GatewayConfig;
import com.dlink.job.JobConfig; import com.dlink.job.JobConfig;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
......
package com.dlink.dto; package com.dlink.dto;
import com.dlink.assertion.Asserts;
import com.dlink.gateway.GatewayType;
import com.dlink.gateway.config.GatewayConfig;
import com.dlink.job.JobConfig; import com.dlink.job.JobConfig;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.dlink.dto; package com.dlink.dto;
import com.dlink.session.SessionConfig;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -17,5 +16,4 @@ public class SessionDTO { ...@@ -17,5 +16,4 @@ public class SessionDTO {
private String type; private String type;
private boolean useRemote; private boolean useRemote;
private Integer clusterId; private Integer clusterId;
} }
...@@ -22,7 +22,7 @@ public class SqlDTO { ...@@ -22,7 +22,7 @@ public class SqlDTO {
this.maxRowNum = maxRowNum; this.maxRowNum = maxRowNum;
} }
public static SqlDTO build(String statement, Integer databaseId, Integer maxRowNum){ public static SqlDTO build(String statement, Integer databaseId, Integer maxRowNum) {
return new SqlDTO(statement,databaseId,maxRowNum); return new SqlDTO(statement, databaseId, maxRowNum);
} }
} }
...@@ -11,12 +11,7 @@ import lombok.Setter; ...@@ -11,12 +11,7 @@ import lombok.Setter;
**/ **/
@Getter @Getter
@Setter @Setter
public class StudioCADTO extends AbstractStatementDTO{ public class StudioCADTO extends AbstractStatementDTO {
// private String statement; // It's useless for the time being
/* 1:单表表级血缘
* 2:单表字段血缘
* 3.全局表级血缘
* 4.全局字段血缘
* */
private Integer type; private Integer type;
} }
...@@ -23,7 +23,7 @@ public class StudioDDLDTO { ...@@ -23,7 +23,7 @@ public class StudioDDLDTO {
private Integer maxRowNum = 10000; private Integer maxRowNum = 10000;
public JobConfig getJobConfig() { public JobConfig getJobConfig() {
return new JobConfig(type,useResult, useSession, session, useRemote, clusterId,maxRowNum); return new JobConfig(type, useResult, useSession, session, useRemote, clusterId, maxRowNum);
} }
} }
...@@ -40,7 +40,7 @@ public class WebExceptionHandler { ...@@ -40,7 +40,7 @@ public class WebExceptionHandler {
@ExceptionHandler @ExceptionHandler
public Result unknownException(Exception e) { public Result unknownException(Exception e) {
logger.error("ERROR:",e); logger.error("ERROR:", e);
return Result.failed("系统出现错误, 请联系平台管理员!"); return Result.failed("系统出现错误, 请联系平台管理员!");
} }
} }
...@@ -38,11 +38,11 @@ public class SystemInit implements ApplicationRunner { ...@@ -38,11 +38,11 @@ public class SystemInit implements ApplicationRunner {
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
sysConfigService.initSysConfig(); sysConfigService.initSysConfig();
List<JobInstance> jobInstances = jobInstanceService.listJobInstanceActive(); List<JobInstance> jobInstances = jobInstanceService.listJobInstanceActive();
List<DaemonTaskConfig> configList =new ArrayList<>(); List<DaemonTaskConfig> configList = new ArrayList<>();
for(JobInstance jobInstance: jobInstances){ for (JobInstance jobInstance : jobInstances) {
configList.add(new DaemonTaskConfig(FlinkJobTask.TYPE,jobInstance.getId())); configList.add(new DaemonTaskConfig(FlinkJobTask.TYPE, jobInstance.getId()));
} }
log.info("启动的任务数量:"+ configList.size()); log.info("启动的任务数量:" + configList.size());
DaemonFactory.start(configList); DaemonFactory.start(configList);
} }
} }
...@@ -40,7 +40,7 @@ public class FlinkJobTask implements DaemonTask { ...@@ -40,7 +40,7 @@ public class FlinkJobTask implements DaemonTask {
@Override @Override
public void dealTask() { public void dealTask() {
long gap = System.currentTimeMillis() - this.preDealTime; long gap = System.currentTimeMillis() - this.preDealTime;
if(gap < FlinkTaskConstant.TIME_SLEEP){ if (gap < FlinkTaskConstant.TIME_SLEEP) {
try { try {
Thread.sleep(FlinkTaskConstant.TIME_SLEEP); Thread.sleep(FlinkTaskConstant.TIME_SLEEP);
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -49,7 +49,7 @@ public class FlinkJobTask implements DaemonTask { ...@@ -49,7 +49,7 @@ public class FlinkJobTask implements DaemonTask {
} }
preDealTime = System.currentTimeMillis(); preDealTime = System.currentTimeMillis();
JobInstance jobInstance = taskService.refreshJobInstance(config.getId()); JobInstance jobInstance = taskService.refreshJobInstance(config.getId());
if(!JobStatus.isDone(jobInstance.getStatus())){ if (!JobStatus.isDone(jobInstance.getStatus())) {
DefaultThreadPool.getInstance().execute(this); DefaultThreadPool.getInstance().execute(this);
} }
} }
......
...@@ -3,7 +3,6 @@ package com.dlink.mapper; ...@@ -3,7 +3,6 @@ package com.dlink.mapper;
import com.dlink.db.mapper.SuperMapper; import com.dlink.db.mapper.SuperMapper;
import com.dlink.model.Catalogue; import com.dlink.model.Catalogue;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* CatalogueMapper * CatalogueMapper
......
package com.dlink.mapper; package com.dlink.mapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.dlink.db.mapper.SuperMapper; import com.dlink.db.mapper.SuperMapper;
import com.dlink.model.Statement; import com.dlink.model.Statement;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* StatementMapper * StatementMapper
......
...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* 作业 Mapper 接口 * 作业 Mapper 接口
*
* @author wenmo * @author wenmo
* @since 2021-05-28 * @since 2021-05-28
*/ */
......
package com.dlink.model; package com.dlink.model;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
......
...@@ -41,7 +41,7 @@ public class Cluster extends SuperEntity { ...@@ -41,7 +41,7 @@ public class Cluster extends SuperEntity {
private Integer taskId; private Integer taskId;
public static Cluster autoRegistersCluster(String hosts,String name,String alias,String type,Integer clusterConfigurationId,Integer taskId){ public static Cluster autoRegistersCluster(String hosts, String name, String alias, String type, Integer clusterConfigurationId, Integer taskId) {
Cluster cluster = new Cluster(); Cluster cluster = new Cluster();
cluster.setName(name); cluster.setName(name);
cluster.setAlias(alias); cluster.setAlias(alias);
......
...@@ -38,13 +38,13 @@ public class ClusterConfiguration extends SuperEntity { ...@@ -38,13 +38,13 @@ public class ClusterConfiguration extends SuperEntity {
private String note; private String note;
@TableField(exist = false) @TableField(exist = false)
private Map<String,Object> config = new HashMap<>(); private Map<String, Object> config = new HashMap<>();
public Map<String,Object> parseConfig(){ public Map<String, Object> parseConfig() {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
try { try {
if(Asserts.isNotNullString(configJson)) { if (Asserts.isNotNullString(configJson)) {
config = objectMapper.readValue(configJson, HashMap.class); config = objectMapper.readValue(configJson, HashMap.class);
} }
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
......
...@@ -12,7 +12,8 @@ public enum CodeEnum { ...@@ -12,7 +12,8 @@ public enum CodeEnum {
NOTLOGIN(401); NOTLOGIN(401);
private Integer code; private Integer code;
CodeEnum(Integer code){
CodeEnum(Integer code) {
this.code = code; this.code = code;
} }
......
...@@ -7,8 +7,6 @@ import com.dlink.db.model.SuperEntity; ...@@ -7,8 +7,6 @@ import com.dlink.db.model.SuperEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable;
/** /**
* Jar * Jar
* *
......
package com.dlink.model; package com.dlink.model;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
......
package com.dlink.model; package com.dlink.model;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dlink.db.annotation.Save; import com.dlink.db.annotation.Save;
import com.dlink.db.model.SuperEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
......
package com.dlink.model; package com.dlink.model;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.dlink.assertion.Asserts;
import com.dlink.db.annotation.Save; import com.dlink.db.annotation.Save;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -19,7 +18,7 @@ import java.time.LocalDateTime; ...@@ -19,7 +18,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@TableName("dlink_user") @TableName("dlink_user")
public class User implements Serializable{ public class User implements Serializable {
private static final long serialVersionUID = -1077801296270024204L; private static final long serialVersionUID = -1077801296270024204L;
......
...@@ -34,8 +34,8 @@ public class APIJobResult { ...@@ -34,8 +34,8 @@ public class APIJobResult {
this.endTime = endTime; this.endTime = endTime;
} }
public static APIJobResult build(JobResult jobResult){ public static APIJobResult build(JobResult jobResult) {
return new APIJobResult(jobResult.getJobManagerAddress(),jobResult.getStatus(),jobResult.isSuccess(), return new APIJobResult(jobResult.getJobManagerAddress(), jobResult.getStatus(), jobResult.isSuccess(),
jobResult.getJobId(),jobResult.getError(),jobResult.getStartTime(),jobResult.getEndTime()); jobResult.getJobId(), jobResult.getError(), jobResult.getStartTime(), jobResult.getEndTime());
} }
} }
...@@ -3,7 +3,6 @@ package com.dlink.service; ...@@ -3,7 +3,6 @@ package com.dlink.service;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.dto.CatalogueTaskDTO; import com.dlink.dto.CatalogueTaskDTO;
import com.dlink.model.Catalogue; import com.dlink.model.Catalogue;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
......
...@@ -19,7 +19,7 @@ public interface ClusterConfigurationService extends ISuperService<ClusterConfig ...@@ -19,7 +19,7 @@ public interface ClusterConfigurationService extends ISuperService<ClusterConfig
List<ClusterConfiguration> listEnabledAll(); List<ClusterConfiguration> listEnabledAll();
Map<String,Object> getGatewayConfig(Integer id); Map<String, Object> getGatewayConfig(Integer id);
TestResult testGateway(ClusterConfiguration clusterConfiguration); TestResult testGateway(ClusterConfiguration clusterConfiguration);
} }
...@@ -18,7 +18,7 @@ public interface ClusterService extends ISuperService<Cluster> { ...@@ -18,7 +18,7 @@ public interface ClusterService extends ISuperService<Cluster> {
String getJobManagerAddress(Cluster cluster); String getJobManagerAddress(Cluster cluster);
String buildEnvironmentAddress(boolean useRemote,Integer id); String buildEnvironmentAddress(boolean useRemote, Integer id);
String buildRemoteEnvironmentAddress(Integer id); String buildRemoteEnvironmentAddress(Integer id);
......
...@@ -12,5 +12,6 @@ import java.util.List; ...@@ -12,5 +12,6 @@ import java.util.List;
* @since 2021/6/3 14:35 * @since 2021/6/3 14:35
**/ **/
public interface DocumentService extends ISuperService<Document> { public interface DocumentService extends ISuperService<Document> {
List<Document> getFillAllByVersion(String version); List<Document> getFillAllByVersion(String version);
} }
...@@ -10,5 +10,6 @@ import com.dlink.model.History; ...@@ -10,5 +10,6 @@ import com.dlink.model.History;
* @since 2021/6/26 23:07 * @since 2021/6/26 23:07
*/ */
public interface HistoryService extends ISuperService<History> { public interface HistoryService extends ISuperService<History> {
public boolean removeHistoryById(Integer id);
boolean removeHistoryById(Integer id);
} }
...@@ -15,5 +15,5 @@ public interface JobHistoryService extends ISuperService<JobHistory> { ...@@ -15,5 +15,5 @@ public interface JobHistoryService extends ISuperService<JobHistory> {
JobHistory getJobHistoryInfo(JobHistory jobHistory); JobHistory getJobHistoryInfo(JobHistory jobHistory);
JobHistory refreshJobHistory(Integer id,String jobManagerHost,String jobId); JobHistory refreshJobHistory(Integer id, String jobManagerHost, String jobId);
} }
package com.dlink.service; package com.dlink.service;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.explainer.lineage.LineageResult; import com.dlink.explainer.lineage.LineageResult;
import com.dlink.model.JobInfoDetail; import com.dlink.model.JobInfoDetail;
import com.dlink.model.JobInstance; import com.dlink.model.JobInstance;
......
...@@ -2,10 +2,8 @@ package com.dlink.service; ...@@ -2,10 +2,8 @@ package com.dlink.service;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.model.Savepoints; import com.dlink.model.Savepoints;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Savepoints * Savepoints
...@@ -14,6 +12,7 @@ import java.util.Map; ...@@ -14,6 +12,7 @@ import java.util.Map;
* @since 2021/11/21 * @since 2021/11/21
**/ **/
public interface SavepointsService extends ISuperService<Savepoints> { public interface SavepointsService extends ISuperService<Savepoints> {
List<Savepoints> listSavepointsByTaskId(Integer taskId); List<Savepoints> listSavepointsByTaskId(Integer taskId);
Savepoints getLatestSavepointByTaskId(Integer taskId); Savepoints getLatestSavepointByTaskId(Integer taskId);
......
...@@ -10,5 +10,6 @@ import com.dlink.model.Statement; ...@@ -10,5 +10,6 @@ import com.dlink.model.Statement;
* @since 2021/5/28 13:45 * @since 2021/5/28 13:45
**/ **/
public interface StatementService extends ISuperService<Statement> { public interface StatementService extends ISuperService<Statement> {
boolean insert(Statement statement); boolean insert(Statement statement);
} }
package com.dlink.service; package com.dlink.service;
import com.dlink.dto.*; import com.dlink.dto.*;
import com.dlink.explainer.ca.ColumnCANode;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.explainer.lineage.LineageResult; import com.dlink.explainer.lineage.LineageResult;
import com.dlink.job.JobResult; import com.dlink.job.JobResult;
import com.dlink.result.IResult; import com.dlink.result.IResult;
...@@ -46,7 +44,7 @@ public interface StudioService { ...@@ -46,7 +44,7 @@ public interface StudioService {
List<JsonNode> listJobs(Integer clusterId); List<JsonNode> listJobs(Integer clusterId);
boolean cancel(Integer clusterId,String jobId); boolean cancel(Integer clusterId, String jobId);
boolean savepoint(Integer taskId,Integer clusterId,String jobId,String savePointType,String name); boolean savepoint(Integer taskId, Integer clusterId, String jobId, String savePointType, String name);
} }
...@@ -14,7 +14,7 @@ import java.util.Map; ...@@ -14,7 +14,7 @@ import java.util.Map;
**/ **/
public interface SysConfigService extends ISuperService<SysConfig> { public interface SysConfigService extends ISuperService<SysConfig> {
Map<String,Object> getAll(); Map<String, Object> getAll();
void initSysConfig(); void initSysConfig();
......
...@@ -3,7 +3,6 @@ package com.dlink.service; ...@@ -3,7 +3,6 @@ package com.dlink.service;
import com.dlink.common.result.Result; import com.dlink.common.result.Result;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.dto.StudioExecuteDTO;
import com.dlink.job.JobResult; import com.dlink.job.JobResult;
import com.dlink.model.JobInfoDetail; import com.dlink.model.JobInfoDetail;
import com.dlink.model.JobInstance; import com.dlink.model.JobInstance;
...@@ -50,7 +49,7 @@ public interface TaskService extends ISuperService<Task> { ...@@ -50,7 +49,7 @@ public interface TaskService extends ISuperService<Task> {
boolean recoveryTask(Integer id); boolean recoveryTask(Integer id);
boolean savepointTask(Integer taskId,String savePointType); boolean savepointTask(Integer taskId, String savePointType);
JobInstance refreshJobInstance(Integer id); JobInstance refreshJobInstance(Integer id);
......
...@@ -16,11 +16,11 @@ public interface UserService extends ISuperService<User> { ...@@ -16,11 +16,11 @@ public interface UserService extends ISuperService<User> {
boolean modifyUser(User user); boolean modifyUser(User user);
Result modifyPassword(String username, String password,String newPassword); Result modifyPassword(String username, String password, String newPassword);
boolean removeUser(Integer id); boolean removeUser(Integer id);
Result loginUser(String username, String password,boolean isRemember); Result loginUser(String username, String password, boolean isRemember);
User getUserByUsername(String username); User getUserByUsername(String username);
} }
package com.dlink.service.impl; package com.dlink.service.impl;
import com.dlink.assertion.Asserts;
import com.dlink.dto.*; import com.dlink.dto.*;
import com.dlink.gateway.GatewayType;
import com.dlink.gateway.result.SavePointResult; import com.dlink.gateway.result.SavePointResult;
import com.dlink.job.JobConfig; import com.dlink.job.JobConfig;
import com.dlink.job.JobManager; import com.dlink.job.JobManager;
...@@ -16,8 +14,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -16,8 +14,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
/** /**
* APIServiceImpl * APIServiceImpl
* *
...@@ -52,12 +48,12 @@ public class APIServiceImpl implements APIService { ...@@ -52,12 +48,12 @@ public class APIServiceImpl implements APIService {
JobManager jobManager = JobManager.buildPlanMode(config); JobManager jobManager = JobManager.buildPlanMode(config);
String planJson = jobManager.getJobPlanJson(apiExplainSqlDTO.getStatement()); String planJson = jobManager.getJobPlanJson(apiExplainSqlDTO.getStatement());
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
ObjectNode objectNode =mapper.createObjectNode(); ObjectNode objectNode = mapper.createObjectNode();
try { try {
objectNode = (ObjectNode) mapper.readTree(planJson); objectNode = (ObjectNode) mapper.readTree(planJson);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
RunTimeUtil.recovery(jobManager); RunTimeUtil.recovery(jobManager);
return objectNode; return objectNode;
} }
......
...@@ -28,19 +28,19 @@ public class AlertGroupServiceImpl extends SuperServiceImpl<AlertGroupMapper, Al ...@@ -28,19 +28,19 @@ public class AlertGroupServiceImpl extends SuperServiceImpl<AlertGroupMapper, Al
@Override @Override
public List<AlertGroup> listEnabledAll() { public List<AlertGroup> listEnabledAll() {
return list(new QueryWrapper<AlertGroup>().eq("enabled",1)); return list(new QueryWrapper<AlertGroup>().eq("enabled", 1));
} }
@Override @Override
public AlertGroup getAlertGroupInfo(Integer id) { public AlertGroup getAlertGroupInfo(Integer id) {
AlertGroup alertGroup = getById(id); AlertGroup alertGroup = getById(id);
if(Asserts.isNull(alertGroup)||Asserts.isNullString(alertGroup.getAlertInstanceIds())){ if (Asserts.isNull(alertGroup) || Asserts.isNullString(alertGroup.getAlertInstanceIds())) {
return alertGroup; return alertGroup;
} }
String[] alertInstanceIds = alertGroup.getAlertInstanceIds().split(","); String[] alertInstanceIds = alertGroup.getAlertInstanceIds().split(",");
List<AlertInstance> alertInstanceList = new ArrayList<>(); List<AlertInstance> alertInstanceList = new ArrayList<>();
for(String alertInstanceId: alertInstanceIds){ for (String alertInstanceId : alertInstanceIds) {
if(Asserts.isNullString(alertInstanceId)||alertInstanceId.equals("0")){ if (Asserts.isNullString(alertInstanceId) || alertInstanceId.equals("0")) {
continue; continue;
} }
alertInstanceList.add(alertInstanceService.getById(Integer.valueOf(alertInstanceId))); alertInstanceList.add(alertInstanceService.getById(Integer.valueOf(alertInstanceId)));
......
...@@ -19,6 +19,6 @@ import java.util.List; ...@@ -19,6 +19,6 @@ import java.util.List;
public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapper, AlertInstance> implements AlertInstanceService { public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapper, AlertInstance> implements AlertInstanceService {
@Override @Override
public List<AlertInstance> listEnabledAll() { public List<AlertInstance> listEnabledAll() {
return list(new QueryWrapper<AlertInstance>().eq("enabled",1)); return list(new QueryWrapper<AlertInstance>().eq("enabled", 1));
} }
} }
...@@ -39,10 +39,10 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -39,10 +39,10 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
@Override @Override
public Catalogue findByParentIdAndName(Integer parent_id, String name) { public Catalogue findByParentIdAndName(Integer parent_id, String name) {
return catalogueMapper.selectOne(Wrappers.<Catalogue>query().eq("parent_id",parent_id).eq("name",name)); return catalogueMapper.selectOne(Wrappers.<Catalogue>query().eq("parent_id", parent_id).eq("name", name));
} }
@Transactional(rollbackFor=Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Catalogue createCatalogueAndTask(CatalogueTaskDTO catalogueTaskDTO) { public Catalogue createCatalogueAndTask(CatalogueTaskDTO catalogueTaskDTO) {
Task task = new Task(); Task task = new Task();
...@@ -79,13 +79,13 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -79,13 +79,13 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
return catalogue; return catalogue;
} }
@Transactional(rollbackFor=Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean toRename(Catalogue catalogue) { public boolean toRename(Catalogue catalogue) {
Catalogue oldCatalogue = this.getById(catalogue.getId()); Catalogue oldCatalogue = this.getById(catalogue.getId());
if(oldCatalogue==null){ if (oldCatalogue == null) {
return false; return false;
}else{ } else {
Task task = new Task(); Task task = new Task();
task.setId(oldCatalogue.getTaskId()); task.setId(oldCatalogue.getTaskId());
task.setName(catalogue.getName()); task.setName(catalogue.getName());
...@@ -99,10 +99,10 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -99,10 +99,10 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
@Override @Override
public boolean removeCatalogueAndTaskById(Integer id) { public boolean removeCatalogueAndTaskById(Integer id) {
Catalogue catalogue = this.getById(id); Catalogue catalogue = this.getById(id);
if(catalogue==null){ if (catalogue == null) {
return false; return false;
}else{ } else {
if(catalogue.getTaskId()!=null) { if (catalogue.getTaskId() != null) {
taskService.removeById(catalogue.getTaskId()); taskService.removeById(catalogue.getTaskId());
statementService.removeById(catalogue.getTaskId()); statementService.removeById(catalogue.getTaskId());
} }
......
package com.dlink.service.impl; package com.dlink.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.assertion.Assert;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.db.service.impl.SuperServiceImpl; import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.gateway.GatewayType; import com.dlink.gateway.GatewayType;
import com.dlink.gateway.config.AppConfig;
import com.dlink.gateway.config.ClusterConfig; import com.dlink.gateway.config.ClusterConfig;
import com.dlink.gateway.config.FlinkConfig; import com.dlink.gateway.config.FlinkConfig;
import com.dlink.gateway.config.GatewayConfig; import com.dlink.gateway.config.GatewayConfig;
...@@ -13,8 +11,6 @@ import com.dlink.gateway.result.TestResult; ...@@ -13,8 +11,6 @@ import com.dlink.gateway.result.TestResult;
import com.dlink.job.JobManager; import com.dlink.job.JobManager;
import com.dlink.mapper.ClusterConfigurationMapper; import com.dlink.mapper.ClusterConfigurationMapper;
import com.dlink.model.ClusterConfiguration; import com.dlink.model.ClusterConfiguration;
import com.dlink.model.Jar;
import com.dlink.model.SystemConfiguration;
import com.dlink.service.ClusterConfigurationService; import com.dlink.service.ClusterConfigurationService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,7 +24,7 @@ import java.util.Map; ...@@ -28,7 +24,7 @@ import java.util.Map;
* @since 2021/11/6 20:54 * @since 2021/11/6 20:54
*/ */
@Service @Service
public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterConfigurationMapper,ClusterConfiguration> implements ClusterConfigurationService { public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterConfigurationMapper, ClusterConfiguration> implements ClusterConfigurationService {
@Override @Override
public ClusterConfiguration getClusterConfigById(Integer id) { public ClusterConfiguration getClusterConfigById(Integer id) {
ClusterConfiguration clusterConfiguration = baseMapper.selectById(id); ClusterConfiguration clusterConfiguration = baseMapper.selectById(id);
...@@ -38,7 +34,7 @@ public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterCon ...@@ -38,7 +34,7 @@ public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterCon
@Override @Override
public List<ClusterConfiguration> listEnabledAll() { public List<ClusterConfiguration> listEnabledAll() {
return this.list(new QueryWrapper<ClusterConfiguration>().eq("enabled",1)); return this.list(new QueryWrapper<ClusterConfiguration>().eq("enabled", 1));
} }
@Override @Override
...@@ -52,30 +48,30 @@ public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterCon ...@@ -52,30 +48,30 @@ public class ClusterConfigurationServiceImpl extends SuperServiceImpl<ClusterCon
clusterConfiguration.parseConfig(); clusterConfiguration.parseConfig();
Map<String, Object> config = clusterConfiguration.getConfig(); Map<String, Object> config = clusterConfiguration.getConfig();
GatewayConfig gatewayConfig = new GatewayConfig(); GatewayConfig gatewayConfig = new GatewayConfig();
if(config.containsKey("hadoopConfigPath")) { if (config.containsKey("hadoopConfigPath")) {
gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(), gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(),
config.get("flinkLibPath").toString(), config.get("flinkLibPath").toString(),
config.get("hadoopConfigPath").toString())); config.get("hadoopConfigPath").toString()));
}else { } else {
gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(), gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(),
config.get("flinkLibPath").toString(), config.get("flinkLibPath").toString(),
"")); ""));
} }
if(config.containsKey("flinkConfig")){ if (config.containsKey("flinkConfig")) {
gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>)config.get("flinkConfig"))); gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>) config.get("flinkConfig")));
} }
if(Asserts.isEqualsIgnoreCase(clusterConfiguration.getType(),"Yarn")){ if (Asserts.isEqualsIgnoreCase(clusterConfiguration.getType(), "Yarn")) {
gatewayConfig.setType(GatewayType.YARN_PER_JOB); gatewayConfig.setType(GatewayType.YARN_PER_JOB);
}else if(Asserts.isEqualsIgnoreCase(clusterConfiguration.getType(),"Kubernetes")){ } else if (Asserts.isEqualsIgnoreCase(clusterConfiguration.getType(), "Kubernetes")) {
gatewayConfig.setType(GatewayType.KUBERNETES_APPLICATION); gatewayConfig.setType(GatewayType.KUBERNETES_APPLICATION);
Map kubernetesConfig = (Map) config.get("kubernetesConfig"); Map kubernetesConfig = (Map) config.get("kubernetesConfig");
if(kubernetesConfig.containsKey("kubernetes.namespace")) { if (kubernetesConfig.containsKey("kubernetes.namespace")) {
gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.namespace", kubernetesConfig.get("kubernetes.namespace").toString()); gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.namespace", kubernetesConfig.get("kubernetes.namespace").toString());
} }
if(kubernetesConfig.containsKey("kubernetes.cluster-id")) { if (kubernetesConfig.containsKey("kubernetes.cluster-id")) {
gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.cluster-id", kubernetesConfig.get("kubernetes.cluster-id").toString()); gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.cluster-id", kubernetesConfig.get("kubernetes.cluster-id").toString());
} }
if(kubernetesConfig.containsKey("kubernetes.container.image")) { if (kubernetesConfig.containsKey("kubernetes.container.image")) {
gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.container.image", kubernetesConfig.get("kubernetes.container.image").toString()); gatewayConfig.getFlinkConfig().getConfiguration().put("kubernetes.container.image", kubernetesConfig.get("kubernetes.container.image").toString());
} }
} }
......
...@@ -27,7 +27,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -27,7 +27,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
@Override @Override
public FlinkClusterInfo checkHeartBeat(String hosts, String host) { public FlinkClusterInfo checkHeartBeat(String hosts, String host) {
return FlinkCluster.testFlinkJobManagerIP(hosts,host); return FlinkCluster.testFlinkJobManagerIP(hosts, host);
} }
@Override @Override
...@@ -35,11 +35,11 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -35,11 +35,11 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
Assert.check(cluster); Assert.check(cluster);
FlinkClusterInfo info = FlinkCluster.testFlinkJobManagerIP(cluster.getHosts(), cluster.getJobManagerHost()); FlinkClusterInfo info = FlinkCluster.testFlinkJobManagerIP(cluster.getHosts(), cluster.getJobManagerHost());
String host = null; String host = null;
if(info.isEffective()){ if (info.isEffective()) {
host = info.getJobManagerAddress(); host = info.getJobManagerAddress();
} }
Assert.checkHost(host); Assert.checkHost(host);
if(!host.equals(cluster.getJobManagerHost())){ if (!host.equals(cluster.getJobManagerHost())) {
cluster.setJobManagerHost(host); cluster.setJobManagerHost(host);
updateById(cluster); updateById(cluster);
} }
...@@ -48,9 +48,9 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -48,9 +48,9 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
@Override @Override
public String buildEnvironmentAddress(boolean useRemote, Integer id) { public String buildEnvironmentAddress(boolean useRemote, Integer id) {
if(useRemote&&id!=0) { if (useRemote && id != 0) {
return buildRemoteEnvironmentAddress(id); return buildRemoteEnvironmentAddress(id);
}else{ } else {
return buildLocalEnvironmentAddress(); return buildLocalEnvironmentAddress();
} }
} }
...@@ -64,8 +64,8 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -64,8 +64,8 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
public String buildLocalEnvironmentAddress() { public String buildLocalEnvironmentAddress() {
try { try {
InetAddress inetAddress = InetAddress.getLocalHost(); InetAddress inetAddress = InetAddress.getLocalHost();
if(inetAddress!=null) { if (inetAddress != null) {
return inetAddress.getHostAddress()+ NetConstant.COLON+FlinkConstant.FLINK_REST_DEFAULT_PORT; return inetAddress.getHostAddress() + NetConstant.COLON + FlinkConstant.FLINK_REST_DEFAULT_PORT;
} }
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -75,7 +75,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -75,7 +75,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
@Override @Override
public List<Cluster> listEnabledAll() { public List<Cluster> listEnabledAll() {
return this.list(new QueryWrapper<Cluster>().eq("enabled",1)); return this.list(new QueryWrapper<Cluster>().eq("enabled", 1));
} }
@Override @Override
...@@ -85,7 +85,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -85,7 +85,7 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
@Override @Override
public List<Cluster> listAutoEnable() { public List<Cluster> listAutoEnable() {
return list(new QueryWrapper<Cluster>().eq("enabled",1).eq("auto_registers",1)); return list(new QueryWrapper<Cluster>().eq("enabled", 1).eq("auto_registers", 1));
} }
@Override @Override
...@@ -107,21 +107,21 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster> ...@@ -107,21 +107,21 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
public int clearCluster() { public int clearCluster() {
List<Cluster> clusters = listAutoEnable(); List<Cluster> clusters = listAutoEnable();
int count = 0; int count = 0;
for(Cluster item : clusters){ for (Cluster item : clusters) {
if((!checkHealth(item))&&removeById(item)){ if ((!checkHealth(item)) && removeById(item)) {
count ++; count++;
} }
} }
return count; return count;
} }
private boolean checkHealth(Cluster cluster){ private boolean checkHealth(Cluster cluster) {
FlinkClusterInfo info = checkHeartBeat(cluster.getHosts(), cluster.getJobManagerHost()); FlinkClusterInfo info = checkHeartBeat(cluster.getHosts(), cluster.getJobManagerHost());
if(!info.isEffective()){ if (!info.isEffective()) {
cluster.setJobManagerHost(""); cluster.setJobManagerHost("");
cluster.setStatus(0); cluster.setStatus(0);
return false; return false;
}else{ } else {
cluster.setJobManagerHost(info.getJobManagerAddress()); cluster.setJobManagerHost(info.getJobManagerAddress());
cluster.setStatus(1); cluster.setStatus(1);
cluster.setVersion(info.getVersion()); cluster.setVersion(info.getVersion());
......
...@@ -21,9 +21,9 @@ public class DocumentServiceImpl extends SuperServiceImpl<DocumentMapper, Docume ...@@ -21,9 +21,9 @@ public class DocumentServiceImpl extends SuperServiceImpl<DocumentMapper, Docume
@Override @Override
public List<Document> getFillAllByVersion(String version) { public List<Document> getFillAllByVersion(String version) {
if(Asserts.isNotNullString(version)) { if (Asserts.isNotNullString(version)) {
return baseMapper.selectList(new QueryWrapper<Document>().eq("version", version).eq("enabled", 1)); return baseMapper.selectList(new QueryWrapper<Document>().eq("version", version).eq("enabled", 1));
}else{ } else {
return baseMapper.selectList(new QueryWrapper<Document>().eq("enabled", 1)); return baseMapper.selectList(new QueryWrapper<Document>().eq("enabled", 1));
} }
} }
......
...@@ -18,7 +18,7 @@ public class HistoryServiceImpl extends SuperServiceImpl<HistoryMapper, History> ...@@ -18,7 +18,7 @@ public class HistoryServiceImpl extends SuperServiceImpl<HistoryMapper, History>
@Override @Override
public boolean removeHistoryById(Integer id) { public boolean removeHistoryById(Integer id) {
History history = getById(id); History history = getById(id);
if(history!=null){ if (history != null) {
ResultPool.remove(history.getJobId()); ResultPool.remove(history.getJobId());
} }
return removeById(id); return removeById(id);
......
...@@ -19,6 +19,6 @@ import java.util.List; ...@@ -19,6 +19,6 @@ import java.util.List;
public class JarServiceImpl extends SuperServiceImpl<JarMapper, Jar> implements JarService { public class JarServiceImpl extends SuperServiceImpl<JarMapper, Jar> implements JarService {
@Override @Override
public List<Jar> listEnabledAll() { public List<Jar> listEnabledAll() {
return list(new QueryWrapper<Jar>().eq("enabled",1)); return list(new QueryWrapper<Jar>().eq("enabled", 1));
} }
} }
...@@ -26,36 +26,36 @@ public class JobHistoryServiceImpl extends SuperServiceImpl<JobHistoryMapper, Jo ...@@ -26,36 +26,36 @@ public class JobHistoryServiceImpl extends SuperServiceImpl<JobHistoryMapper, Jo
@Override @Override
public JobHistory getJobHistoryInfo(JobHistory jobHistory) { public JobHistory getJobHistoryInfo(JobHistory jobHistory) {
if(Asserts.isNotNull(jobHistory)){ if (Asserts.isNotNull(jobHistory)) {
if(Asserts.isNotNullString(jobHistory.getJobJson())){ if (Asserts.isNotNullString(jobHistory.getJobJson())) {
jobHistory.setJob(JSONUtil.parseObject(jobHistory.getJobJson())); jobHistory.setJob(JSONUtil.parseObject(jobHistory.getJobJson()));
jobHistory.setJobJson(null); jobHistory.setJobJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getExceptionsJson())){ if (Asserts.isNotNullString(jobHistory.getExceptionsJson())) {
jobHistory.setExceptions(JSONUtil.parseObject(jobHistory.getExceptionsJson())); jobHistory.setExceptions(JSONUtil.parseObject(jobHistory.getExceptionsJson()));
jobHistory.setExceptionsJson(null); jobHistory.setExceptionsJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getCheckpointsJson())){ if (Asserts.isNotNullString(jobHistory.getCheckpointsJson())) {
jobHistory.setCheckpoints(JSONUtil.parseObject(jobHistory.getCheckpointsJson())); jobHistory.setCheckpoints(JSONUtil.parseObject(jobHistory.getCheckpointsJson()));
jobHistory.setCheckpointsJson(null); jobHistory.setCheckpointsJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getCheckpointsConfigJson())){ if (Asserts.isNotNullString(jobHistory.getCheckpointsConfigJson())) {
jobHistory.setCheckpointsConfig(JSONUtil.parseObject(jobHistory.getCheckpointsConfigJson())); jobHistory.setCheckpointsConfig(JSONUtil.parseObject(jobHistory.getCheckpointsConfigJson()));
jobHistory.setCheckpointsConfigJson(null); jobHistory.setCheckpointsConfigJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getConfigJson())){ if (Asserts.isNotNullString(jobHistory.getConfigJson())) {
jobHistory.setConfig(JSONUtil.parseObject(jobHistory.getConfigJson())); jobHistory.setConfig(JSONUtil.parseObject(jobHistory.getConfigJson()));
jobHistory.setConfigJson(null); jobHistory.setConfigJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getJarJson())){ if (Asserts.isNotNullString(jobHistory.getJarJson())) {
jobHistory.setJar(JSONUtil.parseObject(jobHistory.getJarJson())); jobHistory.setJar(JSONUtil.parseObject(jobHistory.getJarJson()));
jobHistory.setJarJson(null); jobHistory.setJarJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getClusterJson())){ if (Asserts.isNotNullString(jobHistory.getClusterJson())) {
jobHistory.setCluster(JSONUtil.parseObject(jobHistory.getClusterJson())); jobHistory.setCluster(JSONUtil.parseObject(jobHistory.getClusterJson()));
jobHistory.setClusterJson(null); jobHistory.setClusterJson(null);
} }
if(Asserts.isNotNullString(jobHistory.getClusterConfigurationJson())){ if (Asserts.isNotNullString(jobHistory.getClusterConfigurationJson())) {
jobHistory.setClusterConfiguration(JSONUtil.parseObject(jobHistory.getClusterConfigurationJson())); jobHistory.setClusterConfiguration(JSONUtil.parseObject(jobHistory.getClusterConfigurationJson()));
jobHistory.setClusterConfigurationJson(null); jobHistory.setClusterConfigurationJson(null);
} }
...@@ -83,8 +83,8 @@ public class JobHistoryServiceImpl extends SuperServiceImpl<JobHistoryMapper, Jo ...@@ -83,8 +83,8 @@ public class JobHistoryServiceImpl extends SuperServiceImpl<JobHistoryMapper, Jo
} else { } else {
save(jobHistory); save(jobHistory);
} }
}catch (Exception e){ } catch (Exception e) {
}finally { } finally {
return jobHistory; return jobHistory;
} }
} }
......
package com.dlink.service.impl; package com.dlink.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.constant.FlinkRestResultConstant;
import com.dlink.db.service.impl.SuperServiceImpl; import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.explainer.ca.CABuilder;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.explainer.lineage.LineageBuilder; import com.dlink.explainer.lineage.LineageBuilder;
import com.dlink.explainer.lineage.LineageResult; import com.dlink.explainer.lineage.LineageResult;
import com.dlink.mapper.JobInstanceMapper; import com.dlink.mapper.JobInstanceMapper;
import com.dlink.model.Cluster; import com.dlink.model.*;
import com.dlink.model.History; import com.dlink.service.*;
import com.dlink.model.JobHistory;
import com.dlink.model.JobInfoDetail;
import com.dlink.model.JobInstance;
import com.dlink.model.JobInstanceCount;
import com.dlink.model.JobInstanceStatus;
import com.dlink.model.JobStatus;
import com.dlink.service.ClusterConfigurationService;
import com.dlink.service.ClusterService;
import com.dlink.service.HistoryService;
import com.dlink.service.JobHistoryService;
import com.dlink.service.JobInstanceService;
import com.dlink.service.TaskService;
import com.dlink.utils.JSONUtil; import com.dlink.utils.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -50,9 +34,9 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper, ...@@ -50,9 +34,9 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper,
@Override @Override
public JobInstanceStatus getStatusCount(boolean isHistory) { public JobInstanceStatus getStatusCount(boolean isHistory) {
List<JobInstanceCount> jobInstanceCounts = null; List<JobInstanceCount> jobInstanceCounts = null;
if(isHistory){ if (isHistory) {
jobInstanceCounts = baseMapper.countHistoryStatus(); jobInstanceCounts = baseMapper.countHistoryStatus();
}else{ } else {
jobInstanceCounts = baseMapper.countStatus(); jobInstanceCounts = baseMapper.countStatus();
} }
JobInstanceStatus jobInstanceStatus = new JobInstanceStatus(); JobInstanceStatus jobInstanceStatus = new JobInstanceStatus();
......
...@@ -20,7 +20,7 @@ public class SavepointsServiceImpl extends SuperServiceImpl<SavepointsMapper, Sa ...@@ -20,7 +20,7 @@ public class SavepointsServiceImpl extends SuperServiceImpl<SavepointsMapper, Sa
@Override @Override
public List<Savepoints> listSavepointsByTaskId(Integer taskId) { public List<Savepoints> listSavepointsByTaskId(Integer taskId) {
return list(new QueryWrapper<Savepoints>().eq("task_id",taskId)); return list(new QueryWrapper<Savepoints>().eq("task_id", taskId));
} }
@Override @Override
......
...@@ -16,9 +16,9 @@ import org.springframework.stereotype.Service; ...@@ -16,9 +16,9 @@ import org.springframework.stereotype.Service;
public class StatementServiceImpl extends SuperServiceImpl<StatementMapper, Statement> implements StatementService { public class StatementServiceImpl extends SuperServiceImpl<StatementMapper, Statement> implements StatementService {
@Override @Override
public boolean insert(Statement statement) { public boolean insert(Statement statement) {
if(baseMapper.insert(statement)>0){ if (baseMapper.insert(statement) > 0) {
return true; return true;
}else{ } else {
return false; return false;
} }
} }
......
package com.dlink.service.impl; package com.dlink.service.impl;
import com.dlink.api.FlinkAPI; import com.dlink.api.FlinkAPI;
import com.dlink.assertion.Assert;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.config.Dialect; import com.dlink.config.Dialect;
import com.dlink.dto.*; import com.dlink.dto.*;
import com.dlink.explainer.ca.CABuilder;
import com.dlink.explainer.ca.ColumnCANode;
import com.dlink.explainer.ca.TableCANode;
import com.dlink.explainer.lineage.LineageBuilder; import com.dlink.explainer.lineage.LineageBuilder;
import com.dlink.explainer.lineage.LineageResult; import com.dlink.explainer.lineage.LineageResult;
import com.dlink.gateway.GatewayType; import com.dlink.gateway.GatewayType;
...@@ -18,7 +14,10 @@ import com.dlink.job.JobManager; ...@@ -18,7 +14,10 @@ import com.dlink.job.JobManager;
import com.dlink.job.JobResult; import com.dlink.job.JobResult;
import com.dlink.metadata.driver.Driver; import com.dlink.metadata.driver.Driver;
import com.dlink.metadata.result.JdbcSelectResult; import com.dlink.metadata.result.JdbcSelectResult;
import com.dlink.model.*; import com.dlink.model.Cluster;
import com.dlink.model.DataBase;
import com.dlink.model.Savepoints;
import com.dlink.model.Task;
import com.dlink.result.IResult; import com.dlink.result.IResult;
import com.dlink.result.SelectResult; import com.dlink.result.SelectResult;
import com.dlink.result.SqlExplainResult; import com.dlink.result.SqlExplainResult;
...@@ -301,7 +300,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -301,7 +300,7 @@ public class StudioServiceImpl implements StudioService {
jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName()); jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName());
jobConfig.setTaskId(cluster.getTaskId()); jobConfig.setTaskId(cluster.getTaskId());
useGateway = true; useGateway = true;
}else { } else {
jobConfig.setTaskId(taskId); jobConfig.setTaskId(taskId);
} }
JobManager jobManager = JobManager.build(jobConfig); JobManager jobManager = JobManager.build(jobConfig);
...@@ -309,7 +308,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -309,7 +308,7 @@ public class StudioServiceImpl implements StudioService {
SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null); SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null);
if (Asserts.isNotNull(savePointResult)) { if (Asserts.isNotNull(savePointResult)) {
for (JobInfo item : savePointResult.getJobInfos()) { for (JobInfo item : savePointResult.getJobInfos()) {
if (Asserts.isEqualsIgnoreCase(jobId, item.getJobId())&&Asserts.isNotNull(jobConfig.getTaskId())) { if (Asserts.isEqualsIgnoreCase(jobId, item.getJobId()) && Asserts.isNotNull(jobConfig.getTaskId())) {
Savepoints savepoints = new Savepoints(); Savepoints savepoints = new Savepoints();
savepoints.setName(name); savepoints.setName(name);
savepoints.setType(savePointType); savepoints.setType(savePointType);
......
...@@ -7,7 +7,6 @@ import com.dlink.mapper.SysConfigMapper; ...@@ -7,7 +7,6 @@ import com.dlink.mapper.SysConfigMapper;
import com.dlink.model.SysConfig; import com.dlink.model.SysConfig;
import com.dlink.model.SystemConfiguration; import com.dlink.model.SystemConfiguration;
import com.dlink.service.SysConfigService; import com.dlink.service.SysConfigService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -30,10 +29,10 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC ...@@ -30,10 +29,10 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC
@Override @Override
public Map<String, Object> getAll() { public Map<String, Object> getAll() {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<SysConfig> sysConfigs = list(); List<SysConfig> sysConfigs = list();
for(SysConfig item : sysConfigs){ for (SysConfig item : sysConfigs) {
map.put(item.getName(),item.getValue()); map.put(item.getName(), item.getValue());
} }
SystemConfiguration.getInstances().addConfiguration(map); SystemConfiguration.getInstances().addConfiguration(map);
return map; return map;
...@@ -46,7 +45,7 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC ...@@ -46,7 +45,7 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC
@Override @Override
public void updateSysConfigByJson(JsonNode node) { public void updateSysConfigByJson(JsonNode node) {
if (node!=null&&node.isObject()) { if (node != null && node.isObject()) {
Iterator<Map.Entry<String, JsonNode>> it = node.fields(); Iterator<Map.Entry<String, JsonNode>> it = node.fields();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next(); Map.Entry<String, JsonNode> entry = it.next();
...@@ -55,10 +54,10 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC ...@@ -55,10 +54,10 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC
SysConfig config = getOne(new QueryWrapper<SysConfig>().eq("name", name)); SysConfig config = getOne(new QueryWrapper<SysConfig>().eq("name", name));
SysConfig newConfig = new SysConfig(); SysConfig newConfig = new SysConfig();
newConfig.setValue(value); newConfig.setValue(value);
if(Asserts.isNull(config)){ if (Asserts.isNull(config)) {
newConfig.setName(name); newConfig.setName(name);
save(newConfig); save(newConfig);
}else { } else {
newConfig.setId(config.getId()); newConfig.setId(config.getId());
updateById(newConfig); updateById(newConfig);
} }
......
...@@ -341,7 +341,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -341,7 +341,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task task = getById(id); Task task = getById(id);
Assert.check(task); Assert.check(task);
if (JobLifeCycle.RELEASE.equalsValue(task.getStep())) { if (JobLifeCycle.RELEASE.equalsValue(task.getStep())) {
if(Asserts.isNotNull(task.getJobInstanceId())&&task.getJobInstanceId()!=0){ if (Asserts.isNotNull(task.getJobInstanceId()) && task.getJobInstanceId() != 0) {
return Result.failed("当前发布状态下有作业正在运行,上线失败,请停止后上线"); return Result.failed("当前发布状态下有作业正在运行,上线失败,请停止后上线");
} }
JobResult jobResult = submitTaskToOnline(id); JobResult jobResult = submitTaskToOnline(id);
...@@ -349,7 +349,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -349,7 +349,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
task.setStep(JobLifeCycle.ONLINE.getValue()); task.setStep(JobLifeCycle.ONLINE.getValue());
task.setJobInstanceId(jobResult.getJobInstanceId()); task.setJobInstanceId(jobResult.getJobInstanceId());
if (updateById(task)) { if (updateById(task)) {
return Result.succeed(jobResult,"上线成功"); return Result.succeed(jobResult, "上线成功");
} else { } else {
return Result.failed("由于未知原因,上线失败"); return Result.failed("由于未知原因,上线失败");
} }
...@@ -368,7 +368,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -368,7 +368,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
type = SavePointType.CANCEL.getValue(); type = SavePointType.CANCEL.getValue();
} }
if (savepointTask(id, type)) { if (savepointTask(id, type)) {
if(!JobLifeCycle.ONLINE.equalsValue(task.getStep())){ if (!JobLifeCycle.ONLINE.equalsValue(task.getStep())) {
return Result.succeed("停止成功"); return Result.succeed("停止成功");
} }
task.setStep(JobLifeCycle.RELEASE.getValue()); task.setStep(JobLifeCycle.RELEASE.getValue());
...@@ -387,7 +387,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -387,7 +387,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task task = getById(id); Task task = getById(id);
Assert.check(task); Assert.check(task);
if (JobLifeCycle.ONLINE != JobLifeCycle.get(task.getStep())) { if (JobLifeCycle.ONLINE != JobLifeCycle.get(task.getStep())) {
if(Asserts.isNotNull(task.getJobInstanceId())&&task.getJobInstanceId()!=0){ if (Asserts.isNotNull(task.getJobInstanceId()) && task.getJobInstanceId() != 0) {
return Result.failed("当前有作业正在运行,注销失败,请停止后注销"); return Result.failed("当前有作业正在运行,注销失败,请停止后注销");
} }
task.setStep(JobLifeCycle.CANCEL.getValue()); task.setStep(JobLifeCycle.CANCEL.getValue());
...@@ -417,7 +417,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -417,7 +417,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Asserts.checkNotNull(cluster, "该集群不存在"); Asserts.checkNotNull(cluster, "该集群不存在");
Asserts.checkNotNull(task.getJobInstanceId(), "无任务需要SavePoint"); Asserts.checkNotNull(task.getJobInstanceId(), "无任务需要SavePoint");
JobInstance jobInstance = jobInstanceService.getById(task.getJobInstanceId()); JobInstance jobInstance = jobInstanceService.getById(task.getJobInstanceId());
if(Asserts.isNull(jobInstance)){ if (Asserts.isNull(jobInstance)) {
return true; return true;
} }
String jobId = jobInstance.getJid(); String jobId = jobInstance.getJid();
...@@ -434,7 +434,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -434,7 +434,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
jobConfig.setTaskId(task.getId()); jobConfig.setTaskId(task.getId());
JobManager jobManager = JobManager.build(jobConfig); JobManager jobManager = JobManager.build(jobConfig);
jobManager.setUseGateway(useGateway); jobManager.setUseGateway(useGateway);
if("canceljob".equals(savePointType)){ if ("canceljob".equals(savePointType)) {
return jobManager.cancel(jobId); return jobManager.cancel(jobId);
} }
SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null); SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null);
......
...@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.common.result.Result; import com.dlink.common.result.Result;
import com.dlink.db.service.impl.SuperServiceImpl; import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.exception.BusException;
import com.dlink.mapper.UserMapper; import com.dlink.mapper.UserMapper;
import com.dlink.model.User; import com.dlink.model.User;
import com.dlink.service.UserService; import com.dlink.service.UserService;
...@@ -22,47 +21,48 @@ import org.springframework.stereotype.Service; ...@@ -22,47 +21,48 @@ import org.springframework.stereotype.Service;
public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implements UserService { public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implements UserService {
private static final String DEFAULT_PASSWORD = "123456"; private static final String DEFAULT_PASSWORD = "123456";
@Override @Override
public Result registerUser(User user) { public Result registerUser(User user) {
User userByUsername = getUserByUsername(user.getUsername()); User userByUsername = getUserByUsername(user.getUsername());
if(Asserts.isNotNull(userByUsername)){ if (Asserts.isNotNull(userByUsername)) {
return Result.failed("该账号已存在"); return Result.failed("该账号已存在");
} }
if(Asserts.isNullString(user.getPassword())){ if (Asserts.isNullString(user.getPassword())) {
user.setPassword(DEFAULT_PASSWORD); user.setPassword(DEFAULT_PASSWORD);
} }
user.setPassword(SaSecureUtil.md5(user.getPassword())); user.setPassword(SaSecureUtil.md5(user.getPassword()));
user.setEnabled(true); user.setEnabled(true);
user.setDelete(false); user.setDelete(false);
if(save(user)){ if (save(user)) {
return Result.succeed("注册成功"); return Result.succeed("注册成功");
}else{ } else {
return Result.failed("该账号已存在"); return Result.failed("该账号已存在");
} }
} }
@Override @Override
public boolean modifyUser(User user) { public boolean modifyUser(User user) {
if(Asserts.isNull(user.getId())){ if (Asserts.isNull(user.getId())) {
return false; return false;
} }
if(Asserts.isNotNull(user.getPassword())){ if (Asserts.isNotNull(user.getPassword())) {
user.setPassword(SaSecureUtil.md5(user.getPassword())); user.setPassword(SaSecureUtil.md5(user.getPassword()));
} }
return updateById(user); return updateById(user);
} }
@Override @Override
public Result modifyPassword(String username, String password,String newPassword) { public Result modifyPassword(String username, String password, String newPassword) {
User user = getUserByUsername(username); User user = getUserByUsername(username);
if(Asserts.isNull(user)){ if (Asserts.isNull(user)) {
return Result.failed("该账号不存在"); return Result.failed("该账号不存在");
} }
if(!Asserts.isEquals(SaSecureUtil.md5(password),user.getPassword())){ if (!Asserts.isEquals(SaSecureUtil.md5(password), user.getPassword())) {
return Result.failed("原密码错误"); return Result.failed("原密码错误");
} }
user.setPassword(SaSecureUtil.md5(newPassword)); user.setPassword(SaSecureUtil.md5(newPassword));
if(updateById(user)){ if (updateById(user)) {
return Result.succeed("密码修改成功"); return Result.succeed("密码修改成功");
} }
return Result.failed("密码修改失败"); return Result.failed("密码修改失败");
...@@ -77,35 +77,35 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen ...@@ -77,35 +77,35 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen
} }
@Override @Override
public Result loginUser(String username, String password,boolean isRemember) { public Result loginUser(String username, String password, boolean isRemember) {
User user = getUserByUsername(username); User user = getUserByUsername(username);
if(Asserts.isNull(user)){ if (Asserts.isNull(user)) {
return Result.failed("账号或密码错误"); return Result.failed("账号或密码错误");
} }
String userPassword = user.getPassword(); String userPassword = user.getPassword();
if(Asserts.isNullString(password)){ if (Asserts.isNullString(password)) {
return Result.failed("密码不能为空"); return Result.failed("密码不能为空");
} }
if(Asserts.isEquals(SaSecureUtil.md5(password),userPassword)){ if (Asserts.isEquals(SaSecureUtil.md5(password), userPassword)) {
if(user.isDelete()){ if (user.isDelete()) {
return Result.failed("账号不存在"); return Result.failed("账号不存在");
} }
if(!user.isEnabled()){ if (!user.isEnabled()) {
return Result.failed("账号已被禁用"); return Result.failed("账号已被禁用");
} }
StpUtil.login(user.getId(), isRemember); StpUtil.login(user.getId(), isRemember);
StpUtil.getSession().set("user", user); StpUtil.getSession().set("user", user);
return Result.succeed(user, "登录成功"); return Result.succeed(user, "登录成功");
}else{ } else {
return Result.failed("账号或密码错误"); return Result.failed("账号或密码错误");
} }
} }
@Override @Override
public User getUserByUsername(String username) { public User getUserByUsername(String username) {
User user = getOne(new QueryWrapper<User>().eq("username", username).eq("is_delete",0)); User user = getOne(new QueryWrapper<User>().eq("username", username).eq("is_delete", 0));
if(Asserts.isNotNull(user)){ if (Asserts.isNotNull(user)) {
user.setAdmin(Asserts.isEqualsIgnoreCase(username,"admin")); user.setAdmin(Asserts.isEqualsIgnoreCase(username, "admin"));
} }
return user; return user;
} }
......
/* http://127.0.0.1:8888/openapi/explainSql */ /* http://127.0.0.1:8888/openapi/savepoint */
{ {
/* required-start */ /* required-start */
"jobId":"195352b0a4518e16699983a13205f059", "jobId":"195352b0a4518e16699983a13205f059",
......
...@@ -12,7 +12,7 @@ import org.junit.Test; ...@@ -12,7 +12,7 @@ import org.junit.Test;
public class AdminTest { public class AdminTest {
@Test @Test
public void adminTest(){ public void adminTest() {
String admin = SaSecureUtil.md5("admin"); String admin = SaSecureUtil.md5("admin");
System.out.println(admin); System.out.println(admin);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment