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 java.util.List;
/**
* @ClassName AssetAccreditController
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/28 14:30
*/
@RestController
@RequestMapping("assetAccredit")
public class AssetAccreditController extends BaseController {
@ -45,10 +51,10 @@ public class AssetAccreditController extends BaseController {
public Result add(@RequestBody AssetAccreditReq assetAccreditReq){
return assetAccreditService.insertAssetAccredit(assetAccreditReq);
}
@PostMapping("/DeleteAssetAccreditByAsserIds")
@PostMapping("/DeleteAssetAccreditByAssetIds")
public Result deleteAssetAccreditByAsserIds(@RequestBody AssetAccreditReq assetAccreditReq)
{
return assetAccreditService.deleteAssetAccreditByAssetId(assetAccreditReq);
return assetAccreditService.deleteAssetAccreditByAssetIds(assetAccreditReq);
}
@PutMapping
public Result edit(@RequestBody AssetAccredit assetAccredit){

View File

@ -53,6 +53,7 @@ public class AssetModelController extends BaseController
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(assetModelService.selectAssetModelById(id));
}
@ -78,9 +79,16 @@ public class AssetModelController extends BaseController
/**
*
*/
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(assetModelService.deleteAssetModelByIds(ids));
}
/**
*
*
* @param assetModel
* @return Result.successResult.fail
*/
}

View File

@ -77,7 +77,7 @@ public class DataAssetController extends BaseController
/**
*
*/
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(dataAssetService.deleteDataAssetByIds(ids));

View File

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

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.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
@ -76,7 +77,7 @@ public class DictionaryController extends BaseController
/**
*
*/
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(dictionaryService.deleteDictionaryByIds(ids));

View File

@ -77,7 +77,7 @@ public class DictionaryDataController extends BaseController
/**
*
*/
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(dictionaryDataService.deleteDictionaryDataByIds(ids));

View File

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

View File

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

View File

@ -8,137 +8,43 @@ import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* @ClassName AssetModel
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/22 19:39
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class AssetModel extends BaseEntity {
private Long id;
private Long dataAssetId;
private String name;
private String comment;
private String isPrimaryKey;
private String type;
private String mappingType;
private String length;
private String decimalPlaces;
private String isNull;
private String defaultValue;
private String isDict;
private String dictKey;
/**
* ID
*/
private Long dictionaryId;
private List<DictionaryData> dictionaryDatas;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDataAssetId() {
return dataAssetId;
}
public void setDataAssetId(Long dataAssetId) {
this.dataAssetId = dataAssetId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getIsPrimaryKey() {
return isPrimaryKey;
}
public void setIsPrimaryKey(String isPrimaryKey) {
this.isPrimaryKey = isPrimaryKey;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMappingType() {
return mappingType;
}
public void setMappingType(String mappingType) {
this.mappingType = mappingType;
}
public String getLength() {
return length;
}
public void setLength(String length) {
this.length = length;
}
public String getDecimalPlaces() {
return decimalPlaces;
}
public void setDecimalPlaces(String decimalPlaces) {
this.decimalPlaces = decimalPlaces;
}
public String getIsNull() {
return isNull;
}
public void setIsNull(String isNull) {
this.isNull = isNull;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getIsDict() {
return isDict;
}
public void setIsDict(String isDict) {
this.isDict = isDict;
}
public String getDictKey() {
return dictKey;
}
public void setDictKey(String dictKey) {
this.dictKey = dictKey;
}
}

View File

@ -14,7 +14,20 @@ import java.util.Map;
@NoArgsConstructor
@Builder
public class AssetsModule {
private HashMap<String,String> structure;
private List<Map<String,VTClass>> kvtList;
private List<TableAssets> tableAssets;
private TableDetail tableDetail;
public AssetsModule assetsModuleBuilder( List<Map<String,VTClass>> kvtList, HashMap<String,String> map) {
return AssetsModule.builder()
.kvtList(kvtList)
.structure(map)
.build();
}
}

View File

@ -8,36 +8,50 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ClassName DataAsset
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/22 20:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class DataAsset extends BaseEntity {
private Long id;
private Long dataSourceId;
private String tableName;
private String tableComment;
private Long tableCount;
private Long fields;
public DataAsset dataAsset(DataAsset dataAsset , ResultSet resultSet){
return DataAsset.builder()
.id(dataAsset.getId())
.dataSourceId(dataAsset.getDataSourceId())
.tableName(dataAsset.getTableName())
.tableComment(dataAsset.getTableComment())
.tableCount(dataAsset.getTableCount())
.fields(dataAsset.getFields())
.updateBy(SecurityUtils.getUsername())
.updateTime(new Date())
.build();
/**
*
*
* @param dataSource
* @param resultSet
* @return
*/
public DataAsset dataAssetBuilder(DataSource dataSource , ResultSet resultSet) {
try {
// 从结果集中提取数据并使用DataAsset的builder模式构建数据资产对象
return DataAsset.builder()
.tableName(resultSet.getString("t_name"))
.tableComment(resultSet.getString("table_comment")==null ? "" : resultSet.getString("table_comment"))
.tableCount(Long.valueOf(resultSet.getString("table_rows")))
.fields(Long.valueOf(resultSet.getString("fields")))
.dataSourceId(dataSource.getId())
.createBy(SecurityUtils.getUsername())
.createTime(new Date())
.build();
}catch (SQLException e){
// 捕获并抛出SQL异常为运行时异常
throw new RuntimeException(e);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,16 @@
package com.muyu.etl.mapper;
import com.muyu.etl.domain.AssetModel;
import com.muyu.etl.domain.DataAsset;
import com.muyu.etl.domain.DataSource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
import com.muyu.common.core.domain.Result;
import com.muyu.etl.domain.AssetModel;
import com.muyu.etl.domain.DataAsset;
import com.muyu.etl.domain.DataSource;
import feign.template.Literal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
@ -16,8 +18,8 @@ import java.util.List;
* @date 2024-04-20
*/
@Mapper
public interface DataSourceMapper
{
public interface DataSourceMapper {
/**
*
*
@ -66,17 +68,14 @@ public interface DataSourceMapper
*/
public int deleteDataSourceByIds(Long[] ids);
List<AssetModel> getAssetModel(String databaseName, String assetModule);
void batchAdd( @Param("dataAssets") ArrayList<DataAsset> dataAssets);
int clearTable(@Param("id") Long[] id);
List<DataAsset> selectDataAssetBachId(@Param("longs") List<Long> longs);
List<DataSource> selectId(Long id);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -164,4 +164,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
</delete>
<delete id="deleteAssetAccreditByUser">
delete from asset_accredit where data_asset_id = #{dataAssetId}
and user_id in(
<foreach collection="userIds" item="id" separator=",">
#{id}
</foreach>
)
</delete>
</mapper>

View File

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

View File

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

View File

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

View File

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

View File

@ -136,4 +136,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
</delete>
<delete id="deleteSourceAccreditByUser">
delete from source_accredit where datasource_id=#{dataSourceId} and user_id in
<foreach item="sourceId" collection="sourceIds" open="(" separator="," close=")">
#{sourceId}
</foreach>
</delete>
</mapper>