master
Jiang Peng 2024-05-06 15:17:49 +08:00
parent ae35c4a607
commit cd276e0a8a
49 changed files with 556 additions and 526 deletions

View File

@ -13,6 +13,12 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/**
* @ClassName AssetAccreditController
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/28 14:30
*/
@RestController @RestController
@RequestMapping("assetAccredit") @RequestMapping("assetAccredit")
public class AssetAccreditController extends BaseController { public class AssetAccreditController extends BaseController {
@ -45,10 +51,10 @@ public class AssetAccreditController extends BaseController {
public Result add(@RequestBody AssetAccreditReq assetAccreditReq){ public Result add(@RequestBody AssetAccreditReq assetAccreditReq){
return assetAccreditService.insertAssetAccredit(assetAccreditReq); return assetAccreditService.insertAssetAccredit(assetAccreditReq);
} }
@PostMapping("/DeleteAssetAccreditByAsserIds") @PostMapping("/DeleteAssetAccreditByAssetIds")
public Result deleteAssetAccreditByAsserIds(@RequestBody AssetAccreditReq assetAccreditReq) public Result deleteAssetAccreditByAsserIds(@RequestBody AssetAccreditReq assetAccreditReq)
{ {
return assetAccreditService.deleteAssetAccreditByAssetId(assetAccreditReq); return assetAccreditService.deleteAssetAccreditByAssetIds(assetAccreditReq);
} }
@PutMapping @PutMapping
public Result edit(@RequestBody AssetAccredit assetAccredit){ public Result edit(@RequestBody AssetAccredit assetAccredit){

View File

@ -53,6 +53,7 @@ public class AssetModelController extends BaseController
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) public Result getInfo(@PathVariable("id") Long id)
{ {
return success(assetModelService.selectAssetModelById(id)); return success(assetModelService.selectAssetModelById(id));
} }
@ -83,4 +84,11 @@ public class AssetModelController extends BaseController
{ {
return toAjax(assetModelService.deleteAssetModelByIds(ids)); return toAjax(assetModelService.deleteAssetModelByIds(ids));
} }
/**
*
*
* @param assetModel
* @return Result.successResult.fail
*/
} }

View File

@ -1,18 +1,25 @@
package com.muyu.etl.controller; package com.muyu.etl.controller;
import com.muyu.common.core.domain.Result; import java.util.List;
import com.muyu.common.core.utils.poi.ExcelUtil; import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.etl.domain.DataAsset; import com.muyu.etl.domain.DataAsset;
import com.muyu.etl.domain.DataSource;
import com.muyu.etl.service.DataSourceService; import com.muyu.etl.service.DataSourceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletResponse; import org.springframework.web.bind.annotation.PutMapping;
import java.util.List; 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 * Controller
@ -30,7 +37,7 @@ public class DataSourceController extends BaseController
/** /**
* *
*/ */
@RequiresPermissions("system:source:list") // @RequiresPermissions("system:source:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<DataSource>> list(DataSource dataSource) public Result<TableDataInfo<DataSource>> list(DataSource dataSource)
{ {
@ -111,7 +118,6 @@ public class DataSourceController extends BaseController
public Result synchronization(@RequestBody DataSource dataSource){ public Result synchronization(@RequestBody DataSource dataSource){
return dataSourceService.synchronization(dataSource); return dataSourceService.synchronization(dataSource);
} }
@PostMapping("dataAssetList") @PostMapping("dataAssetList")
public Result dataAssetList(@RequestBody DataSource dataSource){ public Result dataAssetList(@RequestBody DataSource dataSource){
return dataSourceService.dataAssetList(dataSource); return dataSourceService.dataAssetList(dataSource);

View File

@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil; import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.Dictionary; import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.service.DictionaryService; import com.muyu.etl.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -14,10 +14,10 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("sourceAccredit") @RequestMapping("sourceAccredit")
public class SourceAccreditController extends BaseController public class SourceAccreditController extends BaseController {
{
@Autowired @Autowired
private SourceAccreditService sourceAccreditService; private SourceAccreditService sourceAccreditService;

View File

@ -3,6 +3,7 @@ package com.muyu.etl.domain;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@ -14,6 +15,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class AssetAccredit extends BaseEntity { public class AssetAccredit extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ /** $column.columnComment */
@ -33,40 +35,32 @@ public class AssetAccredit extends BaseEntity {
private Long userId; private Long userId;
public void setId(Long id) public void setId(Long id) {
{
this.id = id; this.id = id;
} }
public Long getId() public Long getId() {
{
return id; return id;
} }
public void setDeptId(Long deptId) public void setDeptId(Long deptId) {
{
this.deptId = deptId; this.deptId = deptId;
} }
public Long getDeptId() public Long getDeptId() {
{
return deptId; return deptId;
} }
public void setDataAssetId(Long dataAssetId) public void setDataAssetId(Long dataAssetId) {
{
this.dataAssetId = dataAssetId; this.dataAssetId = dataAssetId;
} }
public Long getDataAssetId() public Long getDataAssetId() {
{
return dataAssetId; return dataAssetId;
} }
public void setUserId(Long userId) public void setUserId(Long userId) {
{
this.userId = userId; this.userId = userId;
} }
public Long getUserId() public Long getUserId() {
{
return userId; return userId;
} }
@ -84,4 +78,5 @@ public class AssetAccredit extends BaseEntity {
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.toString(); .toString();
} }
} }

View File

@ -8,137 +8,43 @@ import lombok.experimental.SuperBuilder;
import java.util.List; import java.util.List;
/**
* @ClassName AssetModel
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/22 19:39
*/
@Data @Data
@SuperBuilder @SuperBuilder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class AssetModel extends BaseEntity { public class AssetModel extends BaseEntity {
private Long id; private Long id;
private Long dataAssetId; private Long dataAssetId;
private String name; private String name;
private String comment; private String comment;
private String isPrimaryKey; private String isPrimaryKey;
private String type; private String type;
private String mappingType; private String mappingType;
private String length; private String length;
private String decimalPlaces; private String decimalPlaces;
private String isNull; private String isNull;
private String defaultValue; private String defaultValue;
private String isDict; private String isDict;
private String dictKey; private String dictKey;
/** /**
* ID * ID
*/ */
private Long dictionaryId; private Long dictionaryId;
private List<DictionaryData> dictionaryDatas; 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;
}
} }

View File

@ -14,7 +14,20 @@ import java.util.Map;
@NoArgsConstructor @NoArgsConstructor
@Builder @Builder
public class AssetsModule { public class AssetsModule {
private HashMap<String,String> structure; private HashMap<String,String> structure;
private List<Map<String,VTClass>> kvtList; private List<Map<String,VTClass>> kvtList;
private List<TableAssets> tableAssets; 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();
}
} }

View File

@ -8,36 +8,50 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date; import java.util.Date;
/**
* @ClassName DataAsset
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/22 20:41
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class DataAsset extends BaseEntity { public class DataAsset extends BaseEntity {
private Long id; private Long id;
private Long dataSourceId; private Long dataSourceId;
private String tableName; private String tableName;
private String tableComment; private String tableComment;
private Long tableCount; private Long tableCount;
private Long fields; 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() return DataAsset.builder()
.id(dataAsset.getId()) .tableName(resultSet.getString("t_name"))
.dataSourceId(dataAsset.getDataSourceId()) .tableComment(resultSet.getString("table_comment")==null ? "" : resultSet.getString("table_comment"))
.tableName(dataAsset.getTableName()) .tableCount(Long.valueOf(resultSet.getString("table_rows")))
.tableComment(dataAsset.getTableComment()) .fields(Long.valueOf(resultSet.getString("fields")))
.tableCount(dataAsset.getTableCount()) .dataSourceId(dataSource.getId())
.fields(dataAsset.getFields()) .createBy(SecurityUtils.getUsername())
.updateBy(SecurityUtils.getUsername()) .createTime(new Date())
.updateTime(new Date())
.build(); .build();
}catch (SQLException e){
// 捕获并抛出SQL异常为运行时异常
throw new RuntimeException(e);
} }
}
} }

View File

@ -13,23 +13,43 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class DataSource extends BaseEntity { public class DataSource extends BaseEntity {
private Long id; private Long id;
private String port; private String port;
private String username; private String username;
private String password; private String password;
private String LinkAddress; private String LinkAddress;
private String dataSourceName; private String dataSourceName;
private String databaseName; private String databaseName;
private Long initNum; private Long initNum;
private Long maxNum; private Long maxNum;
private Long maxWaitSize; private Long maxWaitSize;
private Long maxWaitTime; private Long maxWaitTime;
private String connectionParam; private String connectionParam;
private String systemName; private String systemName;
private String sql; private String sql;
private String type; private String type;
private String tableName; private String tableName;
private List<TableDetail> tableList; private List<TableDetail> tableList;
private String modeName; private String modeName;
private String jdbcDriver; private String jdbcDriver;
} }

View File

@ -7,34 +7,34 @@ import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
/**
* @ClassName Dictionary
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/25 15:02
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class Dictionary extends BaseEntity { public class Dictionary extends BaseEntity {
/** /**
* *
*/ */
private Long id; private Long id;
/** /**
* *
*/ */
private String dictionaryName; private String dictionaryName;
/** /**
* Key * Key
*/ */
private String dictionaryKey; private String dictionaryKey;
/** /**
* ID * ID
*/ */
private Long dataSourceId; private Long dataSourceId;
/** /**
* *
*/ */
private List<DictionaryData> dictionaryDataList; private List<DictionaryData> dictionaryDataList;
} }

View File

@ -7,33 +7,33 @@ import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
/**
* @ClassName DictionaryData
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/25 15:05
*/
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class DictionaryData extends BaseEntity { public class DictionaryData extends BaseEntity {
private Long id; private Long id;
/** /**
* Id * Id
*/ */
private Long dictionaryId; private Long dictionaryId;
/** /**
* *
*/ */
private String label; private String label;
/** /**
* *
*/ */
private String val; private String val;
private List<Dictionary> dictionaryDatas; private List<Dictionary> dictionaryDatas;
/** /**
* *
*/ */
private Boolean isEdit = false; private Boolean isEdit = false;
} }

View File

@ -14,6 +14,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class SourceAccredit extends BaseEntity { public class SourceAccredit extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ /** $column.columnComment */
@ -33,13 +34,11 @@ public class SourceAccredit extends BaseEntity {
private Long userId; private Long userId;
public void setId(Long id) public void setId(Long id) {
{
this.id = id; this.id = id;
} }
public Long getId() public Long getId() {
{
return id; return id;
} }
@ -59,13 +58,11 @@ public class SourceAccredit extends BaseEntity {
this.dataSourceId = dataSourceId; this.dataSourceId = dataSourceId;
} }
public void setUserId(Long userId) public void setUserId(Long userId) {
{
this.userId = userId; this.userId = userId;
} }
public Long getUserId() public Long getUserId() {
{
return userId; return userId;
} }
@ -83,4 +80,5 @@ public class SourceAccredit extends BaseEntity {
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.toString(); .toString();
} }
} }

View File

@ -10,9 +10,15 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@Builder @Builder
public class TableAssets { public class TableAssets {
private String Field; private String Field;
private String Type; private String Type;
private String Null; private String Null;
private String Key; private String Key;
private String Default; private String Default;
} }

View File

@ -10,8 +10,13 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class TableDetail { public class TableDetail {
private String tableName; private String tableName;
private String tableComment; private String tableComment;
private Long tableCount; private Long tableCount;
private List<TableAssets> tableAssets; private List<TableAssets> tableAssets;
} }

View File

@ -10,6 +10,9 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@Builder @Builder
public class VTClass { public class VTClass {
private String value; private String value;
private String type; private String type;
} }

View File

@ -5,23 +5,17 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
public class Statistics { public class Statistics {
/** // 数据资产ID
* ID
*/
private Long dataAsset; private Long dataAsset;
/** // 资产模型ID
* ID
*/
private Long assetModel; private Long assetModel;
/** // 数据模型ID
* ID
*/
private Long dataModel; private Long dataModel;
} }

View File

@ -12,6 +12,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
public class AccreditModel { public class AccreditModel {
/** /**
* ID * ID
*/ */
@ -21,4 +22,5 @@ public class AccreditModel {
* ID * ID
*/ */
private List<Long> deptAccreditModelIds; private List<Long> deptAccreditModelIds;
} }

View File

@ -8,11 +8,15 @@ import lombok.experimental.SuperBuilder;
import java.util.List; import java.util.List;
@Data @Data
@AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@SuperBuilder @SuperBuilder
@AllArgsConstructor
public class AssetAccreditReq { public class AssetAccreditReq {
private List<Long> deptIds; private List<Long> deptIds;
private Long userId; private Long userId;
private Long dataAssetId; private Long dataAssetId;
} }

View File

@ -8,11 +8,15 @@ import lombok.experimental.SuperBuilder;
import java.util.List; import java.util.List;
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder @SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class SourceAccreditReq { public class SourceAccreditReq {
private List<Long> deptIds; private List<Long> deptIds;
private Long userId; private Long userId;
private Long dataSourceId; private Long dataSourceId;
} }

View File

@ -4,11 +4,14 @@ import com.muyu.etl.domain.AssetAccredit;
import com.muyu.etl.domain.req.AssetAccreditReq; import com.muyu.etl.domain.req.AssetAccreditReq;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.PropertyValues;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface AssetAccreditMapper { public interface AssetAccreditMapper {
List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit); List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit);
public AssetAccredit selectAssetAccreditById(Long id); public AssetAccredit selectAssetAccreditById(Long id);
@ -28,4 +31,7 @@ public interface AssetAccreditMapper {
List<AssetAccredit> getSourceAccreditByUserId(Long userId); List<AssetAccredit> getSourceAccreditByUserId(Long userId);
void insertBachAssetAccredit(@Param("assetAccredits") List<AssetAccredit> assetAccredits); void insertBachAssetAccredit(@Param("assetAccredits") List<AssetAccredit> assetAccredits);
void deleteAssetAccreditByUser(List<Long> longs, Long dataAssetId);
} }

View File

@ -13,8 +13,8 @@ import java.util.List;
* @date 2024-04-22 * @date 2024-04-22
*/ */
@Mapper @Mapper
public interface AssetModelMapper public interface AssetModelMapper {
{
/** /**
* *
* *
@ -63,10 +63,10 @@ public interface AssetModelMapper
*/ */
public int deleteAssetModelByIds(Long[] ids); public int deleteAssetModelByIds(Long[] ids);
int clearTable1(@Param("id") Long[] id); int clearTable1(@Param("id") Long[] id);
void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets); void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets);
void updateAssetModelDiction(Long id); void updateAssetModelDiction(Long id);
} }

View File

@ -14,8 +14,8 @@ import java.util.List;
* @date 2024-04-22 * @date 2024-04-22
*/ */
@Mapper @Mapper
public interface DataAssetMapper public interface DataAssetMapper {
{
/** /**
* *
* *
@ -65,7 +65,9 @@ public interface DataAssetMapper
public int deleteDataAssetByIds(Long[] ids); public int deleteDataAssetByIds(Long[] ids);
void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets); void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets);
List<DataAsset> selectById(Long id); List<DataAsset> selectById(Long id);
List<DataAsset> getDataAssetByAssetId(@Param("assetIds") List<Long> assetIds); List<DataAsset> getDataAssetByAssetId(@Param("assetIds") List<Long> assetIds);
} }

View File

@ -1,14 +1,16 @@
package com.muyu.etl.mapper; 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.ArrayList;
import java.util.List; 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 * Mapper
* *
@ -16,8 +18,8 @@ import java.util.List;
* @date 2024-04-20 * @date 2024-04-20
*/ */
@Mapper @Mapper
public interface DataSourceMapper public interface DataSourceMapper {
{
/** /**
* *
* *
@ -66,17 +68,14 @@ public interface DataSourceMapper
*/ */
public int deleteDataSourceByIds(Long[] ids); public int deleteDataSourceByIds(Long[] ids);
List<AssetModel> getAssetModel(String databaseName, String assetModule); List<AssetModel> getAssetModel(String databaseName, String assetModule);
void batchAdd( @Param("dataAssets") ArrayList<DataAsset> dataAssets); void batchAdd( @Param("dataAssets") ArrayList<DataAsset> dataAssets);
int clearTable(@Param("id") Long[] id); int clearTable(@Param("id") Long[] id);
List<DataAsset> selectDataAssetBachId(@Param("longs") List<Long> longs); List<DataAsset> selectDataAssetBachId(@Param("longs") List<Long> longs);
List<DataSource> selectId(Long id); List<DataSource> selectId(Long id);
} }

View File

@ -1,11 +1,17 @@
package com.muyu.etl.mapper; package com.muyu.etl.mapper;
import java.util.List;
import com.muyu.etl.domain.DictionaryData; import com.muyu.etl.domain.DictionaryData;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; /**
* Mapper
*
* @author ruoyi
* @date 2024-04-24
*/
public interface DictionaryDataMapper { public interface DictionaryDataMapper {
/** /**
* *
* *

View File

@ -1,11 +1,18 @@
package com.muyu.etl.mapper; package com.muyu.etl.mapper;
import java.util.List;
import com.muyu.etl.domain.Dictionary; import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.domain.DictionaryData;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; /**
* Mapper
*
* @author ruoyi
* @date 2024-04-24
*/
public interface DictionaryMapper { public interface DictionaryMapper {
/** /**
* *
* *
@ -54,7 +61,8 @@ public interface DictionaryMapper {
*/ */
public int deleteDictionaryByIds(Long[] ids); public int deleteDictionaryByIds(Long[] ids);
List<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId); List<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId);
List<Dictionary> getDictionaryDataList(@Param("string") List<String> string); List<Dictionary> getDictionaryDataList(@Param("string") List<String> string);
} }

View File

@ -3,6 +3,7 @@ package com.muyu.etl.mapper;
import com.muyu.etl.domain.SourceAccredit; import com.muyu.etl.domain.SourceAccredit;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -13,8 +14,8 @@ import java.util.List;
* @date 2024-04-25 * @date 2024-04-25
*/ */
@Mapper @Mapper
public interface SourceAccreditMapper public interface SourceAccreditMapper {
{
/** /**
* *
* *
@ -72,4 +73,7 @@ public interface SourceAccreditMapper
void insertBatchSourceAccredit(@Param("sourceAccredits") List<SourceAccredit> sourceAccredits); void insertBatchSourceAccredit(@Param("sourceAccredits") List<SourceAccredit> sourceAccredits);
void deleteSourceAccreditByDeptUser(@Param("deptIds") List<Long> deptIds, @Param("userId") Long userId, @Param("dataSourceId") Long dataSourceId); void deleteSourceAccreditByDeptUser(@Param("deptIds") List<Long> deptIds, @Param("userId") Long userId, @Param("dataSourceId") Long dataSourceId);
void deleteSourceAccreditByUser(List<Long> longs, Long dataSourceId);
} }

View File

@ -3,22 +3,27 @@ package com.muyu.etl.service;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.etl.domain.AssetAccredit; import com.muyu.etl.domain.AssetAccredit;
import com.muyu.etl.domain.req.AssetAccreditReq; import com.muyu.etl.domain.req.AssetAccreditReq;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@Service @Service
public interface AssetAccreditService { public interface AssetAccreditService {
List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit); List<AssetAccredit> selectAssetAccreditList(AssetAccredit assetAccredit);
AssetAccredit selectAssetAccreditById(Long id); AssetAccredit selectAssetAccreditById(Long id);
public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq); public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq);
public int updateAssetAccredit(AssetAccredit assetAccredit); public int updateAssetAccredit(AssetAccredit assetAccredit);
public int deleteAssetAccreditByIds(Long[] ids); public int deleteAssetAccreditByIds(Long[] ids);
public int deleteAssetAccreditById(Long id); public int deleteAssetAccreditById(Long id);
Result getAssetAccreditByDataAssetId(Long id); Result getAssetAccreditByDataAssetId(Long id);
Result deleteAssetAccreditByAssetId(AssetAccreditReq assetAccreditReq); Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq);
} }

View File

@ -10,8 +10,8 @@ import java.util.List;
* @author ruoyi * @author ruoyi
* @date 2024-04-22 * @date 2024-04-22
*/ */
public interface AssetModelService public interface AssetModelService {
{
/** /**
* *
* *
@ -59,4 +59,5 @@ public interface AssetModelService
* @return * @return
*/ */
public int deleteAssetModelById(Long id); public int deleteAssetModelById(Long id);
} }

View File

@ -10,8 +10,8 @@ import java.util.List;
* @author ruoyi * @author ruoyi
* @date 2024-04-22 * @date 2024-04-22
*/ */
public interface DataAssetService public interface DataAssetService {
{
/** /**
* *
* *
@ -59,4 +59,5 @@ public interface DataAssetService
* @return * @return
*/ */
public int deleteDataAssetById(Long id); public int deleteDataAssetById(Long id);
} }

View File

@ -14,8 +14,8 @@ import java.util.List;
* @date 2024-04-20 * @date 2024-04-20
*/ */
@Service @Service
public interface DataSourceService public interface DataSourceService {
{
/** /**
* *
* *
@ -64,6 +64,7 @@ public interface DataSourceService
*/ */
public int deleteDataSourceById(Long id); public int deleteDataSourceById(Long id);
Result test(DataSource dataSource); Result test(DataSource dataSource);
Result assetsList(DataSource dataSource); Result assetsList(DataSource dataSource);
@ -77,4 +78,5 @@ public interface DataSourceService
Result assetModelList(DataAsset dataAsset); Result assetModelList(DataAsset dataAsset);
Result statisticsInfo(); Result statisticsInfo();
} }

View File

@ -5,8 +5,15 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-04-24
*/
@Service @Service
public interface DictionaryDataService { public interface DictionaryDataService {
/** /**
* *
* *
@ -54,4 +61,5 @@ public interface DictionaryDataService {
* @return * @return
*/ */
public int deleteDictionaryDataById(Long id); public int deleteDictionaryDataById(Long id);
} }

View File

@ -5,9 +5,16 @@ import com.muyu.etl.domain.Dictionary;
import java.util.List; import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-04-24
*/
public interface DictionaryService { public interface DictionaryService {
/** /**
* * 0
* *
* @param id * @param id
* @return * @return
@ -53,7 +60,9 @@ public interface DictionaryService {
* @return * @return
*/ */
public int deleteDictionaryById(Long id); public int deleteDictionaryById(Long id);
Result getDictionaryList(Long dataSourceId); Result getDictionaryList(Long dataSourceId);
Result delDict(Long id); Result delDict(Long id);
} }

View File

@ -14,8 +14,8 @@ import java.util.List;
* @date 2024-04-25 * @date 2024-04-25
*/ */
@Service @Service
public interface SourceAccreditService public interface SourceAccreditService {
{
/** /**
* *
* *
@ -67,4 +67,5 @@ public interface SourceAccreditService
Result getSourceAccreditByDataSourceId(Long id); Result getSourceAccreditByDataSourceId(Long id);
Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq); Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq);
} }

View File

@ -3,12 +3,15 @@ package com.muyu.etl.service.impl;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils; 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.AssetAccredit;
import com.muyu.etl.domain.model.AccreditModel; import com.muyu.etl.domain.model.AccreditModel;
import com.muyu.etl.domain.req.AssetAccreditReq; import com.muyu.etl.domain.req.AssetAccreditReq;
import com.muyu.etl.mapper.AssetAccreditMapper; import com.muyu.etl.mapper.AssetAccreditMapper;
import com.muyu.etl.service.AssetAccreditService; import com.muyu.etl.service.AssetAccreditService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.embedded.undertow.UndertowWebServer;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,8 +39,9 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
@Override @Override
public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq) { public Result insertAssetAccredit(AssetAccreditReq assetAccreditReq) {
// 根据资产ID删除资产授权信息 // 根据资产ID删除资产授权信息
deleteAssetAccreditByAssetId(assetAccreditReq); deleteAssetAccreditByAssetIds(assetAccreditReq);
List<AssetAccredit> assetAccredits = new ArrayList<>(); List<AssetAccredit> assetAccredits = new ArrayList<>();
// 判断用户ID是否为空不为空则为用户授权为空则为部门授权 // 判断用户ID是否为空不为空则为用户授权为空则为部门授权
if (assetAccreditReq.getUserId()!=null){ if (assetAccreditReq.getUserId()!=null){
@ -49,8 +53,7 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
assetAccredit.setCreateTime(new Date()); assetAccredit.setCreateTime(new Date());
assetAccredits.add(assetAccredit); assetAccredits.add(assetAccredit);
}else{ }else{
// 为部门授权时循环遍历部门ID创建相应的资产授权信息 assetAccredits.addAll( assetAccreditReq.getDeptIds().stream()
assetAccreditReq.getDeptIds().stream()
.map(deptId ->{ .map(deptId ->{
AssetAccredit assetAccredit = new AssetAccredit(); AssetAccredit assetAccredit = new AssetAccredit();
assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId()); assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId());
@ -58,7 +61,8 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
assetAccredit.setCreateBy(SecurityUtils.getUsername()); assetAccredit.setCreateBy(SecurityUtils.getUsername());
assetAccredit.setCreateTime(new Date()); assetAccredit.setCreateTime(new Date());
return assetAccredit; return assetAccredit;
}).toList(); }).toList());
// 为部门授权时循环遍历部门ID创建相应的资产授权信息
} }
// 将资产授权信息插入数据库 // 将资产授权信息插入数据库
assetAccreditMapper.insertBachAssetAccredit(assetAccredits); assetAccreditMapper.insertBachAssetAccredit(assetAccredits);
@ -71,7 +75,6 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
return assetAccreditMapper.updateAssetAccredit(assetAccredit); return assetAccreditMapper.updateAssetAccredit(assetAccredit);
} }
@Override @Override
public int deleteAssetAccreditByIds(Long[] ids) { public int deleteAssetAccreditByIds(Long[] ids) {
return assetAccreditMapper.deleteAssetAccreditByIds(ids); return assetAccreditMapper.deleteAssetAccreditByIds(ids);
@ -93,40 +96,29 @@ public class AssetAccreditServiceImpl implements AssetAccreditService {
public Result getAssetAccreditByDataAssetId(Long id) { public Result getAssetAccreditByDataAssetId(Long id) {
// 通过数据资产ID查询所有的资产授权信息 // 通过数据资产ID查询所有的资产授权信息
List<AssetAccredit> assetAccreditList = assetAccreditMapper.getAssetAccreditByDataAssetId(id); List<AssetAccredit> assetAccreditList = assetAccreditMapper.getAssetAccreditByDataAssetId(id);
// 通过流操作取出部门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集合过滤掉空值 // 通过流操作取出用户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集合 // 创建授权模型并设置部门和用户授权ID集合
AccreditModel accreditModel = new AccreditModel(); AccreditModel accreditModel = new AccreditModel();
accreditModel.setDeptAccreditModelIds(deptListIds); accreditModel.setDeptAccreditModelIds(deptAccreditIds);
accreditModel.setUserAccreditModelIds(userListIds); accreditModel.setUserAccreditModelIds(userAccreditIds);
// 返回成功结果,包含授权模型 // 返回成功结果,包含授权模型
return Result.success(accreditModel); return Result.success(accreditModel);
} }
@Override @Override
public Result deleteAssetAccreditByAssetId(AssetAccreditReq assetAccreditReq) public Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq)
{ {
/**
*
* IDIDID
* IDIDID
*
* @param assetAccreditReq IDIDID
* @return
*/
if (assetAccreditReq.getUserId()!=null){ if (assetAccreditReq.getUserId()!=null){
// 根据用户ID和数据资产ID删除授权记录 // 根据用户ID和数据资产ID删除授权记录
assetAccreditMapper.deleteAssetAccreditByDeptUser(null,assetAccreditReq.getUserId(),assetAccreditReq.getDataAssetId()); assetAccreditMapper.deleteAssetAccreditByDeptUser(null,assetAccreditReq.getUserId(),assetAccreditReq.getDataAssetId());
}else{ }else{
// 根据部门ID列表和数据资产ID删除授权记录
assetAccreditMapper.deleteAssetAccreditByDeptUser(assetAccreditReq.getDeptIds(),null,assetAccreditReq.getDataAssetId()); assetAccreditMapper.deleteAssetAccreditByDeptUser(assetAccreditReq.getDeptIds(),null,assetAccreditReq.getDataAssetId());
} }
return Result.success(); return Result.success();
} }
} }

View File

@ -16,8 +16,8 @@ import java.util.List;
* @date 2024-04-22 * @date 2024-04-22
*/ */
@Service @Service
public class AssetModelServiceImpl implements AssetModelService public class AssetModelServiceImpl implements AssetModelService {
{
@Autowired @Autowired
private AssetModelMapper assetModelMapper; private AssetModelMapper assetModelMapper;
@ -28,8 +28,7 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public AssetModel selectAssetModelById(Long id) public AssetModel selectAssetModelById(Long id) {
{
return assetModelMapper.selectAssetModelById(id); return assetModelMapper.selectAssetModelById(id);
} }
@ -40,8 +39,7 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public List<AssetModel> selectAssetModelList(AssetModel assetModel) public List<AssetModel> selectAssetModelList(AssetModel assetModel) {
{
return assetModelMapper.selectAssetModelList(assetModel); return assetModelMapper.selectAssetModelList(assetModel);
} }
@ -52,8 +50,7 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public int insertAssetModel(AssetModel assetModel) public int insertAssetModel(AssetModel assetModel) {
{
assetModel.setCreateTime(DateUtils.getNowDate()); assetModel.setCreateTime(DateUtils.getNowDate());
return assetModelMapper.insertAssetModel(assetModel); return assetModelMapper.insertAssetModel(assetModel);
} }
@ -65,8 +62,7 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public int updateAssetModel(AssetModel assetModel) public int updateAssetModel(AssetModel assetModel) {
{
assetModel.setUpdateTime(DateUtils.getNowDate()); assetModel.setUpdateTime(DateUtils.getNowDate());
return assetModelMapper.updateAssetModel(assetModel); return assetModelMapper.updateAssetModel(assetModel);
} }
@ -78,8 +74,7 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public int deleteAssetModelByIds(Long[] ids) public int deleteAssetModelByIds(Long[] ids) {
{
return assetModelMapper.deleteAssetModelByIds(ids); return assetModelMapper.deleteAssetModelByIds(ids);
} }
@ -90,8 +85,8 @@ public class AssetModelServiceImpl implements AssetModelService
* @return * @return
*/ */
@Override @Override
public int deleteAssetModelById(Long id) public int deleteAssetModelById(Long id) {
{
return assetModelMapper.deleteAssetModelById(id); return assetModelMapper.deleteAssetModelById(id);
} }
} }

View File

@ -16,8 +16,8 @@ import java.util.List;
* @date 2024-04-22 * @date 2024-04-22
*/ */
@Service @Service
public class DataAssetServiceImpl implements DataAssetService public class DataAssetServiceImpl implements DataAssetService {
{
@Autowired @Autowired
private DataAssetMapper dataAssetMapper; private DataAssetMapper dataAssetMapper;
@ -28,8 +28,7 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public DataAsset selectDataAssetById(Long id) public DataAsset selectDataAssetById(Long id) {
{
return dataAssetMapper.selectDataAssetById(id); return dataAssetMapper.selectDataAssetById(id);
} }
@ -40,8 +39,7 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public List<DataAsset> selectDataAssetList(DataAsset dataAsset) public List<DataAsset> selectDataAssetList(DataAsset dataAsset) {
{
return dataAssetMapper.selectDataAssetList(dataAsset); return dataAssetMapper.selectDataAssetList(dataAsset);
} }
@ -52,8 +50,7 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public int insertDataAsset(DataAsset dataAsset) public int insertDataAsset(DataAsset dataAsset) {
{
dataAsset.setCreateTime(DateUtils.getNowDate()); dataAsset.setCreateTime(DateUtils.getNowDate());
return dataAssetMapper.insertDataAsset(dataAsset); return dataAssetMapper.insertDataAsset(dataAsset);
} }
@ -65,8 +62,7 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public int updateDataAsset(DataAsset dataAsset) public int updateDataAsset(DataAsset dataAsset) {
{
dataAsset.setUpdateTime(DateUtils.getNowDate()); dataAsset.setUpdateTime(DateUtils.getNowDate());
return dataAssetMapper.updateDataAsset(dataAsset); return dataAssetMapper.updateDataAsset(dataAsset);
} }
@ -78,8 +74,7 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public int deleteDataAssetByIds(Long[] ids) public int deleteDataAssetByIds(Long[] ids) {
{
return dataAssetMapper.deleteDataAssetByIds(ids); return dataAssetMapper.deleteDataAssetByIds(ids);
} }
@ -90,8 +85,8 @@ public class DataAssetServiceImpl implements DataAssetService
* @return * @return
*/ */
@Override @Override
public int deleteDataAssetById(Long id) public int deleteDataAssetById(Long id) {
{
return dataAssetMapper.deleteDataAssetById(id); return dataAssetMapper.deleteDataAssetById(id);
} }
} }

View File

@ -1,6 +1,11 @@
package com.muyu.etl.service.impl; 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.domain.Result;
import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.sql.*;
import java.util.Date;
import java.util.*;
/** /**
* Service * Service
* *
@ -24,7 +25,7 @@ import java.util.*;
* @date 2024-04-20 * @date 2024-04-20
*/ */
@Service @Service
public class DataSourceServiceImpl implements DataSourceService{ public class DataSourceServiceImpl implements DataSourceService {
@Autowired @Autowired
private DataSourceMapper dataSourceMapper; private DataSourceMapper dataSourceMapper;
@ -51,8 +52,7 @@ public class DataSourceServiceImpl implements DataSourceService{
* @return * @return
*/ */
@Override @Override
public DataSource selectDataSourceById(Long id) public DataSource selectDataSourceById(Long id) {
{
return dataSourceMapper.selectDataSourceById(id); return dataSourceMapper.selectDataSourceById(id);
} }
@ -97,10 +97,10 @@ public class DataSourceServiceImpl implements DataSourceService{
public int insertDataSource(DataSource dataSource) { public int insertDataSource(DataSource dataSource) {
dataSource.setCreateTime(DateUtils.getNowDate()); dataSource.setCreateTime(DateUtils.getNowDate());
dataSource.setCreateBy(SecurityUtils.getUsername()); dataSource.setCreateBy(SecurityUtils.getUsername());
if("Mysql".equals(dataSource.getType())){ if (dataSource.getType().equals("MySql")){
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver"); dataSource.setType("com.mysql.cj.jdbc.Driver");
}else { }else{
dataSource.setJdbcDriver("org.postgresql.Driver"); dataSource.setType("org.postgresql.Driver");
} }
return dataSourceMapper.insertDataSource(dataSource); return dataSourceMapper.insertDataSource(dataSource);
} }
@ -112,8 +112,7 @@ public class DataSourceServiceImpl implements DataSourceService{
* @return * @return
*/ */
@Override @Override
public int updateDataSource(DataSource dataSource) public int updateDataSource(DataSource dataSource) {
{
dataSource.setUpdateTime(DateUtils.getNowDate()); dataSource.setUpdateTime(DateUtils.getNowDate());
dataSource.setUpdateBy(SecurityUtils.getUsername()); dataSource.setUpdateBy(SecurityUtils.getUsername());
return dataSourceMapper.updateDataSource(dataSource); return dataSourceMapper.updateDataSource(dataSource);
@ -126,8 +125,7 @@ public class DataSourceServiceImpl implements DataSourceService{
* @return * @return
*/ */
@Override @Override
public int deleteDataSourceByIds(Long[] ids) public int deleteDataSourceByIds(Long[] ids) {
{
return dataSourceMapper.deleteDataSourceByIds(ids); return dataSourceMapper.deleteDataSourceByIds(ids);
} }
@ -138,30 +136,24 @@ public class DataSourceServiceImpl implements DataSourceService{
* @return * @return
*/ */
@Override @Override
public int deleteDataSourceById(Long id) public int deleteDataSourceById(Long id) {
{
return dataSourceMapper.deleteDataSourceById(id); return dataSourceMapper.deleteDataSourceById(id);
} }
@Override @Override
public Result test(DataSource dataSource) { public Result test(DataSource dataSource) {
//获取用户 String url="jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
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();
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){ if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
url = url +"?"+dataSource.getConnectionParam(); url = url +"?"+dataSource.getConnectionParam();
} }
Connection con = null; Connection con = null;
try{ try{
Class.forName(jdbcDriver); Class.forName(dataSource.getJdbcDriver());
}catch (Exception e){ }catch (Exception e){
return Result.error("数据源查询失败"); return Result.error("数据源查询失败");
} }
try{ try{
con = DriverManager.getConnection(url,username,password); con = DriverManager.getConnection(url,dataSource.getUsername(),dataSource.getPassword());
con.close(); con.close();
}catch (Exception e){ }catch (Exception e){
return Result.error("数据源查询失败"); return Result.error("数据源查询失败");
@ -169,21 +161,29 @@ public class DataSourceServiceImpl implements DataSourceService{
return Result.success("链接成功咯"); return Result.success("链接成功咯");
} }
/**
* DataSource
* @param dataSource
* @param tableName
* @return Java
*/
public Map<String,String> getTypeMap(DataSource dataSource,String tableName){ public Map<String,String> getTypeMap(DataSource dataSource,String tableName){
// 初始化JDBC URL和SQL查询语句
String jdbcUrl =""; String jdbcUrl ="";
String sql=""; String sql="";
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName(); jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
// 根据数据源类型设置SQL语句
if (dataSource.getType().equals("MySql")){ if (dataSource.getType().equals("MySql")){
sql = "select * from"+tableName; sql = "select * from "+tableName;
}else{ }else{
sql = "select * from"+dataSource.getModeName()+"."+tableName; sql = "select * from "+dataSource.getModeName()+"."+tableName;
} }
Connection con = null; Connection con = null;
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
try{ try{
Class.forName(dataSource.getJdbcDriver()); // 加载 JDBC 驱动并获取数据库连接
con = DriverManager.getConnection(jdbcUrl,dataSource.getUsername(),dataSource.getPassword()); con = DriverManager.getConnection(jdbcUrl,dataSource.getUsername(),dataSource.getPassword());
}catch (SQLException | ClassNotFoundException e){ }catch (SQLException e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }
try{ try{
@ -191,7 +191,8 @@ public class DataSourceServiceImpl implements DataSourceService{
pst = con.prepareStatement(sql); pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery(); ResultSet rs = pst.executeQuery();
ResultSetMetaData metaData = rs.getMetaData(); ResultSetMetaData metaData = rs.getMetaData();
for (int i = 0; i < metaData.getColumnCount(); i++) { // 遍历结果集元数据获取列名和对应的Java类型名称
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String sub= ""; String sub= "";
if (metaData.getColumnClassName(i).contains(".")){ if (metaData.getColumnClassName(i).contains(".")){
String[] s=metaData.getColumnClassName(i).split("\\."); String[] s=metaData.getColumnClassName(i).split("\\.");
@ -210,41 +211,6 @@ public class DataSourceServiceImpl implements DataSourceService{
return map; 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 * @param dataSource
@ -259,10 +225,9 @@ public class DataSourceServiceImpl implements DataSourceService{
Map<String, String> typeMap = getTypeMap(dataSource, tableName); Map<String, String> typeMap = getTypeMap(dataSource, tableName);
try{ try{
// 加载JDBC驱动 // 加载JDBC驱动
Class.forName(dataSource.getJdbcDriver());
// 建立数据库连接 // 建立数据库连接
con = DriverManager.getConnection(url,dataSource.getUsername(),dataSource.getPassword()); con = DriverManager.getConnection(url,dataSource.getUsername(),dataSource.getPassword());
}catch (SQLException | ClassNotFoundException exception){ }catch (SQLException exception){
// 抛出运行时异常 // 抛出运行时异常
throw new RuntimeException(exception); throw new RuntimeException(exception);
} }
@ -299,7 +264,6 @@ public class DataSourceServiceImpl implements DataSourceService{
.build(); // 构建并返回字段信息对象 .build(); // 构建并返回字段信息对象
tableAssets.add(build); tableAssets.add(build);
} }
columnsRS.close(); columnsRS.close();
primaryKeyRS.close(); primaryKeyRS.close();
}catch (SQLException e){ }catch (SQLException e){
@ -307,7 +271,14 @@ public class DataSourceServiceImpl implements DataSourceService{
} }
return tableAssets; return tableAssets;
} }
//获取表结构 /**
* DataSourceAssetsModule
* AssetModel
* AssetsModule
*
* @param dataSource
* @return AssetsModule
*/
public AssetsModule getAssets(DataSource dataSource){ public AssetsModule getAssets(DataSource dataSource){
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName(); String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
Connection conn = null; Connection conn = null;
@ -322,24 +293,20 @@ public class DataSourceServiceImpl implements DataSourceService{
// 抛出运行时异常 // 抛出运行时异常
throw new RuntimeException(e); throw new RuntimeException(e);
} }
try { try {
// 准备查询语句并执行 // 准备查询语句并执行
PreparedStatement pst = conn.prepareStatement("select * from "+dataSource.getTableName()+" where 1=1"); PreparedStatement pst = conn.prepareStatement("select * from "+dataSource.getTableName()+" where 1=1");
ResultSet resultSet = pst.executeQuery(); ResultSet resultSet = pst.executeQuery();
ResultSetMetaData rsd = resultSet.getMetaData(); ResultSetMetaData rsd = resultSet.getMetaData();
// 遍历结果集元数据,构建列名和数据类型的映射关系 // 遍历结果集元数据,构建列名和数据类型的映射关系
for(int i = 1; i <= rsd.getColumnCount(); i++) { for(int i = 1; i <= rsd.getColumnCount(); i++) {
String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10); String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10);
map.put(rsd.getColumnName(i),substring); map.put(rsd.getColumnName(i),substring);
} }
// 根据映射关系设置AssetModel的类型 // 根据映射关系设置AssetModel的类型
for (AssetModel tableAsset : tableAssets) { for (AssetModel tableAsset : tableAssets) {
tableAsset.setType(map.get(tableAsset.getName())); tableAsset.setType(map.get(tableAsset.getName()));
} }
pst.close(); pst.close();
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); e.printStackTrace();
@ -350,13 +317,17 @@ public class DataSourceServiceImpl implements DataSourceService{
return assetsModule; return assetsModule;
} }
//获取数据表结构 /**
*
*
* @param dataSource
* @return AssetsModule
*/
public AssetsModule getStructure(DataSource dataSource){ public AssetsModule getStructure(DataSource dataSource){
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName(); String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
Connection conn = null; Connection conn = null;
List<Map<String, VTClass>> kvtList = new ArrayList<>(); List<Map<String, VTClass>> kvtList = new ArrayList<>();
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
try { try {
// 加载数据库驱动并建立连接 // 加载数据库驱动并建立连接
Class.forName(dataSource.getJdbcDriver()); Class.forName(dataSource.getJdbcDriver());
@ -370,15 +341,12 @@ public class DataSourceServiceImpl implements DataSourceService{
PreparedStatement pst = conn.prepareStatement(dataSource.getSql()); PreparedStatement pst = conn.prepareStatement(dataSource.getSql());
ResultSet resultSet = pst.executeQuery(); ResultSet resultSet = pst.executeQuery();
ResultSetMetaData rsd = resultSet.getMetaData(); ResultSetMetaData rsd = resultSet.getMetaData();
// 处理查询结果生成列名与java类型的映射 // 处理查询结果生成列名与java类型的映射
for(int i = 1; i <= rsd.getColumnCount(); i++) { for(int i = 1; i <= rsd.getColumnCount(); i++) {
String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10); String[] split = rsd.getColumnClassName(i).split("\\.");
map.put(rsd.getColumnName(i),substring); map.put(rsd.getColumnName(i),split[split.length-1]);
} }
int columnCount = rsd.getColumnCount(); int columnCount = rsd.getColumnCount();
// 遍历查询结果填充数据到list中 // 遍历查询结果填充数据到list中
while (resultSet.next()){ while (resultSet.next()){
Map<String, VTClass> stringVTClassHashMap = new HashMap<>(); Map<String, VTClass> stringVTClassHashMap = new HashMap<>();
@ -395,15 +363,14 @@ public class DataSourceServiceImpl implements DataSourceService{
kvtList.add(stringVTClassHashMap); kvtList.add(stringVTClassHashMap);
} }
pst.close(); pst.close();
conn.close();
pst=null;
conn=null;
} catch(SQLException e) { } catch(SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
// 构建并返回AssetsModule对象 // 构建并返回AssetsModule对象
AssetsModule assetsModule = new AssetsModule(); return new AssetsModule().assetsModuleBuilder(kvtList,map);
assetsModule.setKvtList(kvtList);
assetsModule.setStructure(map);
return assetsModule;
} }
@Override @Override
@ -422,10 +389,11 @@ public class DataSourceServiceImpl implements DataSourceService{
public void del(){ public void del(){
} }
//数据同步 //数据同步
@Override @Override
public Result synchronization(DataSource dataSource) { 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列表 List<Long> longList = dataSources.stream().map(DataSource::getId).toList(); // 提取数据源ID列表
ArrayList<Long> l = new ArrayList<>(); ArrayList<Long> l = new ArrayList<>();
for (Long aLong : longList) { for (Long aLong : longList) {
@ -479,25 +447,8 @@ public class DataSourceServiceImpl implements DataSourceService{
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
// 遍历结果集将每条记录转换为DataAsset对象并添加到数据列表中 // 遍历结果集将每条记录转换为DataAsset对象并添加到数据列表中
while (resultSet.next()){ while (resultSet.next()){
DataAsset dataAsset = new DataAsset(); dataAssets.add(new DataAsset().dataAssetBuilder(dataSource,resultSet));
// 设置表名
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);
} }
// 将 DataAsset 对象的 ID 提取出来并转换为 Long 数组 // 将 DataAsset 对象的 ID 提取出来并转换为 Long 数组
Long id = dataSource.getId(); // 从数据源获取ID Long id = dataSource.getId(); // 从数据源获取ID
Long[] a = new Long[1]; Long[] a = new Long[1];
@ -516,6 +467,12 @@ public class DataSourceServiceImpl implements DataSourceService{
return Result.success(); return Result.success();
} }
/**
*
*
* @param dataSource
* @return
*/
@Override @Override
public Result dataAssetList(DataSource dataSource) { public Result dataAssetList(DataSource dataSource) {
// 创建一个新的DataAsset实例并设置其数据源ID // 创建一个新的DataAsset实例并设置其数据源ID
@ -527,14 +484,22 @@ public class DataSourceServiceImpl implements DataSourceService{
List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles(); List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles();
if (roles.get(0).getRoleId() ==1){ if (roles.get(0).getRoleId() ==1){
dataAssetList = dataAssets; dataAssetList = dataAssets;
}else{ }else {
// 通过用户ID获取用户被授权的所有资产ID列表
List<Long> assetIds = assetAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList(); 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); return Result.success(dataAssetList);
} }
/**
*
*
* @param dataAsset ID
* @return
*/
@Override @Override
public Result assetModelList(DataAsset dataAsset) { public Result assetModelList(DataAsset dataAsset) {
// 创建资产模型实例并设置数据资产ID // 创建资产模型实例并设置数据资产ID
@ -561,26 +526,31 @@ public class DataSourceServiceImpl implements DataSourceService{
return Result.success(assetModels); return Result.success(assetModels);
} }
@Override
/** /**
* *
* *
*
* *
* @return Result Statistics * @return Result ResultStatisticsdataAsset
* dataModelassetModel
*/ */
@Override
public Result statisticsInfo() { public Result statisticsInfo() {
List<DataSource> dataSourcesList = new ArrayList<>(); List<DataSource> dataSourcesList = new ArrayList<>();
// 查询所有的数据源 // 查询所有的数据源
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(new DataSource()); List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(new DataSource());
List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles(); List<SysRole> roles = SecurityUtils.getLoginUser().getSysUser().getRoles();
List<Long> assetIds; List<Long> assetIds;
// 根据用户角色处理数据源筛选
if (roles.get(0).getRoleId()==1){ if (roles.get(0).getRoleId()==1){
assetIds = new ArrayList<>(); assetIds = new ArrayList<>();
dataSourcesList = dataSources; dataSourcesList = dataSources;
}else{ }else{
ArrayList<Long> longs1 = new ArrayList<>(); ArrayList<Long> longs1 = new ArrayList<>();
// 根据用户权限查询可以访问的数据源ID和数据资产ID
List<Long> sourceIds = sourceAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(SourceAccredit::getDataSourceId).filter(Objects::nonNull).toList(); 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(); assetIds = assetAccreditMapper.getSourceAccreditByUserId(SecurityUtils.getUserId()).stream().map(AssetAccredit::getDataAssetId).filter(Objects::nonNull).toList();
// 根据数据资产ID查询并筛选相关数据源
if (!assetIds.isEmpty()){ if (!assetIds.isEmpty()){
List<Long> longs = dataAssetMapper.getDataAssetByAssetId(assetIds).stream().map(DataAsset::getDataSourceId).toList(); List<Long> longs = dataAssetMapper.getDataAssetByAssetId(assetIds).stream().map(DataAsset::getDataSourceId).toList();
longs1.addAll(longs); longs1.addAll(longs);
@ -589,27 +559,28 @@ public class DataSourceServiceImpl implements DataSourceService{
dataSourcesList = dataSources.stream().filter(dataSource -> longs1.contains(dataSource.getId())).toList(); dataSourcesList = dataSources.stream().filter(dataSource -> longs1.contains(dataSource.getId())).toList();
} }
List<Long> longList = dataSourcesList.stream().map(dataSource -> 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()){ if (!longList.isEmpty()){
List<DataAsset> dataAssetByAssetId = dataAssetMapper.getDataAssetByAssetId(longList); List<DataAsset> dataAssetByAssetId = dataAssetMapper.getDataAssetByAssetId(longList);
// 对于非管理员角色,进一步筛选数据源列表
if (roles.get(0).getRoleId()!=1){ if (roles.get(0).getRoleId()!=1){
dataSourcesList = dataSourcesList.stream().filter(dataSource -> longList.contains(dataSource.getId())).toList(); dataSourcesList = dataSourcesList.stream().filter(dataSource -> longList.contains(dataSource.getId())).toList();
} }
// 统计数据资产数量、数据模型数量和资产模型数量
statistics.setDataAsset(Long.valueOf(dataSourcesList.size())); statistics.setDataAsset(Long.valueOf(dataSourcesList.size()));
long sum; long sum;
long sum1; long sum1;
// 统计所有数据资产的字段总数
sum = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum(); sum = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum();
// 统计所有数据资产的表数量
sum1 = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum(); sum1 = dataAssetByAssetId.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum();
// 设置数据模型数量和资产模型数量
statistics.setDataModel(sum); statistics.setDataModel(sum);
statistics.setAssetModel(sum1); statistics.setAssetModel(sum1);
}else{ }else{
// 若无权限访问的数据源或数据资产则相应数量置为0
statistics.setDataAsset(0L); statistics.setDataAsset(0L);
statistics.setAssetModel(0L); statistics.setAssetModel(0L);
} }
// 返回携带统计信息的成功结果 // 返回统计数据
return Result.success(statistics); return Result.success(statistics);
} }

View File

@ -1,17 +1,23 @@
package com.muyu.etl.service.impl; package com.muyu.etl.service.impl;
import java.util.List;
import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils; 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 com.muyu.etl.service.DictionaryDataService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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 @Service
public class DictionaryDataServiceImpl implements DictionaryDataService { public class DictionaryDataServiceImpl implements DictionaryDataService {
@Autowired @Autowired
private DictionaryDataMapper dictionaryDataMapper; private DictionaryDataMapper dictionaryDataMapper;
@ -22,8 +28,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public DictionaryData selectDictionaryDataById(Long id) public DictionaryData selectDictionaryDataById(Long id) {
{
return dictionaryDataMapper.selectDictionaryDataById(id); return dictionaryDataMapper.selectDictionaryDataById(id);
} }
@ -34,8 +39,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public List<DictionaryData> selectDictionaryDataList(DictionaryData dictionaryData) public List<DictionaryData> selectDictionaryDataList(DictionaryData dictionaryData) {
{
return dictionaryDataMapper.selectDictionaryDataList(dictionaryData); return dictionaryDataMapper.selectDictionaryDataList(dictionaryData);
} }
@ -46,8 +50,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public int insertDictionaryData(DictionaryData dictionaryData) public int insertDictionaryData(DictionaryData dictionaryData) {
{
dictionaryData.setCreateTime(DateUtils.getNowDate()); dictionaryData.setCreateTime(DateUtils.getNowDate());
dictionaryData.setCreateBy(SecurityUtils.getUsername()); dictionaryData.setCreateBy(SecurityUtils.getUsername());
return dictionaryDataMapper.insertDictionaryData(dictionaryData); return dictionaryDataMapper.insertDictionaryData(dictionaryData);
@ -60,8 +63,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public int updateDictionaryData(DictionaryData dictionaryData) public int updateDictionaryData(DictionaryData dictionaryData) {
{
dictionaryData.setUpdateTime(DateUtils.getNowDate()); dictionaryData.setUpdateTime(DateUtils.getNowDate());
dictionaryData.setUpdateBy(SecurityUtils.getUsername()); dictionaryData.setUpdateBy(SecurityUtils.getUsername());
return dictionaryDataMapper.updateDictionaryData(dictionaryData); return dictionaryDataMapper.updateDictionaryData(dictionaryData);
@ -74,8 +76,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public int deleteDictionaryDataByIds(Long[] ids) public int deleteDictionaryDataByIds(Long[] ids) {
{
return dictionaryDataMapper.deleteDictionaryDataByIds(ids); return dictionaryDataMapper.deleteDictionaryDataByIds(ids);
} }
@ -86,8 +87,8 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
* @return * @return
*/ */
@Override @Override
public int deleteDictionaryDataById(Long id) public int deleteDictionaryDataById(Long id) {
{
return dictionaryDataMapper.deleteDictionaryDataById(id); return dictionaryDataMapper.deleteDictionaryDataById(id);
} }
} }

View File

@ -1,18 +1,18 @@
package com.muyu.etl.service.impl; package com.muyu.etl.service.impl;
import java.util.List;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.domain.DictionaryData; import com.muyu.etl.domain.DictionaryData;
import com.muyu.etl.mapper.AssetModelMapper; import com.muyu.etl.mapper.AssetModelMapper;
import com.muyu.etl.mapper.DictionaryDataMapper; import com.muyu.etl.mapper.DictionaryDataMapper;
import com.muyu.etl.mapper.DictionaryMapper;
import com.muyu.etl.service.DictionaryService; import com.muyu.etl.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.muyu.etl.mapper.DictionaryMapper;
import java.util.List; import com.muyu.etl.domain.Dictionary;
/** /**
* Service * Service
@ -21,13 +21,14 @@ import java.util.List;
* @date 2024-04-25 * @date 2024-04-25
*/ */
@Service @Service
public class DictionaryServiceImpl implements DictionaryService public class DictionaryServiceImpl implements DictionaryService {
{
@Autowired @Autowired
private DictionaryMapper dictionaryMapper; private DictionaryMapper dictionaryMapper;
@Autowired @Autowired
private DictionaryDataMapper dictionaryDataMapper; private DictionaryDataMapper dictionaryDataMapper;
@Autowired @Autowired
private AssetModelMapper assetModelMapper; private AssetModelMapper assetModelMapper;
@ -38,8 +39,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public Dictionary selectDictionaryById(Long id) public Dictionary selectDictionaryById(Long id) {
{
return dictionaryMapper.selectDictionaryById(id); return dictionaryMapper.selectDictionaryById(id);
} }
@ -50,8 +50,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public List<Dictionary> selectDictionaryList(Dictionary dictionary) public List<Dictionary> selectDictionaryList(Dictionary dictionary) {
{
return dictionaryMapper.selectDictionaryList(dictionary); return dictionaryMapper.selectDictionaryList(dictionary);
} }
@ -62,8 +61,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public int insertDictionary(Dictionary dictionary) public int insertDictionary(Dictionary dictionary) {
{
dictionary.setCreateTime(DateUtils.getNowDate()); dictionary.setCreateTime(DateUtils.getNowDate());
dictionary.setCreateBy(SecurityUtils.getUsername()); dictionary.setCreateBy(SecurityUtils.getUsername());
return dictionaryMapper.insertDictionary(dictionary); return dictionaryMapper.insertDictionary(dictionary);
@ -76,8 +74,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public int updateDictionary(Dictionary dictionary) public int updateDictionary(Dictionary dictionary) {
{
dictionary.setUpdateTime(DateUtils.getNowDate()); dictionary.setUpdateTime(DateUtils.getNowDate());
dictionary.setUpdateBy(SecurityUtils.getUsername()); dictionary.setUpdateBy(SecurityUtils.getUsername());
return dictionaryMapper.updateDictionary(dictionary); return dictionaryMapper.updateDictionary(dictionary);
@ -90,8 +87,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public int deleteDictionaryByIds(Long[] ids) public int deleteDictionaryByIds(Long[] ids) {
{
return dictionaryMapper.deleteDictionaryByIds(ids); return dictionaryMapper.deleteDictionaryByIds(ids);
} }
@ -102,8 +98,7 @@ public class DictionaryServiceImpl implements DictionaryService
* @return * @return
*/ */
@Override @Override
public int deleteDictionaryById(Long id) public int deleteDictionaryById(Long id) {
{
return dictionaryMapper.deleteDictionaryById(id); return dictionaryMapper.deleteDictionaryById(id);
} }
@ -142,6 +137,7 @@ public class DictionaryServiceImpl implements DictionaryService
assetModelMapper.updateAssetModelDiction(id); assetModelMapper.updateAssetModelDiction(id);
return Result.success(); return Result.success();
} }
/** /**
* *
* *
@ -167,6 +163,7 @@ public class DictionaryServiceImpl implements DictionaryService
// 返回成功结果,包含处理后的字典数据列表 // 返回成功结果,包含处理后的字典数据列表
return Result.success(dictionaryDataList); return Result.success(dictionaryDataList);
} }
} }

View File

@ -16,16 +16,12 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
/**
* @ClassName SourceAccreditServiceImpl
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/29 15:06
*/
@Service @Service
public class SourceAccreditServiceImpl implements SourceAccreditService { public class SourceAccreditServiceImpl implements SourceAccreditService {
@Autowired @Autowired
private SourceAccreditMapper sourceAccreditMapper; private SourceAccreditMapper sourceAccreditMapper;
@Override @Override
public SourceAccredit selectSourceAccreditById(Long id) { public SourceAccredit selectSourceAccreditById(Long id) {
SourceAccredit sourceAccredit = sourceAccreditMapper.selectSourceAccreditById(id); SourceAccredit sourceAccredit = sourceAccreditMapper.selectSourceAccreditById(id);
@ -38,10 +34,21 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
return sourceAccredits; return sourceAccredits;
} }
/**
*
* IDID
* IDID
*
*
* @param sourceAccreditReq IDIDID
* @return Result.success()
*/
@Override @Override
public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) { public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) {
// 删除已有的对应源数据的授权信息
deleteSourceAccreditBySourceIds(sourceAccreditReq); deleteSourceAccreditBySourceIds(sourceAccreditReq);
List<SourceAccredit> sourceAccredits = new ArrayList<>(); List<SourceAccredit> sourceAccredits = new ArrayList<>();
// 如果请求中包含用户ID则为该用户授权
if (sourceAccreditReq.getUserId()!=null){ if (sourceAccreditReq.getUserId()!=null){
SourceAccredit sourceAccredit = new SourceAccredit(); SourceAccredit sourceAccredit = new SourceAccredit();
sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId()); sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId());
@ -49,7 +56,8 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
sourceAccredit.setCreateBy(SecurityUtils.getUsername()); sourceAccredit.setCreateBy(SecurityUtils.getUsername());
sourceAccredit.setCreateTime(new Date()); sourceAccredit.setCreateTime(new Date());
sourceAccredits.add(sourceAccredit); sourceAccredits.add(sourceAccredit);
}else{ } else {
// 如果请求中包含部门ID集合则为这些部门授权
sourceAccredits = sourceAccreditReq.getDeptIds().stream() sourceAccredits = sourceAccreditReq.getDeptIds().stream()
.map(deptId -> { .map(deptId -> {
SourceAccredit sourceAccredit = new SourceAccredit(); SourceAccredit sourceAccredit = new SourceAccredit();
@ -60,6 +68,7 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
return sourceAccredit; return sourceAccredit;
}).toList(); }).toList();
} }
// 批量插入授权信息
sourceAccreditMapper.insertBatchSourceAccredit(sourceAccredits); sourceAccreditMapper.insertBatchSourceAccredit(sourceAccredits);
return Result.success(); return Result.success();
} }
@ -81,24 +90,45 @@ public class SourceAccreditServiceImpl implements SourceAccreditService {
return sourceAccreditMapper.deleteSourceAccreditById(id); return sourceAccreditMapper.deleteSourceAccreditById(id);
} }
/**
* ID
*
* @param id ID
* @return AccreditModelIDID
*/
@Override @Override
public Result getSourceAccreditByDataSourceId(Long id) { public Result getSourceAccreditByDataSourceId(Long id) {
// 根据数据源ID查询所有的源认证信息
List<SourceAccredit> sourceAccreditList = sourceAccreditMapper.getSourceAccreditByDataSourceId(id); List<SourceAccredit> sourceAccreditList = sourceAccreditMapper.getSourceAccreditByDataSourceId(id);
// 从源认证信息中提取用户ID并过滤掉空值然后转换为列表
List<Long> userAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getUserId).filter(Objects::nonNull).toList(); 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(); List<Long> deptAccreditIds = sourceAccreditList.stream().map(SourceAccredit::getDeptId).filter(Objects::nonNull).toList();
// 创建一个认证模型实例并设置用户和部门认证ID集合
AccreditModel accreditModel = new AccreditModel(); AccreditModel accreditModel = new AccreditModel();
accreditModel.setDeptAccreditModelIds(deptAccreditIds); accreditModel.setDeptAccreditModelIds(deptAccreditIds);
accreditModel.setUserAccreditModelIds(userAccreditIds); accreditModel.setUserAccreditModelIds(userAccreditIds);
// 返回包含认证模型的成功结果
return Result.success(accreditModel); return Result.success(accreditModel);
} }
/**
* IDIDID
* @param sourceAccreditReq IDIDID
* @return
*/
@Override @Override
public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) { public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) {
// 根据用户ID或部门ID删除源认证信息
if (sourceAccreditReq.getUserId()!=null){ if (sourceAccreditReq.getUserId()!=null){
// 当用户ID不为空时根据用户ID和数据源ID删除认证信息
sourceAccreditMapper.deleteSourceAccreditByDeptUser(null,sourceAccreditReq.getUserId(),sourceAccreditReq.getDataSourceId()); sourceAccreditMapper.deleteSourceAccreditByDeptUser(null,sourceAccreditReq.getUserId(),sourceAccreditReq.getDataSourceId());
}else{ }else{
// 当用户ID为空时根据部门ID和数据源ID删除认证信息
sourceAccreditMapper.deleteSourceAccreditByDeptUser(sourceAccreditReq.getDeptIds(),null,sourceAccreditReq.getDataSourceId()); sourceAccreditMapper.deleteSourceAccreditByDeptUser(sourceAccreditReq.getDeptIds(),null,sourceAccreditReq.getDataSourceId());
} }
// 返回操作成功的结果
return Result.success(); return Result.success();
} }
} }

View File

@ -164,4 +164,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</if> </if>
</delete> </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> </mapper>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.AssetModelMapper"> <mapper namespace="com.muyu.etl.mapper.AssetModelMapper">
<resultMap type="com.muyu.etl.domain.AssetModel" id="AssetModelResult"> <resultMap type="com.muyu.etl.domain.AssetModel" id="AssetModelResult">
@ -93,69 +93,44 @@
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
</trim> </trim>
</insert> </insert>
<!-- <insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id" >--> <insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id" >
<!-- insert into `asset_model_copy1`--> insert into `asset_model_copy1`
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">--> <trim prefix="(" suffix=")" suffixOverrides=",">
<!-- `data_asset_id`,--> `data_asset_id`,
<!-- `name`,--> `name`,
<!-- `comment`,--> `comment`,
<!-- `is_primary_key`,--> `is_primary_key`,
<!-- `type`,--> `type`,
<!-- `mapping_type`,--> `mapping_type`,
<!-- `length`,--> `length`,
<!-- `decimal_places`,--> `decimal_places`,
<!-- `is_null`,--> `is_null`,
<!-- `is_dict`,--> `is_dict`,
<!-- `default_value`,--> `default_value`,
<!-- `dict_key`,--> `dict_key`,
<!-- `create_by`,--> `create_by`,
<!-- `create_time`,--> `create_time`,
<!-- </trim>--> </trim>
<!-- values--> 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
<foreach collection="tableAssets" item="item" separator=","> <foreach collection="tableAssets" item="item" separator=",">
( <trim prefix="(" suffix=")" suffixOverrides=",">
#{item.dataAssetId}, <if test="item.dataAssetId != null">#{item.dataAssetId},</if>
#{item.name}, <if test="item.name != null">#{item.name},</if>
#{item.comment}, <if test="item.comment != null">#{item.comment},</if>
#{item.isPrimaryKey}, <if test="item.isPrimaryKey != null">#{item.isPrimaryKey},</if>
#{item.type}, <if test="item.type != null">#{item.type},</if>
#{item.mappingType}, <if test="item.mappingType != null">#{item.mappingType},</if>
#{item.length}, <if test="item.length != null">#{item.length},</if>
#{item.decimalPlaces}, <if test="item.decimalPlaces != null">#{item.decimalPlaces},</if>
#{item.isNull}, <if test="item.isNull != null">#{item.isNull},</if>
#{item.isDict}, <if test="item.isDict != null">#{item.isDict},</if>
#{item.defaultValue}, <if test="item.defaultValue != null">#{item.defaultValue},</if>
#{item.dictKey}, <if test="item.dictKey != null">#{item.dictKey},</if>
#{item.createBy}, <if test="item.createBy != null and item.createBy != ''">#{item.createBy},</if>
#{item.createTime} <if test="item.createTime != null">#{item.createTime},</if>
) </trim>
</foreach> </foreach>
</insert> </insert>
<update id="updateAssetModel" parameterType="com.muyu.etl.domain.AssetModel"> <update id="updateAssetModel" parameterType="com.muyu.etl.domain.AssetModel">
@ -181,6 +156,9 @@
</trim> </trim>
where id = #{id} where id = #{id}
</update> </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 id="deleteAssetModelById" parameterType="Long">
delete from asset_model_copy1 where id = #{id} delete from asset_model_copy1 where id = #{id}
@ -192,10 +170,10 @@
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<delete id="clearTable1" > <delete id="clearTable1">
delete from asset_model_copy1 where data_asset_id in delete from asset_model_copy1 where data_asset_id in
<foreach collection="id" item="id" index="index" open="(" separator="," close=")"> <foreach collection="id" item="item" index="index" open="(" separator="," close=")">
#{id} #{item}
</foreach> </foreach>
</delete> </delete>

View File

@ -50,6 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) )
</where> </where>
</select> </select>
<insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
insert into data_asset insert into data_asset
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.DataSourceMapper"> <mapper namespace="com.muyu.etl.mapper.DataSourceMapper">
@ -23,14 +23,16 @@
<result property="maxWaitTime" column="max_wait_time" /> <result property="maxWaitTime" column="max_wait_time" />
<result property="connectionParam" column="connection_param" /> <result property="connectionParam" column="connection_param" />
<result property="systemName" column="systemName" /> <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> </resultMap>
<sql id="selectDataSourceVo"> <sql id="selectDataSourceVo">
select id, data_source_name,`type`,systemName, link_address,init_num, max_num, max_wait_size, max_wait_time,`table_name`, 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
connection_param, port, database_name, username, password, mode_name,create_by, create_time, update_by, update_time, remark from datasource
</sql> </sql>
<select id="selectDataSourceList" parameterType="com.muyu.etl.domain.DataSource" resultMap="DataSourceResult"> <select id="selectDataSourceList" parameterType="com.muyu.etl.domain.DataSource" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/> <include refid="selectDataSourceVo"/>
<where> <where>
@ -40,6 +42,15 @@
<if test="databaseName != null and databaseName != ''"> and database_name like concat('%', #{databaseName}, '%')</if> <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="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
<if test="password != null and password != ''"> and password = #{password}</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> </where>
</select> </select>
@ -107,6 +118,8 @@
<if test="maxWaitTime != null">max_wait_time,</if> <if test="maxWaitTime != null">max_wait_time,</if>
<if test="connectionParam != null">connection_param,</if> <if test="connectionParam != null">connection_param,</if>
<if test="systemName != null">systemName,</if> <if test="systemName != null">systemName,</if>
<if test="modeName != null">mode_name,</if>
<if test="jdbcDriver != null">jdbcDriver,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">#{dataSourceName},</if> <if test="dataSourceName != null">#{dataSourceName},</if>
@ -126,6 +139,8 @@
<if test="maxWaitTime != null">#{maxWaitTime},</if> <if test="maxWaitTime != null">#{maxWaitTime},</if>
<if test="connectionParam != null">#{connectionParam},</if> <if test="connectionParam != null">#{connectionParam},</if>
<if test="systemName != null">#{systemName},</if> <if test="systemName != null">#{systemName},</if>
<if test="modeName != null">#{modeName},</if>
<if test="jdbcDriver != null">#{jdbcDriver},</if>
</trim> </trim>
</insert> </insert>
<insert id="batchInsert" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id"> <insert id="batchInsert" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
@ -166,7 +181,6 @@
values values
<foreach collection="dataAssets" item="item" separator=","> <foreach collection="dataAssets" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
#{item.dataSourceId}, #{item.dataSourceId},
#{item.tableName}, #{item.tableName},
#{item.tableComment}, #{item.tableComment},
@ -191,6 +205,7 @@
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</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="remark != null">remark = #{remark},</if>
<if test="initNum != null">init_num = #{initNum},</if> <if test="initNum != null">init_num = #{initNum},</if>
<if test="maxNum != null">max_num = #{maxNum},</if> <if test="maxNum != null">max_num = #{maxNum},</if>
@ -198,6 +213,8 @@
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if> <if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
<if test="connectionParam != null">connection_param = #{connectionParam},</if> <if test="connectionParam != null">connection_param = #{connectionParam},</if>
<if test="systemName != null">systemName = #{systemName},</if> <if test="systemName != null">systemName = #{systemName},</if>
<if test="modeName != null">mode_name = #{modeName},</if>
<if test="jdbcDriver != null">jdbcDriver = #{jdbcDriver},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</where> </where>
</select> </select>

View File

@ -136,4 +136,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</if> </if>
</delete> </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> </mapper>