数据源,规则,任务增删改查完毕
parent
fab9f96f28
commit
a0846013d5
File diff suppressed because one or more lines are too long
|
@ -21,6 +21,4 @@ public class UserAccount {
|
|||
@ApiModelProperty("密码/")
|
||||
private String password;
|
||||
|
||||
// @ApiModelProperty("uuid")
|
||||
// private String UUID;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "规则")
|
||||
@TableName("t_code")
|
||||
public class Code {
|
||||
@ApiModelProperty(value = "规则id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "规则名称")
|
||||
private String codeName;
|
||||
|
||||
@ApiModelProperty(value = "规则内容")
|
||||
private String codeContent;
|
||||
|
||||
@ApiModelProperty(value = "规则类型id")
|
||||
private Integer codeTypeId;
|
||||
|
||||
@ApiModelProperty(value = "规则id")
|
||||
private Integer ruleId;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "规则")
|
||||
@TableName("t_code_type")
|
||||
public class CodeType {
|
||||
@ApiModelProperty(value = "规则id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "规则类型名称")
|
||||
private String codeTypeName;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 规则
|
||||
*/
|
||||
@ApiModel("数据源规则")
|
||||
@Data
|
||||
@TableName("t_rule")
|
||||
public class Rule {
|
||||
@ApiModelProperty(value = "规则id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "规则名称")
|
||||
private String ruleName;
|
||||
|
||||
@ApiModelProperty(value = "规则类型id")
|
||||
private Integer ruleTypeId;
|
||||
|
||||
@ApiModelProperty(value = "规则状态 1mysql 2 redis")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "类路径")
|
||||
private String classPath;
|
||||
|
||||
@ApiModelProperty(value = "公开方式 1-仅自己可见 2-公开")
|
||||
private Integer publicWay;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
@ApiModel("规则类型")
|
||||
@Data
|
||||
@TableName("t_rule_type")
|
||||
public class RuleType {
|
||||
@ApiModelProperty(value = "规则类型id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "规则类型名称")
|
||||
private String ruleTypeName;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.etl.database.common.entity.database.BaseMate;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 任务实体类
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "任务实体类")
|
||||
@TableName("t_task")
|
||||
public class Task extends BaseMate {
|
||||
@NotNull(message = "id不能为空")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@NotEmpty(message = "任务名称不能为空")
|
||||
@ApiModelProperty(value = "任务名称")
|
||||
private String taskName;
|
||||
|
||||
@NotNull(message = "任务id不能为空")
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private Integer taskId;
|
||||
|
||||
@NotNull(message = "任务权重不能为空")
|
||||
@ApiModelProperty(value = "任务权重 1-紧急 2-高 3-中 4-低")
|
||||
private Integer taskWeight;
|
||||
|
||||
@NotNull(message = "任务状态不能为空")
|
||||
@ApiModelProperty(value = "任务状态 1-执行中 2-暂停")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "任务备注")
|
||||
private String explain;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.etl.database.common.entity;
|
||||
|
||||
import ch.qos.logback.core.net.ssl.SSL;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_task_monitor")
|
||||
@ApiModel("任务监控")
|
||||
public class TaskMonitor {
|
||||
private Integer id;
|
||||
private String task_name;
|
||||
private Integer total_runs;
|
||||
private Integer success_count;
|
||||
private Integer fail_count;
|
||||
private Integer today_insert_count;
|
||||
private Integer today_update_count;
|
||||
private Integer today_delete_count;
|
||||
private Integer fail_data;
|
||||
private String average_duration;
|
||||
}
|
|
@ -36,4 +36,7 @@ public class DruidReq {
|
|||
|
||||
@ApiModelProperty(value = "数据库表名")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty(value = "数据")
|
||||
private Integer data;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.etl.database.common.entity.req;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName RuleReq
|
||||
* @Description 描述
|
||||
* @Author TingTing.Yao
|
||||
* @Date 2024/06/25 11:01
|
||||
*/
|
||||
@Data
|
||||
public class RuleReq {
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
private Integer ruleTypeId;
|
||||
private Integer codeTypeId;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,15 +1,13 @@
|
|||
package com.etl.database.server.controller;
|
||||
|
||||
import com.etl.common.result.Result;
|
||||
import com.etl.database.common.entity.DataSources;
|
||||
import com.etl.database.common.entity.req.DataSourceReq;
|
||||
import com.etl.database.server.service.DataSouceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
@ -28,4 +26,22 @@ public class DataSourceController {
|
|||
public Result findDateSource(@RequestBody @Valid DataSourceReq dataSourceReq) {
|
||||
return dataSouceService.findDateSource(dataSourceReq);
|
||||
}
|
||||
|
||||
@PostMapping("/addMysqlDataSource")
|
||||
@ApiOperation(value = "添加数据源")
|
||||
public Result addMysqlDataSource(@RequestBody @Valid DataSources dataSources) {
|
||||
return dataSouceService.addMysqlDataSource(dataSources);
|
||||
}
|
||||
|
||||
@PutMapping("/updateMysqlDataSource")
|
||||
@ApiOperation(value = "修改数据源")
|
||||
public Result updateMysqlDataSource(@RequestBody @Valid DataSources dataSources) {
|
||||
return dataSouceService.updateMysqlDataSource(dataSources);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteMysqlDataSource")
|
||||
@ApiOperation(value = "删除数据源")
|
||||
public Result deleteMysqlDataSource(@RequestParam("id") Long id) {
|
||||
return dataSouceService.deleteMysqlDataSource(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,14 @@ public class MysqlController {
|
|||
}
|
||||
|
||||
@PostMapping("/findDatabaseTableFieldPrice")
|
||||
@ApiOperation("复制数据源数据")
|
||||
@ApiOperation("数据表输入")
|
||||
public Result<List<Map<String, Object>> > findDatabaseTableFieldPrice(@Valid @RequestBody DruidReq druidReq){
|
||||
return Result.success(dataSouceService.findDatabaseTableFieldPrice(druidReq));
|
||||
}
|
||||
|
||||
@PostMapping("outDatabaseTableFieldPrice")
|
||||
@ApiOperation("数据表输出")
|
||||
public Result outDatabaseTableFieldPrice(@Valid @RequestBody DruidReq druidReq){
|
||||
return Result.success(dataSouceService.findDatabaseTableFieldPrice(druidReq));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.etl.database.server.controller;
|
||||
|
||||
import com.etl.common.result.Result;
|
||||
import com.etl.database.common.entity.Code;
|
||||
import com.etl.database.common.entity.Rule;
|
||||
import com.etl.database.common.entity.req.RuleReq;
|
||||
import com.etl.database.server.service.RuleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则控制层
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value ="/rule")
|
||||
@Api(tags = "规则-API")
|
||||
public class RuleController {
|
||||
@Autowired
|
||||
private RuleService ruleService;
|
||||
@GetMapping("findRule")
|
||||
@ApiOperation(value = "查询规则")
|
||||
public Result findRule(@RequestBody RuleReq ruleReq) {
|
||||
List<Rule> ruleList=ruleService.findRule(ruleReq);
|
||||
return Result.success(ruleList);
|
||||
}
|
||||
|
||||
@PostMapping("addRule")
|
||||
@ApiOperation(value = "添加规则")
|
||||
public Result addRule(@RequestBody Rule rule) {
|
||||
ruleService.addRule(rule);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PutMapping("updateRule")
|
||||
@ApiOperation(value = "修改规则")
|
||||
public Result updateRule(@RequestBody Rule rule) {
|
||||
ruleService.updateRule(rule);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteRule")
|
||||
@ApiOperation(value = "删除规则")
|
||||
public Result deleteRule(@RequestParam("id") Long id) {
|
||||
ruleService.deleteRule(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/addCode")
|
||||
@ApiOperation(value = "添加规则")
|
||||
public Result addCode(@RequestBody Code code) {
|
||||
ruleService.addCode(code);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.etl.database.server.controller;
|
||||
|
||||
import com.etl.common.result.Result;
|
||||
import com.etl.database.common.entity.Task;
|
||||
import com.etl.database.server.service.TaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 任务控制层
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "任务-API")
|
||||
@RequestMapping(value ="/task")
|
||||
public class TaskController {
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@GetMapping("/findTask")
|
||||
@ApiOperation("查询任务")
|
||||
public Result<List<Task>> findTask(){
|
||||
return Result.success(taskService.findTask());
|
||||
}
|
||||
@PostMapping("/addTask")
|
||||
@ApiOperation("添加任务")
|
||||
public Result<String> addTask(@RequestBody Task task){
|
||||
taskService.addTask(task);
|
||||
return Result.success();
|
||||
}
|
||||
@PostMapping("/updateTask")
|
||||
@ApiOperation("修改任务")
|
||||
public Result<String> updateTask(@RequestBody Task task){
|
||||
taskService.updateTask(task);
|
||||
return Result.success();
|
||||
}
|
||||
@DeleteMapping("/deleteTask/{id}")
|
||||
@ApiOperation("删除任务")
|
||||
public Result<String> deleteTask(@PathVariable Long id){
|
||||
taskService.deleteTask(id);
|
||||
return Result.success();
|
||||
}
|
||||
@GetMapping("/findTaskById/{id}")
|
||||
@ApiOperation("根据id查询任务")
|
||||
public Result<Task> findTaskById(@PathVariable Long id){
|
||||
return Result.success(taskService.findTaskById(id));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.etl.database.server.mapper;
|
||||
|
||||
import com.etl.database.common.entity.Code;
|
||||
import com.etl.database.common.entity.Rule;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CodeMapper extends MPJBaseMapper<Code> {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.etl.database.server.mapper;
|
||||
|
||||
import com.etl.database.common.entity.Code;
|
||||
import com.etl.database.common.entity.CodeType;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CodeTypeMapper extends MPJBaseMapper<CodeType> {
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.etl.database.server.mapper;
|
||||
|
||||
import com.etl.database.common.entity.DataSources;
|
||||
import com.etl.database.common.entity.Rule;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface RuleMapper extends MPJBaseMapper<Rule> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.etl.database.server.mapper;
|
||||
|
||||
import com.etl.database.common.entity.DatabaseRedis;
|
||||
import com.etl.database.common.entity.RuleType;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface RuleTypeMapper extends MPJBaseMapper<RuleType> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.etl.database.server.mapper;
|
||||
|
||||
import com.etl.database.common.entity.Rule;
|
||||
import com.etl.database.common.entity.Task;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TaskMapper extends MPJBaseMapper<Task> {
|
||||
}
|
|
@ -7,4 +7,10 @@ import com.github.yulichang.base.MPJBaseService;
|
|||
|
||||
public interface DataSouceService extends MPJBaseService<DataSources> {
|
||||
Result findDateSource(DataSourceReq dataSourceReq);
|
||||
|
||||
Result addMysqlDataSource(DataSources dataSources);
|
||||
|
||||
Result updateMysqlDataSource(DataSources dataSources);
|
||||
|
||||
Result deleteMysqlDataSource(Long id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.etl.database.server.service;
|
||||
|
||||
import com.etl.common.result.Result;
|
||||
import com.etl.database.common.entity.Code;
|
||||
import com.etl.database.common.entity.DatabaseRedis;
|
||||
import com.etl.database.common.entity.Rule;
|
||||
import com.etl.database.common.entity.req.RuleReq;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RuleService extends MPJBaseService<Rule> {
|
||||
List<Rule> findRule(RuleReq ruleReq);
|
||||
|
||||
void addRule(Rule rule);
|
||||
|
||||
void updateRule(Rule rule);
|
||||
|
||||
void deleteRule(Long id);
|
||||
|
||||
void addCode(Code code);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.etl.database.server.service;
|
||||
|
||||
import com.etl.database.common.entity.Task;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskService extends MPJBaseService<Task> {
|
||||
List<Task> findTask();
|
||||
|
||||
void addTask(Task task);
|
||||
|
||||
void updateTask(Task task);
|
||||
|
||||
void deleteTask(Long id);
|
||||
|
||||
Task findTaskById(Long id);
|
||||
}
|
|
@ -23,21 +23,52 @@ import java.util.List;
|
|||
public class DataSouceServiceImpl extends MPJBaseServiceImpl<DataSourceMapper, DataSources> implements DataSouceService {
|
||||
@Autowired
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
|
||||
@Override
|
||||
public Result findDateSource(DataSourceReq dataSourceReq) {
|
||||
MPJLambdaWrapper<DataSources> dataSourceMPJLambdaWrapper = new MPJLambdaWrapper<DataSources>();
|
||||
dataSourceMPJLambdaWrapper.selectAll(DataSources.class)
|
||||
.select(DataSourceType::getDataSourceTypeName)
|
||||
.leftJoin(DataSourceType.class, DataSourceType::getId, DataSources::getDatabaseType);
|
||||
if (dataSourceReq.getDataSourceDescribe()!=null && !dataSourceReq.getDataSourceDescribe().isEmpty()){
|
||||
dataSourceMPJLambdaWrapper.like(DataSources::getDatabaseDescription,dataSourceReq.getDataSourceDescribe());
|
||||
if (dataSourceReq.getDataSourceDescribe() != null && !dataSourceReq.getDataSourceDescribe().isEmpty()) {
|
||||
dataSourceMPJLambdaWrapper.like(DataSources::getDatabaseDescription, dataSourceReq.getDataSourceDescribe());
|
||||
}
|
||||
if (dataSourceReq.getDataSourceType()!=null){
|
||||
dataSourceMPJLambdaWrapper.eq(DataSources::getDatabaseType,dataSourceReq.getDataSourceType());
|
||||
if (dataSourceReq.getDataSourceType() != null) {
|
||||
dataSourceMPJLambdaWrapper.eq(DataSources::getDatabaseType, dataSourceReq.getDataSourceType());
|
||||
}
|
||||
Page<DataSources> page = new Page<>(dataSourceReq.getPageNum(),dataSourceReq.getPageSize());
|
||||
Page<DataSources> page = new Page<>(dataSourceReq.getPageNum(), dataSourceReq.getPageSize());
|
||||
IPage<DataSources> dataSourceReqIPage = dataSourceMapper.selectJoinPage(page, DataSources.class, dataSourceMPJLambdaWrapper);
|
||||
List<DataSources> records = dataSourceReqIPage.getRecords();
|
||||
return Result.success(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addMysqlDataSource(DataSources dataSources) {
|
||||
int insert = dataSourceMapper.insert(dataSources);
|
||||
if (insert > 0) {
|
||||
return Result.success("添加成功");
|
||||
} else {
|
||||
return Result.error("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateMysqlDataSource(DataSources dataSources) {
|
||||
int i = dataSourceMapper.updateById(dataSources);
|
||||
if (i > 0) {
|
||||
return Result.success("修改成功");
|
||||
} else {
|
||||
return Result.error("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteMysqlDataSource(Long id) {
|
||||
int i = dataSourceMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
return Result.success("删除成功");
|
||||
} else {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.*;
|
|||
public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSources> implements MysqlService {
|
||||
/**
|
||||
* 测试连接mysql
|
||||
*
|
||||
* @param druidReq
|
||||
* @return
|
||||
*/
|
||||
|
@ -197,9 +196,66 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (1 == druidReq.getData()) {
|
||||
insertDataExcludingId(druidReq, results);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void insertDataExcludingId(DruidReq druidReq, List<Map<String, Object>> results) {
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try {
|
||||
connection = getConnection(druidReq);
|
||||
|
||||
for (Map<String, Object> rowData : results) {
|
||||
// 获取列名并构建 SQL 语句
|
||||
List<String> columnNames = new ArrayList<>(rowData.keySet());
|
||||
columnNames.remove("id"); // 移除 id 列
|
||||
StringBuilder sql = new StringBuilder("INSERT INTO ");
|
||||
sql.append(druidReq.getDatabaseName()).append(".").append(druidReq.getTableName()).append(" (");
|
||||
for (int i = 0; i < columnNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append(columnNames.get(i));
|
||||
}
|
||||
sql.append(") VALUES (");
|
||||
|
||||
// 添加占位符
|
||||
for (int i = 0; i < columnNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
sql.append(", ");
|
||||
}
|
||||
sql.append("?");
|
||||
}
|
||||
sql.append(")");
|
||||
|
||||
preparedStatement = connection.prepareStatement(sql.toString());
|
||||
|
||||
// 填充数据并执行 INSERT
|
||||
int index = 1;
|
||||
for (String columnName : columnNames) {
|
||||
preparedStatement.setObject(index++, rowData.get(columnName));
|
||||
}
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
try {
|
||||
if (preparedStatement != null) preparedStatement.close();
|
||||
if (connection != null) connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private DataSource createDataSource(DruidReq druidReq) {
|
||||
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
|
||||
driverManagerDataSource.setDriverClassName(druidReq.getDriverClassName());
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package com.etl.database.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.etl.database.common.entity.*;
|
||||
import com.etl.database.common.entity.req.RuleReq;
|
||||
import com.etl.database.server.mapper.CodeMapper;
|
||||
import com.etl.database.server.mapper.RuleMapper;
|
||||
import com.etl.database.server.service.RuleService;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RuleServiceImpl extends MPJBaseServiceImpl<RuleMapper, Rule> implements RuleService {
|
||||
@Autowired
|
||||
private RuleMapper ruleMapper;
|
||||
|
||||
@Autowired
|
||||
private CodeMapper codeMapper;
|
||||
@Override
|
||||
public List<Rule> findRule(RuleReq ruleReq) {
|
||||
MPJLambdaWrapper<Rule> ruleMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
ruleMPJLambdaWrapper.select(Rule::getId, Rule::getRuleTypeId, Rule::getRuleName)
|
||||
.select(RuleType::getRuleTypeName)
|
||||
.select(CodeType::getCodeTypeName)
|
||||
.leftJoin(RuleType.class, RuleType::getId, Rule::getRuleTypeId)
|
||||
.leftJoin(Code.class, Code::getRuleId, Rule::getId)
|
||||
.leftJoin(CodeType.class, CodeType::getId, Code::getCodeTypeId);
|
||||
if (ruleReq.getRuleTypeId() != null) {
|
||||
ruleMPJLambdaWrapper.eq(Rule::getRuleTypeId, ruleReq.getRuleTypeId());
|
||||
}
|
||||
if (ruleReq.getCodeTypeId() != null) {
|
||||
ruleMPJLambdaWrapper.eq(Code::getCodeTypeId, ruleReq.getCodeTypeId());
|
||||
}
|
||||
Page<Rule> page = new Page<>(ruleReq.getPageNum(), ruleReq.getPageSize());
|
||||
IPage<Rule> ruleIPage = ruleMapper.selectJoinPage(page, Rule.class, ruleMPJLambdaWrapper);
|
||||
List<Rule> records = ruleIPage.getRecords();
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRule(Rule rule) {
|
||||
if (rule != null){
|
||||
ruleMapper.insert(rule);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRule(Rule rule) {
|
||||
if (rule != null){
|
||||
ruleMapper.updateById(rule);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRule(Long id) {
|
||||
if (id != null){
|
||||
ruleMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCode(Code code) {
|
||||
if (code != null){
|
||||
codeMapper.insert(code);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.etl.database.server.service.impl;
|
||||
|
||||
|
||||
import com.etl.database.common.entity.Task;
|
||||
import com.etl.database.server.mapper.TaskMapper;
|
||||
import com.etl.database.server.service.TaskService;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implements TaskService {
|
||||
@Autowired
|
||||
private TaskMapper taskMapper;
|
||||
|
||||
@Override
|
||||
public List<Task> findTask() {
|
||||
MPJLambdaWrapper<Task> taskMPJLambdaWrapper = new MPJLambdaWrapper<Task>()
|
||||
.selectAll(Task.class);
|
||||
return taskMapper.selectJoinList(Task.class, taskMPJLambdaWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(Task task) {
|
||||
taskMapper.insert(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask(Task task) {
|
||||
taskMapper.updateById(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTask(Long id) {
|
||||
taskMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task findTaskById(Long id) {
|
||||
return taskMapper.selectById(id);
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.DataSourceMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.MysqlMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.RedisMapper">
|
||||
|
||||
</mapper>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.DataSourceMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.MysqlMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.etl.database.server.mapper.RedisMapper">
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue