forked from DataLinkDC/dinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,558 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.dlink; | ||
|
||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
/** | ||
* Dlink 启动器 | ||
* @author wenmo | ||
* @since 2021/5/28 | ||
*/ | ||
@EnableTransactionManagement | ||
@SpringBootApplication | ||
public class Dlink { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Dlink.class, args); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
dlink-admin/src/main/java/com/dlink/common/banner/BannerInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.dlink.common.banner; | ||
|
||
import com.dlink.constant.CommonConstant; | ||
import com.dlink.utils.CustomBanner; | ||
import com.nepxion.banner.BannerConstant; | ||
import com.nepxion.banner.Description; | ||
import com.nepxion.banner.LogoBanner; | ||
import com.taobao.text.Color; | ||
import org.springframework.context.ApplicationContextInitializer; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
|
||
/** | ||
* BannerInitializer | ||
* | ||
* @author wenmo | ||
* @since 2021/5/10 21:40 | ||
*/ | ||
public class BannerInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | ||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
if (!(applicationContext instanceof AnnotationConfigApplicationContext)) { | ||
LogoBanner logoBanner = new LogoBanner(BannerInitializer.class, "/dlink/logo.txt", "Welcome to Dlink", 5, 6, new Color[5], true); | ||
CustomBanner.show(logoBanner, new Description(BannerConstant.VERSION + ":", CommonConstant.PROJECT_VERSION, 0, 1) | ||
, new Description("Github:", "https://github.com/aiwenmo/dlink", 0, 1) | ||
, new Description("公众号:", "DataLink数据中台", 0, 1) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
dlink-admin/src/main/java/com/dlink/constant/CommonConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.dlink.constant; | ||
|
||
/** | ||
* CommonConstant | ||
* | ||
* @author wenmo | ||
* @since 2021/5/28 9:35 | ||
**/ | ||
public interface CommonConstant { | ||
/** | ||
* 项目版本号(banner使用) | ||
*/ | ||
String PROJECT_VERSION = "0.1.0"; | ||
} |
39 changes: 39 additions & 0 deletions
39
dlink-admin/src/main/java/com/dlink/controller/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.dlink.controller; | ||
|
||
import com.dlink.common.result.Result; | ||
import com.dlink.model.Task; | ||
import com.dlink.model.User; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* AdminController | ||
* | ||
* @author wenmo | ||
* @since 2021/5/28 15:52 | ||
**/ | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/user") | ||
public class AdminController { | ||
|
||
@Value("${dlink.login.username}") | ||
private String username; | ||
@Value("${dlink.login.password}") | ||
private String password; | ||
/** | ||
* 获取指定ID的信息 | ||
*/ | ||
@PostMapping("/login") | ||
public Result getOneById(@RequestBody User user) throws Exception { | ||
if(username.equals(user.getUsername())&&password.equals(user.getPassword())) { | ||
return Result.succeed(username, "登录成功"); | ||
}else{ | ||
return Result.failed("验证失败"); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
dlink-admin/src/main/java/com/dlink/controller/CatalogueController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.dlink.controller; | ||
|
||
import com.dlink.common.result.ProTableResult; | ||
import com.dlink.common.result.Result; | ||
import com.dlink.model.Catalogue; | ||
import com.dlink.service.CatalogueService; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* CatalogueController | ||
* | ||
* @author wenmo | ||
* @since 2021/5/28 14:03 | ||
**/ | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/catalogue") | ||
public class CatalogueController { | ||
@Autowired | ||
private CatalogueService catalogueService; | ||
|
||
/** | ||
* 新增或者更新 | ||
*/ | ||
@PutMapping | ||
public Result saveOrUpdate(@RequestBody Catalogue catalogue) throws Exception { | ||
if(catalogueService.saveOrUpdate(catalogue)){ | ||
return Result.succeed("新增成功"); | ||
}else { | ||
return Result.failed("新增失败"); | ||
} | ||
} | ||
|
||
/** | ||
* 动态查询列表 | ||
*/ | ||
@PostMapping | ||
public ProTableResult<Catalogue> listCatalogues(@RequestBody JsonNode para) { | ||
return catalogueService.selectForProTable(para); | ||
} | ||
|
||
/** | ||
* 批量删除 | ||
*/ | ||
@DeleteMapping | ||
public Result deleteMul(@RequestBody JsonNode para) { | ||
if (para.size()>0){ | ||
boolean isAdmin = false; | ||
List<Integer> error = new ArrayList<>(); | ||
for (final JsonNode item : para){ | ||
Integer id = item.asInt(); | ||
if(!catalogueService.removeById(id)){ | ||
error.add(id); | ||
} | ||
} | ||
if(error.size()==0&&!isAdmin) { | ||
return Result.succeed("删除成功"); | ||
}else { | ||
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); | ||
} | ||
}else{ | ||
return Result.failed("请选择要删除的记录"); | ||
} | ||
} | ||
|
||
/** | ||
* 获取指定ID的信息 | ||
*/ | ||
@PostMapping("/getOneById") | ||
public Result getOneById(@RequestBody Catalogue catalogue) throws Exception { | ||
catalogue = catalogueService.getById(catalogue.getId()); | ||
return Result.succeed(catalogue,"获取成功"); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
dlink-admin/src/main/java/com/dlink/controller/ClusterController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.dlink.controller; | ||
|
||
import com.dlink.common.result.ProTableResult; | ||
import com.dlink.common.result.Result; | ||
import com.dlink.model.Cluster; | ||
import com.dlink.result.SubmitResult; | ||
import com.dlink.service.ClusterService; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* ClusterController | ||
* | ||
* @author wenmo | ||
* @since 2021/5/28 14:03 | ||
**/ | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/cluster") | ||
public class ClusterController { | ||
@Autowired | ||
private ClusterService clusterService; | ||
|
||
/** | ||
* 新增或者更新 | ||
*/ | ||
@PutMapping | ||
public Result saveOrUpdate(@RequestBody Cluster cluster) throws Exception { | ||
if(clusterService.saveOrUpdate(cluster)){ | ||
return Result.succeed("新增成功"); | ||
}else { | ||
return Result.failed("新增失败"); | ||
} | ||
} | ||
|
||
/** | ||
* 动态查询列表 | ||
*/ | ||
@PostMapping | ||
public ProTableResult<Cluster> listClusters(@RequestBody JsonNode para) { | ||
return clusterService.selectForProTable(para); | ||
} | ||
|
||
/** | ||
* 批量删除 | ||
*/ | ||
@DeleteMapping | ||
public Result deleteMul(@RequestBody JsonNode para) { | ||
if (para.size()>0){ | ||
boolean isAdmin = false; | ||
List<Integer> error = new ArrayList<>(); | ||
for (final JsonNode item : para){ | ||
Integer id = item.asInt(); | ||
if(!clusterService.removeById(id)){ | ||
error.add(id); | ||
} | ||
} | ||
if(error.size()==0&&!isAdmin) { | ||
return Result.succeed("删除成功"); | ||
}else { | ||
return Result.succeed("删除部分成功,但"+error.toString()+"删除失败,共"+error.size()+"次失败。"); | ||
} | ||
}else{ | ||
return Result.failed("请选择要删除的记录"); | ||
} | ||
} | ||
|
||
/** | ||
* 获取指定ID的信息 | ||
*/ | ||
@PostMapping("/getOneById") | ||
public Result getOneById(@RequestBody Cluster cluster) throws Exception { | ||
cluster = clusterService.getById(cluster.getId()); | ||
return Result.succeed(cluster,"获取成功"); | ||
} | ||
|
||
/** | ||
* 全部心跳监测 | ||
*/ | ||
@PostMapping("/heartbeats") | ||
public Result heartbeat(@RequestBody JsonNode para) { | ||
List<Cluster> clusters = clusterService.listEnabledAll(); | ||
for (int i = 0; i < clusters.size(); i++) { | ||
Cluster cluster = clusters.get(i); | ||
String jobManagerHost = clusterService.checkHeartBeat(cluster.getHosts(), cluster.getJobManagerHost()); | ||
if(jobManagerHost==null){ | ||
cluster.setJobManagerHost(""); | ||
cluster.setStatus(0); | ||
}else{ | ||
cluster.setJobManagerHost(jobManagerHost); | ||
cluster.setStatus(1); | ||
} | ||
clusterService.updateById(cluster); | ||
} | ||
return Result.succeed("状态刷新完成"); | ||
} | ||
} |
Oops, something went wrong.