Skip to content

Commit

Permalink
Merge pull request DataLinkDC#6 from aiwenmo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
aiwenmo authored Jun 1, 2021
2 parents 7b7f57a + 2cda298 commit fd6db6f
Show file tree
Hide file tree
Showing 32 changed files with 1,026 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dlink.common.result.ProTableResult;
import com.dlink.common.result.Result;
import com.dlink.dto.CatalogueTaskDTO;
import com.dlink.model.Catalogue;
import com.dlink.service.CatalogueService;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -36,9 +37,9 @@ public class CatalogueController {
@PutMapping
public Result saveOrUpdate(@RequestBody Catalogue catalogue) throws Exception {
if(catalogueService.saveOrUpdate(catalogue)){
return Result.succeed("新增成功");
return Result.succeed("创建成功");
}else {
return Result.failed("新增失败");
return Result.failed("创建失败");
}
}

Expand All @@ -60,7 +61,7 @@ public Result deleteMul(@RequestBody JsonNode para) {
List<Integer> error = new ArrayList<>();
for (final JsonNode item : para){
Integer id = item.asInt();
if(!catalogueService.removeById(id)){
if(!catalogueService.removeCatalogueAndTaskById(id)){
error.add(id);
}
}
Expand Down Expand Up @@ -91,4 +92,28 @@ public Result getCatalogueTreeData() throws Exception {
List<Catalogue> catalogues = catalogueService.getAllData();
return Result.succeed(catalogues,"获取成功");
}

/**
* 创建节点和作业
*/
@PutMapping("/createTask")
public Result createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) throws Exception {
if(catalogueService.createCatalogueAndTask(catalogueTaskDTO)){
return Result.succeed("创建成功");
}else {
return Result.failed("创建失败");
}
}

/**
* 创建节点和作业
*/
@PutMapping("/toRename")
public Result toRename(@RequestBody Catalogue catalogue) throws Exception {
if(catalogueService.toRename(catalogue)){
return Result.succeed("重命名成功");
}else {
return Result.failed("重命名失败");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
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 org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -104,9 +99,9 @@ public Result submit(@RequestBody JsonNode para) throws Exception {
/**
* 获取指定ID的信息
*/
@PostMapping("/getOneById")
public Result getOneById(@RequestBody Task task) throws Exception {
task = taskService.getById(task.getId());
@GetMapping
public Result getOneById(@RequestParam Integer id) {
Task task = taskService.getTaskInfoById(id);
return Result.succeed(task,"获取成功");
}
}
Expand Down
20 changes: 20 additions & 0 deletions dlink-admin/src/main/java/com/dlink/dto/CatalogueTaskDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.dlink.dto;

import lombok.Getter;
import lombok.Setter;

/**
* CatalogueTaskDTO
*
* @author wenmo
* @since 2021/6/1 20:16
*/
@Getter
@Setter
public class CatalogueTaskDTO {
private Integer id;
private Integer parentId;
private boolean isLeaf;
private String name;
private String alias;
}
2 changes: 1 addition & 1 deletion dlink-admin/src/main/java/com/dlink/model/Catalogue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ public class Catalogue extends SuperEntity {

private Integer parentId;

private Boolean isDir;
private Boolean isLeaf;
}
6 changes: 6 additions & 0 deletions dlink-admin/src/main/java/com/dlink/model/Task.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dlink.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dlink.db.model.SuperEntity;
import com.dlink.executor.Executor;
Expand Down Expand Up @@ -36,11 +37,16 @@ public class Task extends SuperEntity{

private String note;

@TableField(exist = false)
private String statement;

public ExecutorSetting getLocalExecutorSetting(){
return new ExecutorSetting(Executor.LOCAL,checkPoint,parallelism,fragment,savePointPath);
}

public ExecutorSetting getRemoteExecutorSetting(){
return new ExecutorSetting(Executor.REMOTE,checkPoint,parallelism,fragment,savePointPath);
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dlink.service;

import com.dlink.db.service.ISuperService;
import com.dlink.dto.CatalogueTaskDTO;
import com.dlink.model.Catalogue;

import java.util.List;
Expand All @@ -14,4 +15,10 @@
public interface CatalogueService extends ISuperService<Catalogue> {

List<Catalogue> getAllData();

boolean createCatalogueAndTask(CatalogueTaskDTO catalogueTaskDTO);

boolean toRename(Catalogue catalogue);

boolean removeCatalogueAndTaskById(Integer id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface TaskService extends ISuperService<Task> {

SubmitResult submitByTaskId(Integer id);

Task getTaskInfoById(Integer id);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.dlink.service.impl;

import com.dlink.assertion.Assert;
import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.dto.CatalogueTaskDTO;
import com.dlink.mapper.CatalogueMapper;
import com.dlink.model.Catalogue;
import com.dlink.model.Task;
import com.dlink.service.CatalogueService;
import com.dlink.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

Expand All @@ -16,8 +22,57 @@
**/
@Service
public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Catalogue> implements CatalogueService {

@Autowired
private TaskService taskService;

@Override
public List<Catalogue> getAllData() {
return this.list();
}

@Transactional(rollbackFor=Exception.class)
@Override
public boolean createCatalogueAndTask(CatalogueTaskDTO catalogueTaskDTO) {
Task task = new Task();
task.setName(catalogueTaskDTO.getName());
task.setAlias(catalogueTaskDTO.getAlias());
taskService.save(task);
Catalogue catalogue = new Catalogue();
catalogue.setName(catalogueTaskDTO.getAlias());
catalogue.setIsLeaf(true);
catalogue.setTaskId(task.getId());
catalogue.setParentId(catalogueTaskDTO.getParentId());
return this.save(catalogue);
}

@Transactional(rollbackFor=Exception.class)
@Override
public boolean toRename(Catalogue catalogue) {
Catalogue oldCatalogue = this.getById(catalogue.getId());
if(oldCatalogue==null){
return false;
}else{
Task task = new Task();
task.setId(oldCatalogue.getTaskId());
task.setAlias(oldCatalogue.getName());
taskService.updateById(task);
this.updateById(catalogue);
return true;
}
}

@Override
public boolean removeCatalogueAndTaskById(Integer id) {
Catalogue catalogue = this.getById(id);
if(catalogue==null){
return false;
}else{
if(catalogue.getTaskId()!=null) {
taskService.removeById(catalogue.getTaskId());
}
this.removeById(id);
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dlink.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.assertion.Assert;
import com.dlink.cluster.FlinkCluster;
import com.dlink.db.service.impl.SuperServiceImpl;
Expand Down Expand Up @@ -46,4 +47,16 @@ public SubmitResult submitByTaskId(Integer id) {
return jobManager.submit(statement.getStatement(), task.getRemoteExecutorSetting());
}

@Override
public Task getTaskInfoById(Integer id) {
Task task = this.getById(id);
if(task!=null){
Statement statement = statementService.getById(id);
if(statement!=null){
task.setStatement(statement.getStatement());
}
}
return task;
}

}
4 changes: 2 additions & 2 deletions dlink-admin/src/main/resources/mapper/CatalogueMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<result column="task_id" property="taskId" />
<result column="type" property="type" />
<result column="parent_id" property="parentId" />
<result column="is_dir" property="isDir" />
<result column="is_leaf" property="isLeaf" />
<result column="enabled" property="enabled" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>

<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, task_id, type,parent_id,is_dir, enabled, create_time, update_time
id, name, task_id, type,parent_id,is_leaf, enabled, create_time, update_time
</sql>


Expand Down
4 changes: 2 additions & 2 deletions dlink-doc/sql/dlink.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ CREATE TABLE `dlink_catalogue` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`task_id` int(11) NULL DEFAULT NULL COMMENT '任务ID',
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
`type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型',
`type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '类型',
`parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '父ID',
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '启用',
`is_dir` tinyint(1) NOT NULL COMMENT '是否为文件夹',
`is_leaf` tinyint(1) NOT NULL COMMENT '是否为叶子',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '最近修改时间',
PRIMARY KEY (`id`) USING BTREE,
Expand Down
2 changes: 1 addition & 1 deletion dlink-web/config/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Settings: LayoutSettings & {
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
title: 'Dlink',
title: 'Dlink & Apache Flink',
pwa: false,
logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg',
iconfontUrl: '',
Expand Down
4 changes: 2 additions & 2 deletions dlink-web/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export default [
icon: 'home',
component: './Welcome',
},
{
/*{
path: '/studio',
name: 'studio',
icon: 'consoleSql',
component: './Studio',
},
},*/
{
path: '/flinksqlstudio',
name: 'flinsqlstudio',
Expand Down
19 changes: 19 additions & 0 deletions dlink-web/src/components/Common/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export async function postAll(url:string,params?: any) {
});
}

export async function getInfoById(url:string,id:number) {
return request(url, {
method: 'GET',
params: {
id:id,
},
});
}

export const handleAddOrUpdate = async (url:string,fields: any) => {
const tipsTitle = fields.id ? "修改" : "添加";
const hide = message.loading(`正在${tipsTitle}`);
Expand Down Expand Up @@ -112,3 +121,13 @@ export const handleOption = async (url:string,title:string,param:any) => {
return false;
}
};

export const handleInfo = async (url:string,id:number) => {
try {
const {datas} = await getInfoById(url,id);
return datas;
} catch (error) {
message.error('获取失败,请重试');
return false;
}
};
1 change: 1 addition & 0 deletions dlink-web/src/components/Common/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
Loading

0 comments on commit fd6db6f

Please sign in to comment.