master
parent
ae35c4a607
commit
cd276e0a8a
|
@ -13,6 +13,12 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName AssetAccreditController
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/28 14:30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("assetAccredit")
|
||||
public class AssetAccreditController extends BaseController {
|
||||
|
@ -45,10 +51,10 @@ public class AssetAccreditController extends BaseController {
|
|||
public Result add(@RequestBody AssetAccreditReq assetAccreditReq){
|
||||
return assetAccreditService.insertAssetAccredit(assetAccreditReq);
|
||||
}
|
||||
@PostMapping("/DeleteAssetAccreditByAsserIds")
|
||||
@PostMapping("/DeleteAssetAccreditByAssetIds")
|
||||
public Result deleteAssetAccreditByAsserIds(@RequestBody AssetAccreditReq assetAccreditReq)
|
||||
{
|
||||
return assetAccreditService.deleteAssetAccreditByAssetId(assetAccreditReq);
|
||||
return assetAccreditService.deleteAssetAccreditByAssetIds(assetAccreditReq);
|
||||
}
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody AssetAccredit assetAccredit){
|
||||
|
|
|
@ -53,6 +53,7 @@ public class AssetModelController extends BaseController
|
|||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
||||
return success(assetModelService.selectAssetModelById(id));
|
||||
}
|
||||
|
||||
|
@ -83,4 +84,11 @@ public class AssetModelController extends BaseController
|
|||
{
|
||||
return toAjax(assetModelService.deleteAssetModelByIds(ids));
|
||||
}
|
||||
/**
|
||||
* 更新资产模型信息
|
||||
*
|
||||
* @param assetModel 资产模型对象,包含需要更新的资产模型信息
|
||||
* @return 返回更新操作的结果,成功返回Result.success,失败返回Result.fail
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,25 @@
|
|||
package com.muyu.etl.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.etl.domain.DataAsset;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import com.muyu.etl.service.DataSourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 【数据源】Controller
|
||||
|
@ -30,7 +37,7 @@ public class DataSourceController extends BaseController
|
|||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@RequiresPermissions("system:source:list")
|
||||
// @RequiresPermissions("system:source:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DataSource>> list(DataSource dataSource)
|
||||
{
|
||||
|
@ -111,7 +118,6 @@ public class DataSourceController extends BaseController
|
|||
public Result synchronization(@RequestBody DataSource dataSource){
|
||||
return dataSourceService.synchronization(dataSource);
|
||||
}
|
||||
|
||||
@PostMapping("dataAssetList")
|
||||
public Result dataAssetList(@RequestBody DataSource dataSource){
|
||||
return dataSourceService.dataAssetList(dataSource);
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
import com.muyu.etl.domain.Dictionary;
|
||||
import com.muyu.etl.service.DictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -14,10 +14,10 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sourceAccredit")
|
||||
public class SourceAccreditController extends BaseController
|
||||
{
|
||||
public class SourceAccreditController extends BaseController {
|
||||
@Autowired
|
||||
private SourceAccreditService sourceAccreditService;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.etl.domain;
|
|||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
@ -14,6 +15,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AssetAccredit extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
|
@ -33,40 +35,32 @@ public class AssetAccredit extends BaseEntity {
|
|||
private Long userId;
|
||||
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setDeptId(Long deptId)
|
||||
{
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
public void setDataAssetId(Long dataAssetId)
|
||||
{
|
||||
public void setDataAssetId(Long dataAssetId) {
|
||||
this.dataAssetId = dataAssetId;
|
||||
}
|
||||
|
||||
public Long getDataAssetId()
|
||||
{
|
||||
public Long getDataAssetId() {
|
||||
return dataAssetId;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
|
@ -84,4 +78,5 @@ public class AssetAccredit extends BaseEntity {
|
|||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,137 +8,43 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName AssetModel
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/22 19:39
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AssetModel extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long dataAssetId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String comment;
|
||||
|
||||
private String isPrimaryKey;
|
||||
|
||||
private String type;
|
||||
|
||||
private String mappingType;
|
||||
|
||||
private String length;
|
||||
|
||||
private String decimalPlaces;
|
||||
|
||||
private String isNull;
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
private String isDict;
|
||||
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 字典ID
|
||||
*/
|
||||
private Long dictionaryId;
|
||||
|
||||
private List<DictionaryData> dictionaryDatas;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getDataAssetId() {
|
||||
return dataAssetId;
|
||||
}
|
||||
|
||||
public void setDataAssetId(Long dataAssetId) {
|
||||
this.dataAssetId = dataAssetId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getIsPrimaryKey() {
|
||||
return isPrimaryKey;
|
||||
}
|
||||
|
||||
public void setIsPrimaryKey(String isPrimaryKey) {
|
||||
this.isPrimaryKey = isPrimaryKey;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMappingType() {
|
||||
return mappingType;
|
||||
}
|
||||
|
||||
public void setMappingType(String mappingType) {
|
||||
this.mappingType = mappingType;
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public String getDecimalPlaces() {
|
||||
return decimalPlaces;
|
||||
}
|
||||
|
||||
public void setDecimalPlaces(String decimalPlaces) {
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
}
|
||||
|
||||
public String getIsNull() {
|
||||
return isNull;
|
||||
}
|
||||
|
||||
public void setIsNull(String isNull) {
|
||||
this.isNull = isNull;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getIsDict() {
|
||||
return isDict;
|
||||
}
|
||||
|
||||
public void setIsDict(String isDict) {
|
||||
this.isDict = isDict;
|
||||
}
|
||||
|
||||
public String getDictKey() {
|
||||
return dictKey;
|
||||
}
|
||||
|
||||
public void setDictKey(String dictKey) {
|
||||
this.dictKey = dictKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,20 @@ import java.util.Map;
|
|||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class AssetsModule {
|
||||
|
||||
private HashMap<String,String> structure;
|
||||
|
||||
private List<Map<String,VTClass>> kvtList;
|
||||
|
||||
private List<TableAssets> tableAssets;
|
||||
|
||||
private TableDetail tableDetail;
|
||||
|
||||
public AssetsModule assetsModuleBuilder( List<Map<String,VTClass>> kvtList, HashMap<String,String> map) {
|
||||
return AssetsModule.builder()
|
||||
.kvtList(kvtList)
|
||||
.structure(map)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,36 +8,50 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName DataAsset
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/22 20:41
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DataAsset extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long dataSourceId;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String tableComment;
|
||||
|
||||
private Long tableCount;
|
||||
|
||||
private Long fields;
|
||||
|
||||
public DataAsset dataAsset(DataAsset dataAsset , ResultSet resultSet){
|
||||
/**
|
||||
* 根据给定的数据源和结果集构建数据资产对象。
|
||||
*
|
||||
* @param dataSource 数据源对象,用于标识数据资产的来源。
|
||||
* @param resultSet 结果集对象,包含了从数据库查询到的数据资产信息。
|
||||
* @return 构建完成的数据资产对象。
|
||||
*/
|
||||
public DataAsset dataAssetBuilder(DataSource dataSource , ResultSet resultSet) {
|
||||
try {
|
||||
// 从结果集中提取数据,并使用DataAsset的builder模式构建数据资产对象
|
||||
return DataAsset.builder()
|
||||
.id(dataAsset.getId())
|
||||
.dataSourceId(dataAsset.getDataSourceId())
|
||||
.tableName(dataAsset.getTableName())
|
||||
.tableComment(dataAsset.getTableComment())
|
||||
.tableCount(dataAsset.getTableCount())
|
||||
.fields(dataAsset.getFields())
|
||||
.updateBy(SecurityUtils.getUsername())
|
||||
.updateTime(new Date())
|
||||
.tableName(resultSet.getString("t_name"))
|
||||
.tableComment(resultSet.getString("table_comment")==null ? "" : resultSet.getString("table_comment"))
|
||||
.tableCount(Long.valueOf(resultSet.getString("table_rows")))
|
||||
.fields(Long.valueOf(resultSet.getString("fields")))
|
||||
.dataSourceId(dataSource.getId())
|
||||
.createBy(SecurityUtils.getUsername())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}catch (SQLException e){
|
||||
// 捕获并抛出SQL异常为运行时异常
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,23 +13,43 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DataSource extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String port;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String LinkAddress;
|
||||
|
||||
private String dataSourceName;
|
||||
|
||||
private String databaseName;
|
||||
|
||||
private Long initNum;
|
||||
|
||||
private Long maxNum;
|
||||
|
||||
private Long maxWaitSize;
|
||||
|
||||
private Long maxWaitTime;
|
||||
|
||||
private String connectionParam;
|
||||
|
||||
private String systemName;
|
||||
|
||||
private String sql;
|
||||
|
||||
private String type;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private List<TableDetail> tableList;
|
||||
|
||||
private String modeName;
|
||||
|
||||
private String jdbcDriver;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,34 +7,34 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Dictionary
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/25 15:02
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Dictionary extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictionaryName;
|
||||
|
||||
/**
|
||||
* 字典Key
|
||||
*/
|
||||
private String dictionaryKey;
|
||||
|
||||
/**
|
||||
* 数据源ID
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 字典集合
|
||||
*/
|
||||
private List<DictionaryData> dictionaryDataList;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,33 +7,33 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DictionaryData
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/25 15:05
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DictionaryData extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典表Id
|
||||
*/
|
||||
private Long dictionaryId;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String val;
|
||||
|
||||
private List<Dictionary> dictionaryDatas;
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
|
||||
private Boolean isEdit = false;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class SourceAccredit extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
|
@ -33,13 +34,11 @@ public class SourceAccredit extends BaseEntity {
|
|||
private Long userId;
|
||||
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -59,13 +58,11 @@ public class SourceAccredit extends BaseEntity {
|
|||
this.dataSourceId = dataSourceId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
|
@ -83,4 +80,5 @@ public class SourceAccredit extends BaseEntity {
|
|||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,15 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class TableAssets {
|
||||
|
||||
private String Field;
|
||||
|
||||
private String Type;
|
||||
|
||||
private String Null;
|
||||
|
||||
private String Key;
|
||||
|
||||
private String Default;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,13 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableDetail {
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String tableComment;
|
||||
|
||||
private Long tableCount;
|
||||
|
||||
private List<TableAssets> tableAssets;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class VTClass {
|
||||
|
||||
private String value;
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,23 +5,17 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Statistics {
|
||||
|
||||
/**
|
||||
* 数据资产ID
|
||||
*/
|
||||
// 数据资产ID
|
||||
private Long dataAsset;
|
||||
|
||||
/**
|
||||
* 资产模型ID
|
||||
*/
|
||||
// 资产模型ID
|
||||
private Long assetModel;
|
||||
|
||||
/**
|
||||
* 数据模型ID
|
||||
*/
|
||||
// 数据模型ID
|
||||
private Long dataModel;
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AccreditModel {
|
||||
|
||||
/**
|
||||
* 用于存储与用户认证相关的模型ID
|
||||
*/
|
||||
|
@ -21,4 +22,5 @@ public class AccreditModel {
|
|||
* 用于存储与部门认证相关的模型ID
|
||||
*/
|
||||
private List<Long> deptAccreditModelIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -8,11 +8,15 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
public class AssetAccreditReq {
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long dataAssetId;
|
||||
|
||||
}
|
||||
|
|
|
@ -8,11 +8,15 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SourceAccreditReq {
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long dataSourceId;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,14 @@ import com.muyu.etl.domain.AssetAccredit;
|
|||
import com.muyu.etl.domain.req.AssetAccreditReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AssetAccreditMapper {
|
||||
|
||||
List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit);
|
||||
|
||||
public AssetAccredit selectAssetAccreditById(Long id);
|
||||
|
@ -28,4 +31,7 @@ public interface AssetAccreditMapper {
|
|||
List<AssetAccredit> getSourceAccreditByUserId(Long userId);
|
||||
|
||||
void insertBachAssetAccredit(@Param("assetAccredits") List<AssetAccredit> assetAccredits);
|
||||
|
||||
void deleteAssetAccreditByUser(List<Long> longs, Long dataAssetId);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import java.util.List;
|
|||
* @date 2024-04-22
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssetModelMapper
|
||||
{
|
||||
public interface AssetModelMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -63,10 +63,10 @@ public interface AssetModelMapper
|
|||
*/
|
||||
public int deleteAssetModelByIds(Long[] ids);
|
||||
|
||||
|
||||
|
||||
int clearTable1(@Param("id") Long[] id);
|
||||
|
||||
void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets);
|
||||
|
||||
void updateAssetModelDiction(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.List;
|
|||
* @date 2024-04-22
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataAssetMapper
|
||||
{
|
||||
public interface DataAssetMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -65,7 +65,9 @@ public interface DataAssetMapper
|
|||
public int deleteDataAssetByIds(Long[] ids);
|
||||
|
||||
void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets);
|
||||
|
||||
List<DataAsset> selectById(Long id);
|
||||
|
||||
List<DataAsset> getDataAssetByAssetId(@Param("assetIds") List<Long> assetIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package com.muyu.etl.mapper;
|
||||
|
||||
import com.muyu.etl.domain.AssetModel;
|
||||
import com.muyu.etl.domain.DataAsset;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.etl.domain.AssetModel;
|
||||
import com.muyu.etl.domain.DataAsset;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import feign.template.Literal;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
|
@ -16,8 +18,8 @@ import java.util.List;
|
|||
* @date 2024-04-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataSourceMapper
|
||||
{
|
||||
public interface DataSourceMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -66,17 +68,14 @@ public interface DataSourceMapper
|
|||
*/
|
||||
public int deleteDataSourceByIds(Long[] ids);
|
||||
|
||||
|
||||
List<AssetModel> getAssetModel(String databaseName, String assetModule);
|
||||
|
||||
void batchAdd( @Param("dataAssets") ArrayList<DataAsset> dataAssets);
|
||||
|
||||
|
||||
int clearTable(@Param("id") Long[] id);
|
||||
|
||||
List<DataAsset> selectDataAssetBachId(@Param("longs") List<Long> longs);
|
||||
|
||||
List<DataSource> selectId(Long id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.muyu.etl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.etl.domain.DictionaryData;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface DictionaryDataMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package com.muyu.etl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.etl.domain.Dictionary;
|
||||
import com.muyu.etl.domain.DictionaryData;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface DictionaryMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -54,7 +61,8 @@ public interface DictionaryMapper {
|
|||
*/
|
||||
public int deleteDictionaryByIds(Long[] ids);
|
||||
|
||||
|
||||
List<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId);
|
||||
|
||||
List<Dictionary> getDictionaryDataList(@Param("string") List<String> string);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.etl.mapper;
|
|||
import com.muyu.etl.domain.SourceAccredit;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,8 +14,8 @@ import java.util.List;
|
|||
* @date 2024-04-25
|
||||
*/
|
||||
@Mapper
|
||||
public interface SourceAccreditMapper
|
||||
{
|
||||
public interface SourceAccreditMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -72,4 +73,7 @@ public interface SourceAccreditMapper
|
|||
void insertBatchSourceAccredit(@Param("sourceAccredits") List<SourceAccredit> sourceAccredits);
|
||||
|
||||
void deleteSourceAccreditByDeptUser(@Param("deptIds") List<Long> deptIds, @Param("userId") Long userId, @Param("dataSourceId") Long dataSourceId);
|
||||
|
||||
void deleteSourceAccreditByUser(List<Long> longs, Long dataSourceId);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,22 +3,27 @@ package com.muyu.etl.service;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.etl.domain.AssetAccredit;
|
||||
import com.muyu.etl.domain.req.AssetAccreditReq;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface AssetAccreditService {
|
||||
|
||||
List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit);
|
||||
|
||||
AssetAccredit selectAssetAccreditById(Long id);
|
||||
|
||||
public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq);
|
||||
|
||||
public int updateAssetAccredit(AssetAccredit assetAccredit);
|
||||
|
||||
public int deleteAssetAccreditByIds(Long[] ids);
|
||||
|
||||
public int deleteAssetAccreditById(Long id);
|
||||
|
||||
Result getAssetAccreditByDataAssetId(Long id);
|
||||
Result deleteAssetAccreditByAssetId(AssetAccreditReq assetAccreditReq);
|
||||
Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
* @date 2024-04-22
|
||||
*/
|
||||
public interface AssetModelService
|
||||
{
|
||||
public interface AssetModelService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -59,4 +59,5 @@ public interface AssetModelService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAssetModelById(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
* @date 2024-04-22
|
||||
*/
|
||||
public interface DataAssetService
|
||||
{
|
||||
public interface DataAssetService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -59,4 +59,5 @@ public interface DataAssetService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDataAssetById(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.List;
|
|||
* @date 2024-04-20
|
||||
*/
|
||||
@Service
|
||||
public interface DataSourceService
|
||||
{
|
||||
public interface DataSourceService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -64,6 +64,7 @@ public interface DataSourceService
|
|||
*/
|
||||
public int deleteDataSourceById(Long id);
|
||||
|
||||
|
||||
Result test(DataSource dataSource);
|
||||
|
||||
Result assetsList(DataSource dataSource);
|
||||
|
@ -77,4 +78,5 @@ public interface DataSourceService
|
|||
Result assetModelList(DataAsset dataAsset);
|
||||
|
||||
Result statisticsInfo();
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,15 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Service
|
||||
public interface DictionaryDataService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -54,4 +61,5 @@ public interface DictionaryDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryDataById(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,16 @@ import com.muyu.etl.domain.Dictionary;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface DictionaryService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
* 查询【请填0写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
|
@ -53,7 +60,9 @@ public interface DictionaryService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryById(Long id);
|
||||
|
||||
Result getDictionaryList(Long dataSourceId);
|
||||
|
||||
Result delDict(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.List;
|
|||
* @date 2024-04-25
|
||||
*/
|
||||
@Service
|
||||
public interface SourceAccreditService
|
||||
{
|
||||
public interface SourceAccreditService {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -67,4 +67,5 @@ public interface SourceAccreditService
|
|||
Result getSourceAccreditByDataSourceId(Long id);
|
||||
|
||||
Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,12 +3,15 @@ package com.muyu.etl.service.impl;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.etl.domain.AssetAccredit;
|
||||
import com.muyu.etl.domain.model.AccreditModel;
|
||||
import com.muyu.etl.domain.req.AssetAccreditReq;
|
||||
import com.muyu.etl.mapper.AssetAccreditMapper;
|
||||
import com.muyu.etl.service.AssetAccreditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.embedded.undertow.UndertowWebServer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -36,8 +39,9 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
|
|||
|
||||
@Override
|
||||
public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq) {
|
||||
|
||||
// 根据资产ID删除资产授权信息
|
||||
deleteAssetAccreditByAssetId(assetAccreditReq);
|
||||
deleteAssetAccreditByAssetIds(assetAccreditReq);
|
||||
List<AssetAccredit> assetAccredits = new ArrayList<>();
|
||||
// 判断用户ID是否为空,不为空则为用户授权,为空则为部门授权
|
||||
if (assetAccreditReq.getUserId()!=null){
|
||||
|
@ -49,8 +53,7 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
|
|||
assetAccredit.setCreateTime(new Date());
|
||||
assetAccredits.add(assetAccredit);
|
||||
}else{
|
||||
// 为部门授权时,循环遍历部门ID,创建相应的资产授权信息
|
||||
assetAccreditReq.getDeptIds().stream()
|
||||
assetAccredits.addAll( assetAccreditReq.getDeptIds().stream()
|
||||
.map(deptId ->{
|
||||
AssetAccredit assetAccredit = new AssetAccredit();
|
||||
assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId());
|
||||
|
@ -58,7 +61,8 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
|
|||
assetAccredit.setCreateBy(SecurityUtils.getUsername());
|
||||
assetAccredit.setCreateTime(new Date());
|
||||
return assetAccredit;
|
||||
}).toList();
|
||||
}).toList());
|
||||
// 为部门授权时,循环遍历部门ID,创建相应的资产授权信息
|
||||
}
|
||||
// 将资产授权信息插入数据库
|
||||
assetAccreditMapper.insertBachAssetAccredit(assetAccredits);
|
||||
|
@ -71,7 +75,6 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
|
|||
return assetAccreditMapper.updateAssetAccredit(assetAccredit);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteAssetAccreditByIds(Long[] ids) {
|
||||
return assetAccreditMapper.deleteAssetAccreditByIds(ids);
|
||||
|
@ -93,40 +96,29 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
|
|||
public Result getAssetAccreditByDataAssetId(Long id) {
|
||||
// 通过数据资产ID查询所有的资产授权信息
|
||||
List<AssetAccredit> assetAccreditList = assetAccreditMapper.getAssetAccreditByDataAssetId(id);
|
||||
|
||||
// 通过流操作取出部门Id集合,过滤掉空值
|
||||
List<Long> deptListIds = assetAccreditList.stream().map(AssetAccredit::getDeptId).filter(Objects::nonNull).toList();
|
||||
|
||||
List<Long> deptAccreditIds = assetAccreditList.stream().map(AssetAccredit::getDeptId).filter(Objects::nonNull).toList();
|
||||
// 通过流操作取出用户ID集合,过滤掉空值
|
||||
List<Long> userListIds = assetAccreditList.stream().map(AssetAccredit::getUserId).filter(Objects::nonNull).toList();
|
||||
|
||||
List<Long> userAccreditIds = assetAccreditList.stream().map(AssetAccredit::getUserId).filter(Objects::nonNull).toList();
|
||||
// 创建授权模型,并设置部门和用户授权ID集合
|
||||
AccreditModel accreditModel = new AccreditModel();
|
||||
accreditModel.setDeptAccreditModelIds(deptListIds);
|
||||
accreditModel.setUserAccreditModelIds(userListIds);
|
||||
accreditModel.setDeptAccreditModelIds(deptAccreditIds);
|
||||
accreditModel.setUserAccreditModelIds(userAccreditIds);
|
||||
|
||||
// 返回成功结果,包含授权模型
|
||||
return Result.success(accreditModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteAssetAccreditByAssetId(AssetAccreditReq assetAccreditReq)
|
||||
public Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq)
|
||||
{
|
||||
/**
|
||||
* 根据用户或部门删除资产授权记录。
|
||||
* 如果用户ID非空,则根据用户ID和数据资产ID删除授权记录。
|
||||
* 如果用户ID空,则根据部门ID列表和数据资产ID删除授权记录。
|
||||
*
|
||||
* @param assetAccreditReq 包含用户ID、部门ID列表和数据资产ID的资产授权请求对象。
|
||||
* @return 返回操作成功的结果对象。
|
||||
*/
|
||||
if (assetAccreditReq.getUserId()!=null){
|
||||
// 根据用户ID和数据资产ID删除授权记录
|
||||
assetAccreditMapper.deleteAssetAccreditByDeptUser(null,assetAccreditReq.getUserId(),assetAccreditReq.getDataAssetId());
|
||||
}else{
|
||||
// 根据部门ID列表和数据资产ID删除授权记录
|
||||
assetAccreditMapper.deleteAssetAccreditByDeptUser(assetAccreditReq.getDeptIds(),null,assetAccreditReq.getDataAssetId());
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import java.util.List;
|
|||
* @date 2024-04-22
|
||||
*/
|
||||
@Service
|
||||
public class AssetModelServiceImpl implements AssetModelService
|
||||
{
|
||||
public class AssetModelServiceImpl implements AssetModelService {
|
||||
|
||||
@Autowired
|
||||
private AssetModelMapper assetModelMapper;
|
||||
|
||||
|
@ -28,8 +28,7 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public AssetModel selectAssetModelById(Long id)
|
||||
{
|
||||
public AssetModel selectAssetModelById(Long id) {
|
||||
return assetModelMapper.selectAssetModelById(id);
|
||||
}
|
||||
|
||||
|
@ -40,8 +39,7 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<AssetModel> selectAssetModelList(AssetModel assetModel)
|
||||
{
|
||||
public List<AssetModel> selectAssetModelList(AssetModel assetModel) {
|
||||
return assetModelMapper.selectAssetModelList(assetModel);
|
||||
}
|
||||
|
||||
|
@ -52,8 +50,7 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAssetModel(AssetModel assetModel)
|
||||
{
|
||||
public int insertAssetModel(AssetModel assetModel) {
|
||||
assetModel.setCreateTime(DateUtils.getNowDate());
|
||||
return assetModelMapper.insertAssetModel(assetModel);
|
||||
}
|
||||
|
@ -65,8 +62,7 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAssetModel(AssetModel assetModel)
|
||||
{
|
||||
public int updateAssetModel(AssetModel assetModel) {
|
||||
assetModel.setUpdateTime(DateUtils.getNowDate());
|
||||
return assetModelMapper.updateAssetModel(assetModel);
|
||||
}
|
||||
|
@ -78,8 +74,7 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAssetModelByIds(Long[] ids)
|
||||
{
|
||||
public int deleteAssetModelByIds(Long[] ids) {
|
||||
return assetModelMapper.deleteAssetModelByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -90,8 +85,8 @@ public class AssetModelServiceImpl implements AssetModelService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAssetModelById(Long id)
|
||||
{
|
||||
public int deleteAssetModelById(Long id) {
|
||||
return assetModelMapper.deleteAssetModelById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import java.util.List;
|
|||
* @date 2024-04-22
|
||||
*/
|
||||
@Service
|
||||
public class DataAssetServiceImpl implements DataAssetService
|
||||
{
|
||||
public class DataAssetServiceImpl implements DataAssetService {
|
||||
|
||||
@Autowired
|
||||
private DataAssetMapper dataAssetMapper;
|
||||
|
||||
|
@ -28,8 +28,7 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public DataAsset selectDataAssetById(Long id)
|
||||
{
|
||||
public DataAsset selectDataAssetById(Long id) {
|
||||
return dataAssetMapper.selectDataAssetById(id);
|
||||
}
|
||||
|
||||
|
@ -40,8 +39,7 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<DataAsset> selectDataAssetList(DataAsset dataAsset)
|
||||
{
|
||||
public List<DataAsset> selectDataAssetList(DataAsset dataAsset) {
|
||||
return dataAssetMapper.selectDataAssetList(dataAsset);
|
||||
}
|
||||
|
||||
|
@ -52,8 +50,7 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDataAsset(DataAsset dataAsset)
|
||||
{
|
||||
public int insertDataAsset(DataAsset dataAsset) {
|
||||
dataAsset.setCreateTime(DateUtils.getNowDate());
|
||||
return dataAssetMapper.insertDataAsset(dataAsset);
|
||||
}
|
||||
|
@ -65,8 +62,7 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDataAsset(DataAsset dataAsset)
|
||||
{
|
||||
public int updateDataAsset(DataAsset dataAsset) {
|
||||
dataAsset.setUpdateTime(DateUtils.getNowDate());
|
||||
return dataAssetMapper.updateDataAsset(dataAsset);
|
||||
}
|
||||
|
@ -78,8 +74,7 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDataAssetByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDataAssetByIds(Long[] ids) {
|
||||
return dataAssetMapper.deleteDataAssetByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -90,8 +85,8 @@ public class DataAssetServiceImpl implements DataAssetService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDataAssetById(Long id)
|
||||
{
|
||||
public int deleteDataAssetById(Long id) {
|
||||
return dataAssetMapper.deleteDataAssetById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
|
@ -13,10 +18,6 @@ import com.muyu.etl.service.DataSourceService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
*
|
||||
|
@ -24,7 +25,7 @@ import java.util.*;
|
|||
* @date 2024-04-20
|
||||
*/
|
||||
@Service
|
||||
public class DataSourceServiceImpl implements DataSourceService{
|
||||
public class DataSourceServiceImpl implements DataSourceService {
|
||||
|
||||
@Autowired
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
|
@ -51,8 +52,7 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public DataSource selectDataSourceById(Long id)
|
||||
{
|
||||
public DataSource selectDataSourceById(Long id) {
|
||||
return dataSourceMapper.selectDataSourceById(id);
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,10 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
public int insertDataSource(DataSource dataSource) {
|
||||
dataSource.setCreateTime(DateUtils.getNowDate());
|
||||
dataSource.setCreateBy(SecurityUtils.getUsername());
|
||||
if("Mysql".equals(dataSource.getType())){
|
||||
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver");
|
||||
}else {
|
||||
dataSource.setJdbcDriver("org.postgresql.Driver");
|
||||
if (dataSource.getType().equals("MySql")){
|
||||
dataSource.setType("com.mysql.cj.jdbc.Driver");
|
||||
}else{
|
||||
dataSource.setType("org.postgresql.Driver");
|
||||
}
|
||||
return dataSourceMapper.insertDataSource(dataSource);
|
||||
}
|
||||
|
@ -112,8 +112,7 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDataSource(DataSource dataSource)
|
||||
{
|
||||
public int updateDataSource(DataSource dataSource) {
|
||||
dataSource.setUpdateTime(DateUtils.getNowDate());
|
||||
dataSource.setUpdateBy(SecurityUtils.getUsername());
|
||||
return dataSourceMapper.updateDataSource(dataSource);
|
||||
|
@ -126,8 +125,7 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDataSourceByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDataSourceByIds(Long[] ids) {
|
||||
return dataSourceMapper.deleteDataSourceByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -138,30 +136,24 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDataSourceById(Long id)
|
||||
{
|
||||
public int deleteDataSourceById(Long id) {
|
||||
return dataSourceMapper.deleteDataSourceById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result test(DataSource dataSource) {
|
||||
//获取用户
|
||||
String username = dataSource.getUsername();
|
||||
//获取密码
|
||||
String password = dataSource.getPassword();
|
||||
String jdbcDriver="com.mysql.cj.jdbc.Driver";
|
||||
String url="jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
String url="jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
|
||||
url = url +"?"+dataSource.getConnectionParam();
|
||||
}
|
||||
Connection con = null;
|
||||
try{
|
||||
Class.forName(jdbcDriver);
|
||||
Class.forName(dataSource.getJdbcDriver());
|
||||
}catch (Exception e){
|
||||
return Result.error("数据源查询失败");
|
||||
}
|
||||
try{
|
||||
con = DriverManager.getConnection(url,username,password);
|
||||
con = DriverManager.getConnection(url,dataSource.getUsername(),dataSource.getPassword());
|
||||
con.close();
|
||||
}catch (Exception e){
|
||||
return Result.error("数据源查询失败");
|
||||
|
@ -169,21 +161,29 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
return Result.success("链接成功咯");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据提供的DataSource和表名获取表类型映射。
|
||||
* @param dataSource 数据源对象,包含连接数据库所需的信息。
|
||||
* @param tableName 需要查询的表名。
|
||||
* @return 返回一个映射,其中包含表中的列名和对应的Java类型名称。
|
||||
*/
|
||||
public Map<String,String> getTypeMap(DataSource dataSource,String tableName){
|
||||
// 初始化JDBC URL和SQL查询语句
|
||||
String jdbcUrl ="";
|
||||
String sql="";
|
||||
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
// 根据数据源类型设置SQL语句
|
||||
if (dataSource.getType().equals("MySql")){
|
||||
sql = "select * from"+tableName;
|
||||
sql = "select * from "+tableName;
|
||||
}else{
|
||||
sql = "select * from"+dataSource.getModeName()+"."+tableName;
|
||||
sql = "select * from "+dataSource.getModeName()+"."+tableName;
|
||||
}
|
||||
Connection con = null;
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
try{
|
||||
Class.forName(dataSource.getJdbcDriver());
|
||||
// 加载 JDBC 驱动并获取数据库连接
|
||||
con = DriverManager.getConnection(jdbcUrl,dataSource.getUsername(),dataSource.getPassword());
|
||||
}catch (SQLException | ClassNotFoundException e){
|
||||
}catch (SQLException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try{
|
||||
|
@ -191,7 +191,8 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
pst = con.prepareStatement(sql);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
ResultSetMetaData metaData = rs.getMetaData();
|
||||
for (int i = 0; i < metaData.getColumnCount(); i++) {
|
||||
// 遍历结果集元数据,获取列名和对应的Java类型名称
|
||||
for (int i = 1; i <= metaData.getColumnCount(); i++) {
|
||||
String sub= "";
|
||||
if (metaData.getColumnClassName(i).contains(".")){
|
||||
String[] s=metaData.getColumnClassName(i).split("\\.");
|
||||
|
@ -210,41 +211,6 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
return map;
|
||||
}
|
||||
|
||||
public static String mapDataTypeToJavaClass(String mappingType) {
|
||||
switch (mappingType.toLowerCase()) {
|
||||
case "tinyint":
|
||||
return "Byte";
|
||||
case "smallint":
|
||||
return "Short";
|
||||
case "mediumint":
|
||||
case "int":
|
||||
case "integer":
|
||||
return "Integer";
|
||||
case "bigint":
|
||||
return "Long";
|
||||
case "real":
|
||||
case "float":
|
||||
return "Float";
|
||||
case "decimal":
|
||||
return "Double";
|
||||
case "varchar":
|
||||
case "char":
|
||||
case "text":
|
||||
return "String";
|
||||
case "datetime":
|
||||
return "Date";
|
||||
case "blob":
|
||||
case "longblob":
|
||||
return "byte[]";
|
||||
case "longtext":
|
||||
return "Clob";
|
||||
case "double":
|
||||
return "double";
|
||||
default:
|
||||
//抛出新的IlLegalArgumentException(“不支持的数据类型:”+mappingType);
|
||||
throw new IllegalArgumentException("Unsupported data type: " + mappingType);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取指定数据表的资产模型列表
|
||||
* @param dataSource 数据源,包含数据库连接所需的用户名、密码、链接地址、端口和数据库名称
|
||||
|
@ -259,10 +225,9 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
Map<String, String> typeMap = getTypeMap(dataSource, tableName);
|
||||
try{
|
||||
// 加载JDBC驱动
|
||||
Class.forName(dataSource.getJdbcDriver());
|
||||
// 建立数据库连接
|
||||
con = DriverManager.getConnection(url,dataSource.getUsername(),dataSource.getPassword());
|
||||
}catch (SQLException | ClassNotFoundException exception){
|
||||
}catch (SQLException exception){
|
||||
// 抛出运行时异常
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
@ -299,7 +264,6 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
.build(); // 构建并返回字段信息对象
|
||||
tableAssets.add(build);
|
||||
}
|
||||
|
||||
columnsRS.close();
|
||||
primaryKeyRS.close();
|
||||
}catch (SQLException e){
|
||||
|
@ -307,7 +271,14 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
}
|
||||
return tableAssets;
|
||||
}
|
||||
//获取表结构
|
||||
/**
|
||||
* 根据给定的DataSource获取AssetsModule。
|
||||
* 该方法首先会构建与数据库的连接,然后查询指定表的所有列,并根据列的类型映射到AssetModel的属性类型上。
|
||||
* 最后,将这个映射关系封装到AssetsModule中返回。
|
||||
*
|
||||
* @param dataSource 提供数据库连接信息的对象,包括用户名、密码、数据库类型、链接地址、端口和数据库名称。
|
||||
* @return AssetsModule 包含表结构信息的模块。
|
||||
*/
|
||||
public AssetsModule getAssets(DataSource dataSource){
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
Connection conn = null;
|
||||
|
@ -322,24 +293,20 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
// 抛出运行时异常
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
// 准备查询语句并执行
|
||||
PreparedStatement pst = conn.prepareStatement("select * from "+dataSource.getTableName()+" where 1=1");
|
||||
ResultSet resultSet = pst.executeQuery();
|
||||
ResultSetMetaData rsd = resultSet.getMetaData();
|
||||
|
||||
// 遍历结果集元数据,构建列名和数据类型的映射关系
|
||||
for(int i = 1; i <= rsd.getColumnCount(); i++) {
|
||||
String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10);
|
||||
map.put(rsd.getColumnName(i),substring);
|
||||
}
|
||||
|
||||
// 根据映射关系,设置AssetModel的类型
|
||||
for (AssetModel tableAsset : tableAssets) {
|
||||
tableAsset.setType(map.get(tableAsset.getName()));
|
||||
}
|
||||
|
||||
pst.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -350,13 +317,17 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
return assetsModule;
|
||||
}
|
||||
|
||||
//获取数据表结构
|
||||
/**
|
||||
* 从数据源获取结构信息
|
||||
*
|
||||
* @param dataSource 提供数据库连接信息的数据源
|
||||
* @return AssetsModule 包含数据库结构和数据的模块
|
||||
*/
|
||||
public AssetsModule getStructure(DataSource dataSource){
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
Connection conn = null;
|
||||
List<Map<String, VTClass>> kvtList = new ArrayList<>();
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 加载数据库驱动并建立连接
|
||||
Class.forName(dataSource.getJdbcDriver());
|
||||
|
@ -370,15 +341,12 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
PreparedStatement pst = conn.prepareStatement(dataSource.getSql());
|
||||
ResultSet resultSet = pst.executeQuery();
|
||||
ResultSetMetaData rsd = resultSet.getMetaData();
|
||||
|
||||
// 处理查询结果,生成列名与java类型的映射
|
||||
for(int i = 1; i <= rsd.getColumnCount(); i++) {
|
||||
String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10);
|
||||
map.put(rsd.getColumnName(i),substring);
|
||||
String[] split = rsd.getColumnClassName(i).split("\\.");
|
||||
map.put(rsd.getColumnName(i),split[split.length-1]);
|
||||
}
|
||||
|
||||
int columnCount = rsd.getColumnCount();
|
||||
|
||||
// 遍历查询结果,填充数据到list中
|
||||
while (resultSet.next()){
|
||||
Map<String, VTClass> stringVTClassHashMap = new HashMap<>();
|
||||
|
@ -395,15 +363,14 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
kvtList.add(stringVTClassHashMap);
|
||||
}
|
||||
pst.close();
|
||||
conn.close();
|
||||
pst=null;
|
||||
conn=null;
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 构建并返回AssetsModule对象
|
||||
AssetsModule assetsModule = new AssetsModule();
|
||||
assetsModule.setKvtList(kvtList);
|
||||
assetsModule.setStructure(map);
|
||||
return assetsModule;
|
||||
return new AssetsModule().assetsModuleBuilder(kvtList,map);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -422,10 +389,11 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
public void del(){
|
||||
|
||||
}
|
||||
|
||||
//数据同步
|
||||
@Override
|
||||
public Result synchronization(DataSource dataSource) {
|
||||
List<DataSource> dataSources = dataSourceMapper.selectId(dataSource.getId()); // 根据数据源ID查询所有相关数据源-+
|
||||
List<DataSource> dataSources = dataSourceMapper.selectId(dataSource.getId()); // 根据数据源ID查询所有相关数据源
|
||||
List<Long> longList = dataSources.stream().map(DataSource::getId).toList(); // 提取数据源ID列表
|
||||
ArrayList<Long> l = new ArrayList<>();
|
||||
for (Long aLong : longList) {
|
||||
|
@ -479,25 +447,8 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
// 遍历结果集,将每条记录转换为DataAsset对象,并添加到数据列表中
|
||||
while (resultSet.next()){
|
||||
DataAsset dataAsset = new DataAsset();
|
||||
// 设置表名
|
||||
dataAsset.setTableName(resultSet.getString("t_name"));
|
||||
// 设置表注释
|
||||
dataAsset.setTableComment(resultSet.getString("table_comment"));
|
||||
// 设置表行数
|
||||
dataAsset.setTableCount(resultSet.getLong("table_rows"));
|
||||
// 设置字段数
|
||||
dataAsset.setFields(resultSet.getLong("fields"));
|
||||
// 设置数据源ID
|
||||
dataAsset.setDataSourceId(dataSource.getId());
|
||||
// 设置创建者为当前登录用户
|
||||
dataAsset.setCreateBy(SecurityUtils.getUsername());
|
||||
// 设置创建时间为当前时间
|
||||
dataAsset.setCreateTime(new Date());
|
||||
// 将DataAsset对象添加到数据列表中
|
||||
dataAssets.add(dataAsset);
|
||||
dataAssets.add(new DataAsset().dataAssetBuilder(dataSource,resultSet));
|
||||
}
|
||||
|
||||
// 将 DataAsset 对象的 ID 提取出来并转换为 Long 数组
|
||||
Long id = dataSource.getId(); // 从数据源获取ID
|
||||
Long[] a = new Long[1];
|
||||
|
@ -516,6 +467,12 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据资产列表。
|
||||
*
|
||||
* @param dataSource 数据源对象,用于指定查询的数据源。
|
||||
* @return 返回数据资产列表操作的结果,其中包含查询到的数据资产列表。
|
||||
*/
|
||||
@Override
|
||||
public Result dataAssetList(DataSource dataSource) {
|
||||
// 创建一个新的DataAsset实例,并设置其数据源ID
|
||||
|
@ -527,14 +484,22 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles();
|
||||
if (roles.get(0).getRoleId() ==1){
|
||||
dataAssetList = dataAssets;
|
||||
}else{
|
||||
}else {
|
||||
// 通过用户ID获取用户被授权的所有资产ID列表
|
||||
List<Long> assetIds = assetAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList();
|
||||
dataAssets = dataAssets.stream().filter(dataAsset1 -> assetIds.contains(dataAsset1.getId())).toList();
|
||||
// 从所有数据资产中筛选出用户被授权的资产
|
||||
dataAssetList = dataAssets.stream().filter(dataAsset1 -> assetIds.contains(dataAsset1.getId())).toList();
|
||||
}
|
||||
// 返回查询结果的成功响应
|
||||
return Result.success(dataAssetList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据资产模型列表。
|
||||
*
|
||||
* @param dataAsset 数据资产对象,包含需要查询的数据资产ID。
|
||||
* @return 返回数据资产模型列表的结果对象,其中包含查询到的资产模型列表。
|
||||
*/
|
||||
@Override
|
||||
public Result assetModelList(DataAsset dataAsset) {
|
||||
// 创建资产模型实例,并设置数据资产ID
|
||||
|
@ -561,26 +526,31 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
return Result.success(assetModels);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 获取统计信息
|
||||
* 该方法不接受参数,通过查询数据源及其相关的数据资产,来统计数据资产的总数和包含的字段总数、表数量。
|
||||
* 获取统计数据信息
|
||||
* 本方法用于根据当前用户的角色和权限,统计相关的数据资产信息,包括数据资产数量、数据模型数量和资产模型数量。
|
||||
* 不接受任何参数。
|
||||
*
|
||||
* @return Result 包含统计信息的结果对象,其中成功时携带Statistics对象,包含数据资产数量、数据模型数量和资产模型数量。
|
||||
* @return Result 包含统计数据的Result对象。其中,统计数据封装在Statistics对象中,包括数据资产数量(dataAsset)、
|
||||
* 数据模型数量(dataModel)和资产模型数量(assetModel)。
|
||||
*/
|
||||
@Override
|
||||
public Result statisticsInfo() {
|
||||
List<DataSource> dataSourcesList = new ArrayList<>();
|
||||
// 查询所有的数据源
|
||||
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(new DataSource());
|
||||
List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles();
|
||||
List<Long> assetIds;
|
||||
// 根据用户角色处理数据源筛选
|
||||
if (roles.get(0).getRoleId()==1){
|
||||
assetIds = new ArrayList<>();
|
||||
dataSourcesList = dataSources;
|
||||
}else{
|
||||
ArrayList<Long> longs1 = new ArrayList<>();
|
||||
// 根据用户权限查询可以访问的数据源ID和数据资产ID
|
||||
List<Long> sourceIds = sourceAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(SourceAccredit::getDataSourceId).filter(Objects::nonNull).toList();
|
||||
assetIds = assetAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList();
|
||||
// 根据数据资产ID查询并筛选相关数据源
|
||||
if (!assetIds.isEmpty()){
|
||||
List<Long> longs = dataAssetMapper.getDataAssetByAssetId(assetIds).stream().map(DataAsset::getDataSourceId).toList();
|
||||
longs1.addAll(longs);
|
||||
|
@ -589,27 +559,28 @@ public class DataSourceServiceImpl implements DataSourceService{
|
|||
dataSourcesList = dataSources.stream().filter(dataSource -> longs1.contains(dataSource.getId())).toList();
|
||||
}
|
||||
List<Long> longList = dataSourcesList.stream().map(dataSource -> dataSource.getId()).toList();
|
||||
com.muyu.etl.domain.custom.Statistics statistics= new Statistics();
|
||||
Statistics statistics= new Statistics();
|
||||
// 根据筛选后的数据源列表统计数据资产数量、数据模型数量和资产模型数量
|
||||
if (!longList.isEmpty()){
|
||||
List<DataAsset> dataAssetByAssetId = dataAssetMapper.getDataAssetByAssetId(longList);
|
||||
// 对于非管理员角色,进一步筛选数据源列表
|
||||
if (roles.get(0).getRoleId()!=1){
|
||||
dataSourcesList = dataSourcesList.stream().filter(dataSource -> longList.contains(dataSource.getId())).toList();
|
||||
}
|
||||
// 统计数据资产数量、数据模型数量和资产模型数量
|
||||
statistics.setDataAsset(Long.valueOf(dataSourcesList.size()));
|
||||
long sum;
|
||||
long sum1;
|
||||
// 统计所有数据资产的字段总数
|
||||
sum = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum();
|
||||
// 统计所有数据资产的表数量
|
||||
sum1 = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum();
|
||||
// 设置数据模型数量和资产模型数量
|
||||
statistics.setDataModel(sum);
|
||||
statistics.setAssetModel(sum1);
|
||||
}else{
|
||||
// 若无权限访问的数据源或数据资产,则相应数量置为0
|
||||
statistics.setDataAsset(0L);
|
||||
statistics.setAssetModel(0L);
|
||||
}
|
||||
// 返回携带统计信息的成功结果
|
||||
// 返回统计数据
|
||||
return Result.success(statistics);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.etl.domain.DictionaryData;
|
||||
import com.muyu.etl.mapper.DictionaryDataMapper;
|
||||
import com.muyu.etl.service.DictionaryDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.etl.mapper.DictionaryDataMapper;
|
||||
import com.muyu.etl.domain.DictionaryData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-25
|
||||
*/
|
||||
@Service
|
||||
public class DictionaryDataServiceImpl implements DictionaryDataService {
|
||||
|
||||
@Autowired
|
||||
private DictionaryDataMapper dictionaryDataMapper;
|
||||
|
||||
|
@ -22,8 +28,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public DictionaryData selectDictionaryDataById(Long id)
|
||||
{
|
||||
public DictionaryData selectDictionaryDataById(Long id) {
|
||||
return dictionaryDataMapper.selectDictionaryDataById(id);
|
||||
}
|
||||
|
||||
|
@ -34,8 +39,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<DictionaryData> selectDictionaryDataList(DictionaryData dictionaryData)
|
||||
{
|
||||
public List<DictionaryData> selectDictionaryDataList(DictionaryData dictionaryData) {
|
||||
return dictionaryDataMapper.selectDictionaryDataList(dictionaryData);
|
||||
}
|
||||
|
||||
|
@ -46,8 +50,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDictionaryData(DictionaryData dictionaryData)
|
||||
{
|
||||
public int insertDictionaryData(DictionaryData dictionaryData) {
|
||||
dictionaryData.setCreateTime(DateUtils.getNowDate());
|
||||
dictionaryData.setCreateBy(SecurityUtils.getUsername());
|
||||
return dictionaryDataMapper.insertDictionaryData(dictionaryData);
|
||||
|
@ -60,8 +63,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDictionaryData(DictionaryData dictionaryData)
|
||||
{
|
||||
public int updateDictionaryData(DictionaryData dictionaryData) {
|
||||
dictionaryData.setUpdateTime(DateUtils.getNowDate());
|
||||
dictionaryData.setUpdateBy(SecurityUtils.getUsername());
|
||||
return dictionaryDataMapper.updateDictionaryData(dictionaryData);
|
||||
|
@ -74,8 +76,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictionaryDataByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDictionaryDataByIds(Long[] ids) {
|
||||
return dictionaryDataMapper.deleteDictionaryDataByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -86,8 +87,8 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictionaryDataById(Long id)
|
||||
{
|
||||
public int deleteDictionaryDataById(Long id) {
|
||||
return dictionaryDataMapper.deleteDictionaryDataById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.etl.domain.Dictionary;
|
||||
import com.muyu.etl.domain.DictionaryData;
|
||||
import com.muyu.etl.mapper.AssetModelMapper;
|
||||
import com.muyu.etl.mapper.DictionaryDataMapper;
|
||||
import com.muyu.etl.mapper.DictionaryMapper;
|
||||
import com.muyu.etl.service.DictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.etl.mapper.DictionaryMapper;
|
||||
import com.muyu.etl.domain.Dictionary;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
|
@ -21,13 +21,14 @@ import java.util.List;
|
|||
* @date 2024-04-25
|
||||
*/
|
||||
@Service
|
||||
public class DictionaryServiceImpl implements DictionaryService
|
||||
{
|
||||
public class DictionaryServiceImpl implements DictionaryService {
|
||||
|
||||
@Autowired
|
||||
private DictionaryMapper dictionaryMapper;
|
||||
|
||||
@Autowired
|
||||
private DictionaryDataMapper dictionaryDataMapper;
|
||||
|
||||
@Autowired
|
||||
private AssetModelMapper assetModelMapper;
|
||||
|
||||
|
@ -38,8 +39,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public Dictionary selectDictionaryById(Long id)
|
||||
{
|
||||
public Dictionary selectDictionaryById(Long id) {
|
||||
return dictionaryMapper.selectDictionaryById(id);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<Dictionary> selectDictionaryList(Dictionary dictionary)
|
||||
{
|
||||
public List<Dictionary> selectDictionaryList(Dictionary dictionary) {
|
||||
return dictionaryMapper.selectDictionaryList(dictionary);
|
||||
}
|
||||
|
||||
|
@ -62,8 +61,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDictionary(Dictionary dictionary)
|
||||
{
|
||||
public int insertDictionary(Dictionary dictionary) {
|
||||
dictionary.setCreateTime(DateUtils.getNowDate());
|
||||
dictionary.setCreateBy(SecurityUtils.getUsername());
|
||||
return dictionaryMapper.insertDictionary(dictionary);
|
||||
|
@ -76,8 +74,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDictionary(Dictionary dictionary)
|
||||
{
|
||||
public int updateDictionary(Dictionary dictionary) {
|
||||
dictionary.setUpdateTime(DateUtils.getNowDate());
|
||||
dictionary.setUpdateBy(SecurityUtils.getUsername());
|
||||
return dictionaryMapper.updateDictionary(dictionary);
|
||||
|
@ -90,8 +87,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictionaryByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDictionaryByIds(Long[] ids) {
|
||||
return dictionaryMapper.deleteDictionaryByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -102,8 +98,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictionaryById(Long id)
|
||||
{
|
||||
public int deleteDictionaryById(Long id) {
|
||||
return dictionaryMapper.deleteDictionaryById(id);
|
||||
}
|
||||
|
||||
|
@ -142,6 +137,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
assetModelMapper.updateAssetModelDiction(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典数据列表。
|
||||
*
|
||||
|
@ -167,6 +163,7 @@ public class DictionaryServiceImpl implements DictionaryService
|
|||
// 返回成功结果,包含处理后的字典数据列表
|
||||
return Result.success(dictionaryDataList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,16 +16,12 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @ClassName SourceAccreditServiceImpl
|
||||
* @Description 描述
|
||||
* @Author HaoRan.Zhang
|
||||
* @Date 2024/4/29 15:06
|
||||
*/
|
||||
@Service
|
||||
public class SourceAccreditServiceImpl implements SourceAccreditService {
|
||||
|
||||
@Autowired
|
||||
private SourceAccreditMapper sourceAccreditMapper;
|
||||
|
||||
@Override
|
||||
public SourceAccredit selectSourceAccreditById(Long id) {
|
||||
SourceAccredit sourceAccredit = sourceAccreditMapper.selectSourceAccreditById(id);
|
||||
|
@ -38,10 +34,21 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
|
|||
return sourceAccredits;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入源数据授权信息。
|
||||
* 此方法根据传入的用户ID或部门ID集合,为指定的数据源授权。
|
||||
* 如果传入了用户ID,则只授权给该用户;如果传入了部门ID集合,则为这些部门授权。
|
||||
* 首先会删除已有的对应源数据的授权信息,然后插入新的授权信息。
|
||||
*
|
||||
* @param sourceAccreditReq 包含授权信息请求对象,包括数据源ID、用户ID(可选)和部门ID集合(可选)。
|
||||
* @return 返回操作结果,成功则返回Result.success()。
|
||||
*/
|
||||
@Override
|
||||
public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) {
|
||||
// 删除已有的对应源数据的授权信息
|
||||
deleteSourceAccreditBySourceIds(sourceAccreditReq);
|
||||
List<SourceAccredit> sourceAccredits = new ArrayList<>();
|
||||
// 如果请求中包含用户ID,则为该用户授权
|
||||
if (sourceAccreditReq.getUserId()!=null){
|
||||
SourceAccredit sourceAccredit = new SourceAccredit();
|
||||
sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId());
|
||||
|
@ -49,7 +56,8 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
|
|||
sourceAccredit.setCreateBy(SecurityUtils.getUsername());
|
||||
sourceAccredit.setCreateTime(new Date());
|
||||
sourceAccredits.add(sourceAccredit);
|
||||
}else{
|
||||
} else {
|
||||
// 如果请求中包含部门ID集合,则为这些部门授权
|
||||
sourceAccredits = sourceAccreditReq.getDeptIds().stream()
|
||||
.map(deptId -> {
|
||||
SourceAccredit sourceAccredit = new SourceAccredit();
|
||||
|
@ -60,6 +68,7 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
|
|||
return sourceAccredit;
|
||||
}).toList();
|
||||
}
|
||||
// 批量插入授权信息
|
||||
sourceAccreditMapper.insertBatchSourceAccredit(sourceAccredits);
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -81,24 +90,45 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
|
|||
return sourceAccreditMapper.deleteSourceAccreditById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据源ID获取源认证信息。
|
||||
*
|
||||
* @param id 数据源ID,用于查询与之相关的认证信息。
|
||||
* @return 返回一个结果对象,其中包含认证模型(AccreditModel)信息。该模型包括用户认证ID集合和部门认证ID集合。
|
||||
*/
|
||||
@Override
|
||||
public Result getSourceAccreditByDataSourceId(Long id) {
|
||||
// 根据数据源ID查询所有的源认证信息
|
||||
List<SourceAccredit> sourceAccreditList = sourceAccreditMapper.getSourceAccreditByDataSourceId(id);
|
||||
// 从源认证信息中提取用户ID,并过滤掉空值,然后转换为列表
|
||||
List<Long> userAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getUserId).filter(Objects::nonNull).toList();
|
||||
// 从源认证信息中提取部门ID,并过滤掉空值,然后转换为列表
|
||||
List<Long> deptAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getDeptId).filter(Objects::nonNull).toList();
|
||||
// 创建一个认证模型实例,并设置用户和部门认证ID集合
|
||||
AccreditModel accreditModel = new AccreditModel();
|
||||
accreditModel.setDeptAccreditModelIds(deptAccreditIds);
|
||||
accreditModel.setUserAccreditModelIds(userAccreditIds);
|
||||
// 返回包含认证模型的成功结果
|
||||
return Result.success(accreditModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据源ID和用户ID或部门ID删除源认证信息
|
||||
* @param sourceAccreditReq 包含待删除源的用户ID、部门ID和数据源ID的请求对象
|
||||
* @return 返回操作结果,如果操作成功,则返回成功结果
|
||||
*/
|
||||
@Override
|
||||
public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) {
|
||||
// 根据用户ID或部门ID删除源认证信息
|
||||
if (sourceAccreditReq.getUserId()!=null){
|
||||
// 当用户ID不为空时,根据用户ID和数据源ID删除认证信息
|
||||
sourceAccreditMapper.deleteSourceAccreditByDeptUser(null,sourceAccreditReq.getUserId(),sourceAccreditReq.getDataSourceId());
|
||||
}else{
|
||||
// 当用户ID为空时,根据部门ID和数据源ID删除认证信息
|
||||
sourceAccreditMapper.deleteSourceAccreditByDeptUser(sourceAccreditReq.getDeptIds(),null,sourceAccreditReq.getDataSourceId());
|
||||
}
|
||||
// 返回操作成功的结果
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -164,4 +164,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="deleteAssetAccreditByUser">
|
||||
delete from asset_accredit where data_asset_id = #{dataAssetId}
|
||||
and user_id in(
|
||||
<foreach collection="userIds" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.etl.mapper.AssetModelMapper">
|
||||
|
||||
<resultMap type="com.muyu.etl.domain.AssetModel" id="AssetModelResult">
|
||||
|
@ -93,69 +93,44 @@
|
|||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<!-- <insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id" >-->
|
||||
<!-- insert into `asset_model_copy1`-->
|
||||
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||
<!-- `data_asset_id`,-->
|
||||
<!-- `name`,-->
|
||||
<!-- `comment`,-->
|
||||
<!-- `is_primary_key`,-->
|
||||
<!-- `type`,-->
|
||||
<!-- `mapping_type`,-->
|
||||
<!-- `length`,-->
|
||||
<!-- `decimal_places`,-->
|
||||
<!-- `is_null`,-->
|
||||
<!-- `is_dict`,-->
|
||||
<!-- `default_value`,-->
|
||||
<!-- `dict_key`,-->
|
||||
<!-- `create_by`,-->
|
||||
<!-- `create_time`,-->
|
||||
<!-- </trim>-->
|
||||
<!-- values-->
|
||||
<!-- <foreach collection="tableAssets" item="item" separator=",">-->
|
||||
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||
<!-- <if test="item.dataAssetId != null">#{item.dataAssetId},</if>-->
|
||||
<!-- <if test="item.name != null">#{item.name},</if>-->
|
||||
<!-- <if test="item.comment != null">#{item.comment},</if>-->
|
||||
<!-- <if test="item.isPrimaryKey != null">#{item.isPrimaryKey},</if>-->
|
||||
<!-- <if test="item.type != null">#{item.type},</if>-->
|
||||
<!-- <if test="item.mappingType != null">#{item.mappingType},</if>-->
|
||||
<!-- <if test="item.length != null">#{item.length},</if>-->
|
||||
<!-- <if test="item.decimalPlaces != null">#{item.decimalPlaces},</if>-->
|
||||
<!-- <if test="item.isNull != null">#{item.isNull},</if>-->
|
||||
<!-- <if test="item.isDict != null">#{item.isDict},</if>-->
|
||||
<!-- <if test="item.defaultValue != null">#{item.defaultValue},</if>-->
|
||||
<!-- <if test="item.dictKey != null">#{item.dictKey},</if>-->
|
||||
<!-- <if test="item.createBy != null and item.createBy != ''">#{item.createBy},</if>-->
|
||||
<!-- <if test="item.createTime != null">#{item.createTime},</if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- </foreach>-->
|
||||
|
||||
<!-- </insert>-->
|
||||
<insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO `asset_model_copy1` (
|
||||
`data_asset_id`, `name`, `comment`, `is_primary_key`, `type`, `mapping_type`,
|
||||
`length`, `decimal_places`, `is_null`, `is_dict`, `default_value`, `dict_key`,
|
||||
`create_by`, `create_time`
|
||||
) VALUES
|
||||
<insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id" >
|
||||
insert into `asset_model_copy1`
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
`data_asset_id`,
|
||||
`name`,
|
||||
`comment`,
|
||||
`is_primary_key`,
|
||||
`type`,
|
||||
`mapping_type`,
|
||||
`length`,
|
||||
`decimal_places`,
|
||||
`is_null`,
|
||||
`is_dict`,
|
||||
`default_value`,
|
||||
`dict_key`,
|
||||
`create_by`,
|
||||
`create_time`,
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="tableAssets" item="item" separator=",">
|
||||
(
|
||||
#{item.dataAssetId},
|
||||
#{item.name},
|
||||
#{item.comment},
|
||||
#{item.isPrimaryKey},
|
||||
#{item.type},
|
||||
#{item.mappingType},
|
||||
#{item.length},
|
||||
#{item.decimalPlaces},
|
||||
#{item.isNull},
|
||||
#{item.isDict},
|
||||
#{item.defaultValue},
|
||||
#{item.dictKey},
|
||||
#{item.createBy},
|
||||
#{item.createTime}
|
||||
)
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="item.dataAssetId != null">#{item.dataAssetId},</if>
|
||||
<if test="item.name != null">#{item.name},</if>
|
||||
<if test="item.comment != null">#{item.comment},</if>
|
||||
<if test="item.isPrimaryKey != null">#{item.isPrimaryKey},</if>
|
||||
<if test="item.type != null">#{item.type},</if>
|
||||
<if test="item.mappingType != null">#{item.mappingType},</if>
|
||||
<if test="item.length != null">#{item.length},</if>
|
||||
<if test="item.decimalPlaces != null">#{item.decimalPlaces},</if>
|
||||
<if test="item.isNull != null">#{item.isNull},</if>
|
||||
<if test="item.isDict != null">#{item.isDict},</if>
|
||||
<if test="item.defaultValue != null">#{item.defaultValue},</if>
|
||||
<if test="item.dictKey != null">#{item.dictKey},</if>
|
||||
<if test="item.createBy != null and item.createBy != ''">#{item.createBy},</if>
|
||||
<if test="item.createTime != null">#{item.createTime},</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateAssetModel" parameterType="com.muyu.etl.domain.AssetModel">
|
||||
|
@ -181,6 +156,9 @@
|
|||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateAssetModelDiction">
|
||||
update asset_model_copy1 set is_dict = '',dictionary_id = null where dictionary_id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAssetModelById" parameterType="Long">
|
||||
delete from asset_model_copy1 where id = #{id}
|
||||
|
@ -192,10 +170,10 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="clearTable1" >
|
||||
<delete id="clearTable1">
|
||||
delete from asset_model_copy1 where data_asset_id in
|
||||
<foreach collection="id" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
<foreach collection="id" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into data_asset
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.etl.mapper.DataSourceMapper">
|
||||
|
||||
|
||||
|
@ -23,14 +23,16 @@
|
|||
<result property="maxWaitTime" column="max_wait_time" />
|
||||
<result property="connectionParam" column="connection_param" />
|
||||
<result property="systemName" column="systemName" />
|
||||
<result property="modeName" column="mode_ame" />
|
||||
<result property="type" column="type" />
|
||||
<result property="modeName" column="mode_name" />
|
||||
<result property="jdbcDriver" column="jdbcDriver" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDataSourceVo">
|
||||
select id, data_source_name,`type`,systemName, link_address,init_num, max_num, max_wait_size, max_wait_time,`table_name`,
|
||||
connection_param, port, database_name, username, password, mode_name,create_by, create_time, update_by, update_time, remark from datasource
|
||||
select id, data_source_name, link_address, port, database_name, username, password, connection_param, init_num, max_num, max_wait_time, max_wait_size, create_by, create_time, update_by, update_time, remark, type, systemName,jdbcDriver,mode_name from datasource
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectDataSourceList" parameterType="com.muyu.etl.domain.DataSource" resultMap="DataSourceResult">
|
||||
<include refid="selectDataSourceVo"/>
|
||||
<where>
|
||||
|
@ -40,6 +42,15 @@
|
|||
<if test="databaseName != null and databaseName != ''"> and database_name like concat('%', #{databaseName}, '%')</if>
|
||||
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
|
||||
<if test="password != null and password != ''"> and password = #{password}</if>
|
||||
<if test="connectionParam != null and connectionParam != ''"> and connection_param = #{connectionParam}</if>
|
||||
<if test="initNum != null "> and init_num = #{initNum}</if>
|
||||
<if test="maxNum != null "> and max_num = #{maxNum}</if>
|
||||
<if test="maxWaitTime != null "> and max_wait_time = #{maxWaitTime}</if>
|
||||
<if test="maxWaitSize != null "> and max_wait_size = #{maxWaitSize}</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="systemName != null and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
|
||||
<if test="modeName != null and modeName != ''"> and mode_name like concat('%', #{modeName}, '%')</if>
|
||||
<if test="jdbcDriver != null and jdbcDriver != ''"> and jdbcDriver like concat('%', #{jdbcDriver}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
@ -107,6 +118,8 @@
|
|||
<if test="maxWaitTime != null">max_wait_time,</if>
|
||||
<if test="connectionParam != null">connection_param,</if>
|
||||
<if test="systemName != null">systemName,</if>
|
||||
<if test="modeName != null">mode_name,</if>
|
||||
<if test="jdbcDriver != null">jdbcDriver,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="dataSourceName != null">#{dataSourceName},</if>
|
||||
|
@ -126,6 +139,8 @@
|
|||
<if test="maxWaitTime != null">#{maxWaitTime},</if>
|
||||
<if test="connectionParam != null">#{connectionParam},</if>
|
||||
<if test="systemName != null">#{systemName},</if>
|
||||
<if test="modeName != null">#{modeName},</if>
|
||||
<if test="jdbcDriver != null">#{jdbcDriver},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="batchInsert" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
|
||||
|
@ -166,7 +181,6 @@
|
|||
values
|
||||
<foreach collection="dataAssets" item="item" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
#{item.dataSourceId},
|
||||
#{item.tableName},
|
||||
#{item.tableComment},
|
||||
|
@ -191,6 +205,7 @@
|
|||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="initNum != null">init_num = #{initNum},</if>
|
||||
<if test="maxNum != null">max_num = #{maxNum},</if>
|
||||
|
@ -198,6 +213,8 @@
|
|||
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
|
||||
<if test="connectionParam != null">connection_param = #{connectionParam},</if>
|
||||
<if test="systemName != null">systemName = #{systemName},</if>
|
||||
<if test="modeName != null">mode_name = #{modeName},</if>
|
||||
<if test="jdbcDriver != null">jdbcDriver = #{jdbcDriver},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
|
@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
)
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
@ -136,4 +136,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="deleteSourceAccreditByUser">
|
||||
delete from source_accredit where datasource_id=#{dataSourceId} and user_id in
|
||||
<foreach item="sourceId" collection="sourceIds" open="(" separator="," close=")">
|
||||
#{sourceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue