增加数据源的修改删除代码接口
parent
166f501ff0
commit
a8f02d8276
|
@ -11,19 +11,19 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-14:58
|
||||
* @ Version:1.0
|
||||
* @ Description:资产数据源
|
||||
* @author Lenovo
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "asset_data_source",autoResultMap = true)
|
||||
@TableName(value = "asset_data_source", autoResultMap = true)
|
||||
public class AssetDataSource extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
|
|
|
@ -11,19 +11,19 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-14:18
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库结构
|
||||
* @author Lenovo
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "children",autoResultMap = true)
|
||||
@TableName(value = "children", autoResultMap = true)
|
||||
public class Children extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
|
|
|
@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.source.domain.req.DataSourceQueryReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**u
|
||||
/**
|
||||
* u
|
||||
*
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
|
@ -21,11 +24,14 @@ import lombok.experimental.SuperBuilder;
|
|||
* @ Description:数据源
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "data_source",autoResultMap = true)
|
||||
public class DataSource {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "data_source", autoResultMap = true)
|
||||
public class DataSource extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
@ -36,13 +42,13 @@ public class DataSource {
|
|||
* 接入源名称
|
||||
*/
|
||||
@Excel(name = "接入源名称")
|
||||
@TableField ("name")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
@Excel(name = "数据来源系统名称")
|
||||
@TableField ("system_name")
|
||||
@TableField("system_name")
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
|
@ -130,4 +136,14 @@ public class DataSource {
|
|||
private Long maxWaitSize;
|
||||
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static DataSource queryBuild( DataSourceQueryReq dataSourceQueryReq){
|
||||
return DataSource.builder()
|
||||
.name(dataSourceQueryReq.getName())
|
||||
.systemName(dataSourceQueryReq.getSystemName())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-15:02
|
||||
* @ Version:1.0
|
||||
* @ Description:表结构
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "table_data",autoResultMap = true)
|
||||
@TableName(value = "table_data", autoResultMap = true)
|
||||
public class TableData extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package com.muyu.source.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-14:14
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源对象
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Tag(name = "数据源列表")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DataSourceEditReq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 接入源名称
|
||||
*/
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 数据连接参数
|
||||
*/
|
||||
|
||||
private String connectionParam;
|
||||
|
||||
/**
|
||||
* 是否初始化
|
||||
*/
|
||||
|
||||
private String isInit;
|
||||
|
||||
/**
|
||||
* 初始连接数量
|
||||
*/
|
||||
|
||||
private Long initTotal;
|
||||
|
||||
/**
|
||||
* 最大连接数量
|
||||
*/
|
||||
|
||||
private Long maxNum;
|
||||
|
||||
/**
|
||||
* 最大等待时间
|
||||
*/
|
||||
|
||||
private Long maxWaitTime;
|
||||
|
||||
/**
|
||||
* 最大等待次数
|
||||
*/
|
||||
|
||||
private Long maxWaitSize;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.source.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-14:17
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DataSourceQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 接入源名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
private String systemName;
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.source.controller;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.source.domain.DataSource;
|
||||
import com.muyu.source.domain.req.DataSourceQueryReq;
|
||||
import com.muyu.source.service.DataSourceService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
@ -33,18 +34,40 @@ public class DataSourceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 查询数据源的全部数据
|
||||
* @return
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@GetMapping("/getDataSourceList")
|
||||
public Result<List<DataSource>> list(){
|
||||
List<DataSource> list =dataSourceService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取数据
|
||||
* @param id 数据源ID
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("getDataSourceById/{id}")
|
||||
public Result<DataSource> getDataSourceById(@PathVariable("id") Long id){
|
||||
DataSource dataSource = dataSourceService.getById(id);
|
||||
return Result.success(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源列表的全部数据
|
||||
* @param dataSourceQueryReq 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<List<DataSource>> list(DataSourceQueryReq dataSourceQueryReq){
|
||||
List<DataSource> list =dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据源
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@PostMapping("/insert")
|
||||
public Result insert(@RequestBody DataSource dataSource){
|
||||
|
@ -54,8 +77,8 @@ public class DataSourceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 修改数据源
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result update(@RequestBody DataSource dataSource){
|
||||
|
@ -65,8 +88,8 @@ public class DataSourceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 删除数据源
|
||||
* @param dataSource
|
||||
* @return
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public Result delete(@RequestBody DataSource dataSource){
|
||||
|
@ -75,4 +98,6 @@ public class DataSourceController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface DataSourceService extends IService<DataSource> {
|
||||
|
||||
/**
|
||||
* 查询数据源的列表
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
|
||||
|
||||
List<DataSource> list(DataSource dataSource);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.source.service.Impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.source.domain.DataSource;
|
||||
import com.muyu.source.mapper.DataSourceMapper;
|
||||
import com.muyu.source.service.DataSourceService;
|
||||
|
@ -22,5 +23,21 @@ import java.util.List;
|
|||
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements DataSourceService {
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据源的列表
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> list(DataSource dataSource) {
|
||||
LambdaQueryWrapper<DataSource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if(StringUtils.isNotEmpty(dataSource.getName())){
|
||||
lambdaQueryWrapper.like(DataSource::getName,dataSource.getName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataSource.getSystemName())){
|
||||
lambdaQueryWrapper.like(DataSource::getSystemName,dataSource.getSystemName());
|
||||
}
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue