Node增删改查
parent
8d558af36d
commit
33a1f28f2b
|
@ -0,0 +1,110 @@
|
||||||
|
package com.muyu.common.domian;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.common.domian.req.NodeAddReq;
|
||||||
|
import com.muyu.common.domian.req.NodeUpdReq;
|
||||||
|
import com.muyu.common.domian.req.TaskInfoAddReq;
|
||||||
|
import com.muyu.common.domian.resp.NodeResp;
|
||||||
|
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "etl_node" ,autoResultMap = true)
|
||||||
|
public class Node extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id(taskInfo)
|
||||||
|
*/
|
||||||
|
private Integer taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库id
|
||||||
|
*/
|
||||||
|
private String databaseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表别名
|
||||||
|
*/
|
||||||
|
private String tableAsName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段
|
||||||
|
*/
|
||||||
|
private String tableField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段别名
|
||||||
|
*/
|
||||||
|
private String tableAsField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段规则
|
||||||
|
*/
|
||||||
|
private String fieldAsEngineId;
|
||||||
|
|
||||||
|
public static NodeResp build(Node node) {
|
||||||
|
return NodeResp.builder()
|
||||||
|
.id(node.id)
|
||||||
|
.nodeName(node.nodeName)
|
||||||
|
.taskId(node.taskId)
|
||||||
|
.databaseId(node.databaseId)
|
||||||
|
.tableName(node.tableName)
|
||||||
|
.tableAsName(node.tableAsName)
|
||||||
|
.tableField(node.tableField)
|
||||||
|
.tableAsField(node.getTableField())
|
||||||
|
.fieldAsEngineId(node.fieldAsEngineId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Node addBuild(NodeAddReq req) {
|
||||||
|
return Node.builder()
|
||||||
|
.nodeName(req.getNodeName())
|
||||||
|
.taskId(req.getTaskId())
|
||||||
|
.databaseId(req.getDatabaseId())
|
||||||
|
.tableName(req.getTableName())
|
||||||
|
.tableAsName(req.getTableAsName())
|
||||||
|
.tableField(req.getTableField())
|
||||||
|
.tableAsField(req.getTableAsField())
|
||||||
|
.fieldAsEngineId(req.getFieldAsEngineId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
public static Node updBuild(NodeUpdReq req, Supplier<Integer> id) {
|
||||||
|
return Node.builder()
|
||||||
|
.id(id.get())
|
||||||
|
.nodeName(req.getNodeName())
|
||||||
|
.taskId(req.getTaskId())
|
||||||
|
.databaseId(req.getDatabaseId())
|
||||||
|
.tableName(req.getTableName())
|
||||||
|
.tableAsName(req.getTableAsName())
|
||||||
|
.tableField(req.getTableField())
|
||||||
|
.tableAsField(req.getTableAsField())
|
||||||
|
.fieldAsEngineId(req.getFieldAsEngineId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.muyu.common.domian.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "节点添加请求对象" )
|
||||||
|
public class NodeAddReq {
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id(taskInfo)
|
||||||
|
*/
|
||||||
|
private Integer taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库id
|
||||||
|
*/
|
||||||
|
private String databaseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表别名
|
||||||
|
*/
|
||||||
|
private String tableAsName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段
|
||||||
|
*/
|
||||||
|
private String tableField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段别名
|
||||||
|
*/
|
||||||
|
private String tableAsField;
|
||||||
|
/**
|
||||||
|
* 字段规则
|
||||||
|
*/
|
||||||
|
private String fieldAsEngineId;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.muyu.common.domian.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "节点列表请求对象" )
|
||||||
|
public class NodeListReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
/**
|
||||||
|
* 分页页数
|
||||||
|
*/
|
||||||
|
@Schema(name = "pageNum",description = "分页页数")
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页展示几条
|
||||||
|
*/
|
||||||
|
@Schema(name = "pageSize",description = "每页展示几条")
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.muyu.common.domian.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "节点添加请求对象" )
|
||||||
|
public class NodeUpdReq {
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id(taskInfo)
|
||||||
|
*/
|
||||||
|
private Integer taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库id
|
||||||
|
*/
|
||||||
|
private String databaseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表别名
|
||||||
|
*/
|
||||||
|
private String tableAsName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段
|
||||||
|
*/
|
||||||
|
private String tableField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段别名
|
||||||
|
*/
|
||||||
|
private String tableAsField;
|
||||||
|
/**
|
||||||
|
* 字段规则
|
||||||
|
*/
|
||||||
|
private String fieldAsEngineId;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.common.domian.resp;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "节点列表返回对象" ,description = "负责节点信息查询的响应结果")
|
||||||
|
public class NodeResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id(taskInfo)
|
||||||
|
*/
|
||||||
|
private Integer taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库id
|
||||||
|
*/
|
||||||
|
private String databaseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表别名
|
||||||
|
*/
|
||||||
|
private String tableAsName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段
|
||||||
|
*/
|
||||||
|
private String tableField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段别名
|
||||||
|
*/
|
||||||
|
private String tableAsField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段规则
|
||||||
|
*/
|
||||||
|
private String fieldAsEngineId;
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.muyu.task.server.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.domian.Node;
|
||||||
|
import com.muyu.common.domian.TaskInfo;
|
||||||
|
import com.muyu.common.domian.req.*;
|
||||||
|
import com.muyu.common.domian.resp.NodeResp;
|
||||||
|
import com.muyu.common.domian.resp.TaskInfoResp;
|
||||||
|
import com.muyu.task.server.service.NodeService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("node")
|
||||||
|
public class NodeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NodeService nodeService;
|
||||||
|
/**
|
||||||
|
* 获取所有的任务信息
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("list")
|
||||||
|
@Operation(summary = "查看节点", description = "根据节点名称 权重 状态 查询")
|
||||||
|
public Result list(@RequestBody NodeListReq req) {
|
||||||
|
Page<Node> list = nodeService.findList(req);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加节点信息
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping()
|
||||||
|
@Operation(summary = "添加节点", description = "添加任务信息表")
|
||||||
|
public Result save(@RequestBody @Validated NodeAddReq req) {
|
||||||
|
nodeService.save(Node.addBuild(req));
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询任务信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@Operation(summary = "任务信息查询",description = "通过任务id查询任务信息")
|
||||||
|
public Result<NodeResp> selectById(@PathVariable("id") Long id) {
|
||||||
|
Node byId = nodeService.getById(id);
|
||||||
|
return Result.success(Node.build(byId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除任务
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@Operation(summary = "删除任务",description = "通过任务id删除任务信息")
|
||||||
|
public Result delete(@PathVariable("id") Long id) {
|
||||||
|
nodeService.removeById(id);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id修改任务
|
||||||
|
* @param id
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
@Operation(summary = "任务信息修改",description = "通过任务id修改任务信息")
|
||||||
|
public Result update(@PathVariable("id") Integer id , @RequestBody NodeUpdReq req){
|
||||||
|
nodeService.updateById(Node.updBuild(req,()->id));
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -38,6 +38,11 @@ public class TaskInfoController {
|
||||||
return Result.success(taskInfoService.selectList(req));
|
return Result.success(taskInfoService.selectList(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加任务信息
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
@Operation(summary = "添加任务", description = "添加任务信息表")
|
@Operation(summary = "添加任务", description = "添加任务信息表")
|
||||||
public Result save(@RequestBody @Validated TaskInfoAddReq req) {
|
public Result save(@RequestBody @Validated TaskInfoAddReq req) {
|
||||||
|
@ -45,6 +50,11 @@ public class TaskInfoController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询任务信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@Operation(summary = "任务信息查询",description = "通过任务id查询任务信息")
|
@Operation(summary = "任务信息查询",description = "通过任务id查询任务信息")
|
||||||
public Result<TaskInfoResp> selectById(@PathVariable("id") Long id) {
|
public Result<TaskInfoResp> selectById(@PathVariable("id") Long id) {
|
||||||
|
@ -52,6 +62,11 @@ public class TaskInfoController {
|
||||||
return Result.success(TaskInfo.build(byId));
|
return Result.success(TaskInfo.build(byId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除任务
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@Operation(summary = "删除任务",description = "通过任务id删除任务信息")
|
@Operation(summary = "删除任务",description = "通过任务id删除任务信息")
|
||||||
public Result delete(@PathVariable("id") Long id) {
|
public Result delete(@PathVariable("id") Long id) {
|
||||||
|
@ -59,6 +74,12 @@ public class TaskInfoController {
|
||||||
return Result.success(null,"操作成功");
|
return Result.success(null,"操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id修改任务
|
||||||
|
* @param id
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@Operation(summary = "任务信息修改",description = "通过任务id修改任务信息")
|
@Operation(summary = "任务信息修改",description = "通过任务id修改任务信息")
|
||||||
public Result update(@PathVariable("id") Long id , @RequestBody TaskInfoUpdReq req){
|
public Result update(@PathVariable("id") Long id , @RequestBody TaskInfoUpdReq req){
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.task.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.common.domian.Node;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface NodeMapper extends BaseMapper<Node> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.task.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.domian.Node;
|
||||||
|
import com.muyu.common.domian.req.NodeListReq;
|
||||||
|
|
||||||
|
public interface NodeService extends IService<Node> {
|
||||||
|
Page<Node> findList(NodeListReq req);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.task.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.common.domian.Node;
|
||||||
|
import com.muyu.common.domian.req.NodeListReq;
|
||||||
|
import com.muyu.task.server.mapper.NodeMapper;
|
||||||
|
import com.muyu.task.server.service.NodeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService {
|
||||||
|
@Override
|
||||||
|
public Page<Node> findList(NodeListReq req) {
|
||||||
|
LambdaQueryWrapper<Node> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.like(StringUtils.isNotEmpty(req.getNodeName()), Node::getNodeName, req.getNodeName());
|
||||||
|
Page<Node> page = new Page<>(req.getPageNum(), req.getPageSize());
|
||||||
|
return this.page(page, wrapper);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue