数据源业务

main
刘泽璋 2024-06-26 08:45:44 +08:00
parent 331d061358
commit cd64663e08
61 changed files with 1130 additions and 90 deletions

File diff suppressed because one or more lines are too long

View File

@ -73,10 +73,6 @@
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId> <artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version> <version>4.4.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@ -21,6 +21,10 @@
<artifactId>etl-common</artifactId> <artifactId>etl-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,21 @@
package com.etl.data.source.common.pojo;
import lombok.Data;
import java.util.Date;
/**
*/
@Data
public class BaseEntity {
private Long createBy;
private Date createTime;
private Long updateBy;
private Date updateTime;
private Integer isDelete;
}

View File

@ -0,0 +1,14 @@
package com.etl.data.source.common.pojo;
import lombok.Data;
/**
*
*/
@Data
public class Code {
private Integer id;
private String codeContent;
private Integer codeTypeId;
private Integer ruleId;
}

View File

@ -0,0 +1,14 @@
package com.etl.data.source.common.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*/
@Data
@TableName("code_type")
public class CodeType {
private Integer id; // 主键ID自增长
private String codeTypeName; // 编码类型名称
}

View File

@ -0,0 +1,54 @@
package com.etl.data.source.common.pojo;
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 javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@TableName("data_source")
public class DataSource{
@TableId(type = IdType.AUTO)
private Long id;
@NotNull(message = "数据源id不能为空")
private Long dataSourceId;
@NotEmpty(message = "数据源描述不能为空")
private String dataSourceDescribe;
@NotEmpty(message = "数据源连接地址不能为空")
private String linkAddress;
@NotEmpty(message = "数据源用户名不能为空")
private String userName;
@NotEmpty(message = "数据源密码不能为空")
private String password;
@NotNull(message = "数据源端口不能为空")
private Integer connectionPort;
private String connectionDatabaseName;
@NotEmpty(message = "数据源驱动不能为空")
private String extraConfig;
@NotNull(message = "数据源状态不能为空")
private Integer status;
@NotEmpty(message = "数据源备注不能为空")
private String remark;
private Integer dataSourceType;
@TableField(exist = false)
private String dataSourceTypeName;
}

View File

@ -0,0 +1,21 @@
package com.etl.data.source.common.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@TableName("data_source_type")
public class DataSourceType {
@NotNull(message = "id不能为空")
private int id;
@NotBlank(message = "数据源类型不能为空")
private String dataSourceTypeName;
}

View File

@ -0,0 +1,23 @@
package com.etl.data.source.common.pojo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*/
@Data
@TableName("rule")
public class Rule {
private Integer id; // 规则ID
private String ruleId; // 规则编号
private String ruleName; // 规则名称
private Integer ruleTypeId; // 规则类型ID
private Integer status; // 状态
@TableField(exist = false)
private Integer codeTypeId; // 编码类型ID
private String classPath; // 类路径
private Integer publicWay; // 公开方式
}

View File

@ -0,0 +1,13 @@
package com.etl.data.source.common.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*/
@Data
@TableName("rule_type")
public class RuleType {
private Integer id; // 主键ID自增长
private String ruleTypeName; // 规则类型名称
}

View File

@ -0,0 +1,52 @@
package com.etl.data.source.common.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
*
*/
@Data
@NoArgsConstructor
@ApiModel(value = "Task", description = "任务实体类")
public class Task {
@ApiModelProperty(value = "主键ID", example = "1")
private Integer id;
@ApiModelProperty(value = "任务名称", example = "完成订单")
private String taskName;
@ApiModelProperty(value = "任务ID", example = "T12345")
private String taskId;
@ApiModelProperty(value = "权重1紧急, 2高, 3中, 4低", example = "1")
private Integer taskWeight;
@ApiModelProperty(value = "状态1执行中, 2暂停", example = "1")
private Integer status;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "创建人ID", example = "1001")
private Integer createBy;
@ApiModelProperty(value = "创建时间", example = "2023-03-15T10:15:30")
private Date createTime;
@ApiModelProperty(value = "修改人ID", example = "1002")
private Integer updateBy;
@ApiModelProperty(value = "修改时间", example = "2023-03-16T12:30:00")
private Date updateTime;
@ApiModelProperty(value = "是否删除0未删除, 1已删除", example = "0")
private Integer isDelete;
}

View File

@ -0,0 +1,35 @@
package com.etl.data.source.common.pojo;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
public class TaskManagerEntity extends BaseEntity{
@NotNull(message = "id不能为空")
private int id;
@NotEmpty(message = "任务名称不能为空")
private String taskName;
@NotEmpty(message = "任务id不能为空")
private String taskId;
@NotEmpty(message = "任务code不能为空")
private int taskCode;
@NotEmpty(message = "任务权重不能为空")
private int taskWeight;
@NotEmpty(message = "任务状态不能为空")
private int status;
@NotEmpty(message = "任务备注不能为空")
private String remark;
}

View File

@ -0,0 +1,135 @@
package com.etl.data.source.common.pojo.constants;
/**
*
*
* @author ruoyi
*/
public class Constants
{
/**
* UTF-8
*/
public static final String UTF8 = "UTF-8";
/**
* GBK
*/
public static final String GBK = "GBK";
/**
* www
*/
public static final String WWW = "www.";
/**
* RMI
*/
public static final String LOOKUP_RMI = "rmi:";
/**
* LDAP
*/
public static final String LOOKUP_LDAP = "ldap:";
/**
* LDAPS
*/
public static final String LOOKUP_LDAPS = "ldaps:";
/**
* http
*/
public static final String HTTP = "http://";
/**
* https
*/
public static final String HTTPS = "https://";
/**
*
*/
public static final Integer SUCCESS = 200;
/**
*
*/
public static final Integer FAIL = 500;
/**
*
*/
public static final String LOGIN_SUCCESS_STATUS = "0";
/**
*
*/
public static final String LOGIN_FAIL_STATUS = "1";
/**
*
*/
public static final String LOGIN_SUCCESS = "Success";
/**
*
*/
public static final String LOGOUT = "Logout";
/**
*
*/
public static final String REGISTER = "Register";
/**
*
*/
public static final String LOGIN_FAIL = "Error";
/**
*
*/
public static final String PAGE_NUM = "pageNum";
/**
*
*/
public static final String PAGE_SIZE = "pageSize";
/**
*
*/
public static final String ORDER_BY_COLUMN = "orderByColumn";
/**
* "desc" "asc".
*/
public static final String IS_ASC = "isAsc";
/**
*
*/
public static final long CAPTCHA_EXPIRATION = 2;
/**
*
*/
public static final String RESOURCE_PREFIX = "/profile";
/**
* json
*/
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
/**
* 访
*/
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi.job.task" };
/**
*
*/
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.ruoyi.common.core.utils.file" };
}

View File

@ -0,0 +1,15 @@
package com.etl.data.source.common.pojo.req;
import com.etl.data.source.common.pojo.DataSource;
import lombok.Data;
/**
* @ClassName DataSourceColumn
* @Description
* @Author TingTing.Yao
* @Date 2024/06/21 21:40
*/
@Data
public class DataSourceColumn extends DataSource {
private String tableName;
}

View File

@ -0,0 +1,24 @@
package com.etl.data.source.common.pojo.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName DateSourceReq
* @Description
* @Author TingTing.Yao
* @Date 2024/06/23 10:02
*/
@Data
@ApiModel("查询数据源")
public class DataSourceReq {
@ApiModelProperty("页码")
private Integer pageNum=1;
@ApiModelProperty("每页条数")
private Integer pageSize=3;
@ApiModelProperty("数据源描述")
private String dataSourceDescribe;
@ApiModelProperty("数据源类型")
private Integer dataSourceType;
}

View File

@ -0,0 +1,16 @@
package com.etl.data.source.common.pojo.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;
}

View File

@ -0,0 +1,117 @@
package com.etl.data.source.common.pojo.until;
import com.etl.common.constants.Constants;
import java.io.Serializable;
/**
*
*
* @author ruoyi
*/
public class R<T> implements Serializable
{
private static final long serialVersionUID = 1L;
/** 成功 */
public static final int SUCCESS = Constants.SUCCESS;
/** 失败 */
public static final int FAIL = Constants.ERROR;
private int code;
private String msg;
private T data;
public static <T> R<T> ok()
{
return restResult(null, SUCCESS, null);
}
public static <T> R<T> ok(T data)
{
return restResult(data, SUCCESS, null);
}
public static <T> R<T> ok(T data, String msg)
{
return restResult(data, SUCCESS, msg);
}
public static <T> R<T> fail()
{
return restResult(null, FAIL, null);
}
public static <T> R<T> fail(String msg)
{
return restResult(null, FAIL, msg);
}
public static <T> R<T> fail(T data)
{
return restResult(data, FAIL, null);
}
public static <T> R<T> fail(T data, String msg)
{
return restResult(data, FAIL, msg);
}
public static <T> R<T> fail(int code, String msg)
{
return restResult(null, code, msg);
}
private static <T> R<T> restResult(T data, int code, String msg)
{
R<T> apiResult = new R<T>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public T getData()
{
return data;
}
public void setData(T data)
{
this.data = data;
}
public static <T> Boolean isError(R<T> ret)
{
return !isSuccess(ret);
}
public static <T> Boolean isSuccess(R<T> ret)
{
return R.SUCCESS == ret.getCode();
}
}

View File

@ -16,6 +16,10 @@
<spring-boot.version>2.6.13</spring-boot.version> <spring-boot.version>2.6.13</spring-boot.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.bwie</groupId> <groupId>com.bwie</groupId>
<artifactId>el-data-source-common</artifactId> <artifactId>el-data-source-common</artifactId>
@ -72,6 +76,11 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.3.8</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View File

@ -1,9 +1,11 @@
package com.etl.data.source.server; package com.etl.data.source.server;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
@MapperScan("com.etl.data.source.server.mapper")
public class ElDataSourceServerApplication { public class ElDataSourceServerApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -0,0 +1,19 @@
package com.etl.data.source.server.controller;
import com.etl.data.source.server.service.DataSheetService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName DataSheetController
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 20:35
*/
@RestController
@Api(tags = "节点操作")
public class DataSheetController {
@Autowired
private DataSheetService dataSheetService;
}

View File

@ -0,0 +1,55 @@
package com.etl.data.source.server.controller;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.req.DataSourceReq;
import com.etl.data.source.common.pojo.until.R;
import com.etl.data.source.server.service.DataSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @ClassName DataSourceController
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 14:29
*/
@RestController
@Api(tags = "数据源操作")
public class DataSourceController {
@Autowired
private DataSourceService databaseService;
@PostMapping("/findDataSource")
@ApiOperation(value = "查询数据源")
public R findDateSource(@RequestBody @Valid DataSourceReq dataSourceReq) {
return databaseService.findDateSource(dataSourceReq);
}
@PostMapping("/addMysqlDataSource")
@ApiOperation(value = "添加数据源")
public R addMysqlDataSource(@RequestBody @Valid DataSource dataSource) {
return databaseService.addMysqlDataSource(dataSource);
}
@PutMapping("/updateMysqlDataSource")
@ApiOperation(value = "修改数据源")
public R updateMysqlDataSource(@RequestBody @Valid DataSource dataSource) {
return databaseService.updateMysqlDataSource(dataSource);
}
@DeleteMapping("deleteMysqlDataSource")
@ApiOperation(value = "删除数据源")
public R deleteMysqlDataSource(@RequestParam("id") Long id) {
return databaseService.deleteMysqlDataSource(id);
}
@GetMapping("/findDataSourceType")
@ApiOperation(value = "查询数据源类型")
public R findDataSourceType() {
return databaseService.findDataSourceType();
}
}

View File

@ -10,9 +10,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; 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.PostMapping; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
@ -21,14 +20,14 @@ import java.util.Map;
// 声明为一个 Spring Boot 控制器 // 声明为一个 Spring Boot 控制器
@RestController @RestController
@Api(tags = "数据源") @Api(tags = "数据源连接")
@Slf4j @Slf4j
public class DatabaseController { public class DatabaseController {
@Autowired @Autowired
private DatabaseService databaseService; private DatabaseService databaseService;
@PostMapping("/testDatabaseRedis") @PostMapping("/testDatabaseRedis")
@ApiOperation(value = "测试redis连接") @ApiOperation(value = "测试redis连接")
@Limit(key = "testDatabaseRedis", permitsPerSecond = 1, timeout = 500, msg = "当前排队人数较多,请稍后再试!")
public Result<Map<String,String>> testDatabaseRedis(@Valid @RequestBody DatabaseRedis databaseRedis) { public Result<Map<String,String>> testDatabaseRedis(@Valid @RequestBody DatabaseRedis databaseRedis) {
Map<String,String> map = databaseService.testDatabaseRedis(databaseRedis); Map<String,String> map = databaseService.testDatabaseRedis(databaseRedis);
return Result.success(map); return Result.success(map);
@ -61,5 +60,4 @@ public class DatabaseController {
return Result.success(databaseService.findDatabaseTableField(config)); return Result.success(databaseService.findDatabaseTableField(config));
} }
} }

View File

@ -0,0 +1,49 @@
package com.etl.data.source.server.controller;
import com.etl.common.result.Result;
import com.etl.data.source.common.pojo.Task;
import com.etl.data.source.server.service.TaskService;
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;
/**
* @ClassName TaskController
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 20:59
*/
@RestController
@Api("任务模块")
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){
return Result.success(taskService.addTask(task));
}
@PostMapping("/updateTask")
@ApiOperation("修改任务")
public Result<String> updateTask(@RequestBody Task task){
return Result.success(taskService.updateTask(task));
}
@DeleteMapping("/deleteTask/{id}")
@ApiOperation("删除任务")
public Result<String> deleteTask(@PathVariable Long id){
return Result.success(taskService.deleteTask(id));
}
@GetMapping("/findTaskById/{id}")
@ApiOperation("根据id查询任务")
public Result<Task> findTaskById(@PathVariable Long id){
return Result.success(taskService.findTaskById(id));
}
}

View File

@ -0,0 +1,10 @@
package com.etl.data.source.server.mapper;
/**
* @ClassName DataSheetMapper
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 20:37
*/
public interface DataSheetMapper {
}

View File

@ -0,0 +1,14 @@
package com.etl.data.source.server.mapper;
import com.etl.data.source.common.pojo.DataSource;
import com.github.yulichang.base.MPJBaseMapper;
/**
* @ClassName DataSourceBaseMapper
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 14:19
*/
public interface DataSourceBaseMapper extends MPJBaseMapper<DataSource> {
}

View File

@ -0,0 +1,13 @@
package com.etl.data.source.server.mapper;
import com.etl.data.source.common.pojo.DataSourceType;
import com.github.yulichang.base.MPJBaseMapper;
/**
* @ClassName DataSourceTypeBaseMapper
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 14:22
*/
public interface DataSourceTypeBaseMapper extends MPJBaseMapper<DataSourceType> {
}

View File

@ -0,0 +1,14 @@
package com.etl.data.source.server.mapper;
import com.etl.data.source.common.pojo.DataSourceType;
import com.etl.data.source.common.pojo.Task;
import com.github.yulichang.base.MPJBaseMapper;
/**
* @ClassName TaskMapper
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/26 8:36
*/
public interface TaskMapper extends MPJBaseMapper<Task> {
}

View File

@ -0,0 +1,10 @@
package com.etl.data.source.server.service;
/**
* @ClassName DataSheetService
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 20:36
*/
public interface DataSheetService {
}

View File

@ -0,0 +1,24 @@
package com.etl.data.source.server.service;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.req.DataSourceReq;
import com.etl.data.source.common.pojo.until.R;
import com.github.yulichang.base.MPJBaseService;
/**
* @ClassName DataSourceService
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 14:30
*/
public interface DataSourceService extends MPJBaseService<DataSource> {
R findDateSource(DataSourceReq dataSourceReq);
R addMysqlDataSource(DataSource dataSource);
R updateMysqlDataSource(DataSource dataSource);
R deleteMysqlDataSource(Long id);
R findDataSourceType();
}

View File

@ -1,8 +1,13 @@
package com.etl.data.source.server.service; package com.etl.data.source.server.service;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.DatabaseConfig; import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.DatabaseRedis; import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.req.DataSourceColumn;
import com.etl.data.source.common.pojo.req.DataSourceReq;
import com.etl.data.source.common.pojo.resq.ColumnInfo; import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.common.pojo.until.R;
import com.github.yulichang.base.MPJBaseService;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,4 +28,5 @@ public interface DatabaseService {
List<ColumnInfo> findDatabaseTableField(DatabaseConfig config); List<ColumnInfo> findDatabaseTableField(DatabaseConfig config);
Map<String, String> testDatabaseRedis(DatabaseRedis databaseRedis); Map<String, String> testDatabaseRedis(DatabaseRedis databaseRedis);
} }

View File

@ -0,0 +1,24 @@
package com.etl.data.source.server.service;
import com.etl.data.source.common.pojo.Task;
import java.util.List;
/**
* @ClassName TaskService
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/26 8:35
*/
public interface TaskService {
List<Task> findTask();
String addTask(Task task);
String updateTask(Task task);
String deleteTask(Long id);
Task findTaskById(Long id);
}

View File

@ -0,0 +1,18 @@
package com.etl.data.source.server.service.impl;
import com.etl.data.source.server.mapper.DataSheetMapper;
import com.etl.data.source.server.service.DataSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @ClassName DataSheetServiceImpl
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 20:36
*/
@Service
public class DataSheetServiceImpl implements DataSheetService {
@Autowired
private DataSheetMapper dataSheetMapper;
}

View File

@ -0,0 +1,87 @@
package com.etl.data.source.server.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.DataSourceType;
import com.etl.data.source.common.pojo.req.DataSourceReq;
import com.etl.data.source.common.pojo.until.R;
import com.etl.data.source.server.mapper.DataSourceBaseMapper;
import com.etl.data.source.server.mapper.DataSourceTypeBaseMapper;
import com.etl.data.source.server.service.DataSourceService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName DataSourceServiceImpl
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/25 14:33
*/
@Service
public class DataSourceServiceImpl extends MPJBaseServiceImpl<DataSourceBaseMapper, DataSource> implements DataSourceService {
@Autowired
private DataSourceBaseMapper dataSourceBaseMapper;
@Autowired
private DataSourceTypeBaseMapper dataSourceTypeBaseMapper;
@Override
public R findDateSource(DataSourceReq dataSourceReq) {
MPJLambdaWrapper<DataSource> dataSourceMPJLambdaWrapper = new MPJLambdaWrapper<DataSource>();
dataSourceMPJLambdaWrapper.selectAll(DataSource.class)
.select(DataSourceType::getDataSourceTypeName)
.leftJoin(DataSourceType.class, DataSourceType::getId, DataSource::getDataSourceType);
if (dataSourceReq.getDataSourceDescribe()!=null && !dataSourceReq.getDataSourceDescribe().isEmpty()){
dataSourceMPJLambdaWrapper.like(DataSource::getDataSourceDescribe,dataSourceReq.getDataSourceDescribe());
}
if (dataSourceReq.getDataSourceType()!=null){
dataSourceMPJLambdaWrapper.eq(DataSource::getDataSourceType,dataSourceReq.getDataSourceType());
}
Page<DataSource> page = new Page<>(dataSourceReq.getPageNum(),dataSourceReq.getPageSize());
IPage<DataSource> dataSourceReqIPage = dataSourceBaseMapper.selectJoinPage(page, DataSource.class, dataSourceMPJLambdaWrapper);
List<DataSource> records = dataSourceReqIPage.getRecords();
return R.ok(records);
}
@Override
public R addMysqlDataSource(DataSource dataSource) {
int insert = dataSourceBaseMapper.insert(dataSource);
if (insert > 0) {
return R.ok("添加成功");
} else {
return R.fail("添加失败");
}
}
@Override
public R updateMysqlDataSource(DataSource dataSource) {
int i = dataSourceBaseMapper.updateById(dataSource);
if (i > 0) {
return R.ok("修改成功");
} else{
return R.fail("修改失败");
}
}
@Override
public R deleteMysqlDataSource(Long id) {
int i = dataSourceBaseMapper.deleteById(id);
if (i > 0) {
return R.ok("删除成功");
} else{
return R.fail("删除失败");
}
}
@Override
public R findDataSourceType() {
MPJLambdaWrapper<DataSourceType> dataSourceTypeMPJLambdaWrapper = new MPJLambdaWrapper<DataSourceType>()
.selectAll(DataSourceType.class);
List<DataSourceType> dataSourceTypes = dataSourceTypeBaseMapper.selectJoinList(DataSourceType.class, dataSourceTypeMPJLambdaWrapper);
return R.ok(dataSourceTypes);
}
}

View File

@ -6,7 +6,10 @@ import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.constants.MysqlConstants; import com.etl.data.source.common.pojo.constants.MysqlConstants;
import com.etl.data.source.common.pojo.resq.ColumnInfo; import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.server.config.RedisConfig; import com.etl.data.source.server.config.RedisConfig;
import com.etl.data.source.server.mapper.DataSourceBaseMapper;
import com.etl.data.source.server.mapper.DataSourceTypeBaseMapper;
import com.etl.data.source.server.service.DatabaseService; import com.etl.data.source.server.service.DatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -27,6 +30,11 @@ import java.util.*;
*/ */
@Service @Service
public class DatabaseServiceImpl implements DatabaseService { public class DatabaseServiceImpl implements DatabaseService {
@Autowired
private DataSourceBaseMapper dataSourceBaseMapper;
@Autowired
private DataSourceTypeBaseMapper dataSourceTypeBaseMapper;
@Override @Override
public String testDatabaseConnection(DatabaseConfig config) { public String testDatabaseConnection(DatabaseConfig config) {
try { try {
@ -199,7 +207,6 @@ public class DatabaseServiceImpl implements DatabaseService {
return allData; return allData;
} }
private static Connection getConnection(DatabaseConfig config) throws ClassNotFoundException, SQLException { private static Connection getConnection(DatabaseConfig config) throws ClassNotFoundException, SQLException {
// 加载MySQL驱动 // 加载MySQL驱动
Class.forName(config.getDriverClassName()); Class.forName(config.getDriverClassName());

View File

@ -0,0 +1,56 @@
package com.etl.data.source.server.service.impl;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.DataSourceType;
import com.etl.data.source.common.pojo.Task;
import com.etl.data.source.server.mapper.DataSourceBaseMapper;
import com.etl.data.source.server.mapper.TaskMapper;
import com.etl.data.source.server.service.TaskService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName TaskServiceImpl
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/26 8:36
*/
@Service
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 String addTask(Task task) {
int insert = taskMapper.insert(task);
return insert > 0 ? "添加成功" : "添加失败";
}
@Override
public String updateTask(Task task) {
int update = taskMapper.updateById(task);
return update > 0 ? "修改成功" : "修改失败";
}
@Override
public String deleteTask(Long id) {
int delete = taskMapper.deleteById(id);
return delete > 0 ? "删除成功" : "删除失败";
}
@Override
public Task findTaskById(Long id) {
return taskMapper.selectById(id);
}
}

View File

@ -3,6 +3,11 @@ server:
port: 8886 port: 8886
# Spring # Spring
spring: spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://182.254.221.163:3306/etl
username: root
password: lzz@123
redis: redis:
host: 127.0.0.1 host: 127.0.0.1
port: 6379 port: 6379
@ -28,4 +33,8 @@ spring:
server-addr: 182.254.221.163:8848 server-addr: 182.254.221.163:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
type-aliases-package: com.etl.data.source.common.pojo
mapper-locations: classpath:mappers/*xml

View File

@ -3,6 +3,11 @@ server:
port: 8886 port: 8886
# Spring # Spring
spring: spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://182.254.221.163:3306/etl
username: root
password: lzz@123
redis: redis:
host: 127.0.0.1 host: 127.0.0.1
port: 6379 port: 6379
@ -28,4 +33,8 @@ spring:
server-addr: 182.254.221.163:8848 server-addr: 182.254.221.163:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
type-aliases-package: com.etl.data.source.common.pojo
mapper-locations: classpath:mappers/*xml

View File

@ -22,7 +22,7 @@
<spring-boot.version>2.6.13</spring-boot.version> <spring-boot.version>2.6.13</spring-boot.version>
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version> <spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
<spring-cloud-bootstrap>3.1.3</spring-cloud-bootstrap> <spring-cloud-bootstrap>3.1.3</spring-cloud-bootstrap>
<mybits-plus-version>3.5.1</mybits-plus-version> <mybits-plus-version>3.5.2</mybits-plus-version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>