From 69e70e451b03805c24d405a719a5a84f33b29f50 Mon Sep 17 00:00:00 2001 From: yaoxin <1752800946@qq.com> Date: Wed, 24 Apr 2024 21:57:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=86=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E8=A1=A8=E7=9A=84=E6=96=B0=E5=A2=9E,=E5=88=A0?= =?UTF-8?q?=E9=99=A4,=E5=92=8C=E5=AD=97=E5=85=B8=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E6=96=B0=E5=A2=9E,=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etl/controller/DataSourceController.java | 2 +- .../etl/controller/DictionaryController.java | 108 ++++++++++++++ .../controller/DictionaryDataController.java | 98 +++++++++++++ .../java/com/muyu/etl/domain/DataSource.java | 2 + .../java/com/muyu/etl/domain/Dictionary.java | 96 ++++++++++++ .../com/muyu/etl/domain/DictionaryData.java | 94 ++++++++++++ .../com/muyu/etl/mapper/AssetModelMapper.java | 2 + .../com/muyu/etl/mapper/DataAssetMapper.java | 2 + .../muyu/etl/mapper/DictionaryDataMapper.java | 66 +++++++++ .../com/muyu/etl/mapper/DictionaryMapper.java | 64 ++++++++ .../etl/service/IDictionaryDataService.java | 61 ++++++++ .../muyu/etl/service/IDictionaryService.java | 67 +++++++++ .../service/impl/DataSourceServiceImpl.java | 58 +++----- .../impl/DictionaryDataServiceImpl.java | 99 +++++++++++++ .../service/impl/DictionaryServiceImpl.java | 137 ++++++++++++++++++ .../mapper/system/AssetModelMapper.xml | 12 +- .../mapper/system/DataAssetMapper.xml | 10 ++ .../mapper/system/DictionaryDataMapper.xml | 103 +++++++++++++ .../mapper/system/DictionaryMapper.xml | 92 ++++++++++++ 19 files changed, 1131 insertions(+), 42 deletions(-) create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryController.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryDataController.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/Dictionary.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DictionaryData.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryDataMapper.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryMapper.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryDataService.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryService.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryDataServiceImpl.java create mode 100644 muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryServiceImpl.java create mode 100644 muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryDataMapper.xml create mode 100644 muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryMapper.xml diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DataSourceController.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DataSourceController.java index f83f0e5..6c0b5b2 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DataSourceController.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DataSourceController.java @@ -103,7 +103,7 @@ public class DataSourceController extends BaseController @GetMapping(value = "/{id}") public Result getInfo(@PathVariable("id") Long id) { - return success(dataSourceService.selectDataSourceById(id)); + return Result.success(dataSourceService.selectDataSourceById(id)); } /** diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryController.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryController.java new file mode 100644 index 0000000..143c9a3 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryController.java @@ -0,0 +1,108 @@ +package com.muyu.etl.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.etl.domain.Dictionary; +import com.muyu.etl.service.IDictionaryService; +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 + * + * @author ruoyi + * @date 2024-04-24 + */ +@RestController +@RequestMapping("/dictionary") +public class DictionaryController extends BaseController +{ + @Autowired + private IDictionaryService dictionaryService; + + /** + * 查询【请填写功能名称】列表 + */ + @GetMapping("/list") + public Result> list(Dictionary dictionary) + { + startPage(); + List list = dictionaryService.selectDictionaryList(dictionary); + return getDataTable(list); + } + + /** + * 导出【请填写功能名称】列表 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Dictionary dictionary) + { + List list = dictionaryService.selectDictionaryList(dictionary); + ExcelUtil util = new ExcelUtil(Dictionary.class); + util.exportExcel(response, list, "【请填写功能名称】数据"); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @GetMapping(value = "/{id}") + public Result getInfo(@PathVariable("id") Long id) + { + return success(dictionaryService.selectDictionaryById(id)); + } + + /** + * 根据数据源id获取字典详细信息 + */ + @GetMapping(value = "/GetDictionaryList") + public Result getDictionaryList(@RequestParam("dataSourceId") Long dataSourceId){ + return dictionaryService.getDictionaryList(dataSourceId); + } + + /** + * 根据key删除字典详细信息 + */ + @GetMapping(value = "/DeleteDictionary") + public Result deleteDictionary(@RequestParam("id") Long id){ + return dictionaryService.deleteDictionary(id); + } + + + /** + * 新增【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody Dictionary dictionary) + { + return toAjax(dictionaryService.insertDictionary(dictionary)); + } + + /** + * 修改【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody Dictionary dictionary) + { + return toAjax(dictionaryService.updateDictionary(dictionary)); + } + + /** + * 删除【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) + { + return toAjax(dictionaryService.deleteDictionaryByIds(ids)); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryDataController.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryDataController.java new file mode 100644 index 0000000..38951dd --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/controller/DictionaryDataController.java @@ -0,0 +1,98 @@ +package com.muyu.etl.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +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.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.etl.domain.DictionaryData; +import com.muyu.etl.service.IDictionaryDataService; +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 + * + * @author ruoyi + * @date 2024-04-24 + */ +@RestController +@RequestMapping("/data") +public class DictionaryDataController extends BaseController +{ + @Autowired + private IDictionaryDataService dictionaryDataService; + + /** + * 查询【请填写功能名称】列表 + */ + @GetMapping("/list") + public Result> list(DictionaryData dictionaryData) + { + startPage(); + List list = dictionaryDataService.selectDictionaryDataList(dictionaryData); + return getDataTable(list); + } + + /** + * 导出【请填写功能名称】列表 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DictionaryData dictionaryData) + { + List list = dictionaryDataService.selectDictionaryDataList(dictionaryData); + ExcelUtil util = new ExcelUtil(DictionaryData.class); + util.exportExcel(response, list, "【请填写功能名称】数据"); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @GetMapping(value = "/{id}") + public Result getInfo(@PathVariable("id") Long id) + { + return success(dictionaryDataService.selectDictionaryDataById(id)); + } + + /** + * 新增【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody DictionaryData dictionaryData) + { + return toAjax(dictionaryDataService.insertDictionaryData(dictionaryData)); + } + + /** + * 修改【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody DictionaryData dictionaryData) + { + return toAjax(dictionaryDataService.updateDictionaryData(dictionaryData)); + } + + /** + * 删除【请填写功能名称】 + */ + @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) + { + return toAjax(dictionaryDataService.deleteDictionaryDataByIds(ids)); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DataSource.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DataSource.java index 4dd57b2..1c7a948 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DataSource.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DataSource.java @@ -101,6 +101,8 @@ public class DataSource extends BaseEntity @Excel(name = "数据来源名称") private String modeName; + + public String getJdbcDriver() { return jdbcDriver; } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/Dictionary.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/Dictionary.java new file mode 100644 index 0000000..9a4220e --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/Dictionary.java @@ -0,0 +1,96 @@ +package com.muyu.etl.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; + +import java.util.List; + +/** + * 【请填写功能名称】对象 dictionary + * + * @author ruoyi + * @date 2024-04-24 + */ +public class Dictionary extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 字典名称 */ + @Excel(name = "字典名称") + private String dictionaryName; + + /** 字典key */ + @Excel(name = "字典key") + private String dictionaryKey; + + /** 数据源ID */ + @Excel(name = "数据源ID") + private Long dataSourceId; + + /** 字典数据集合 */ + @Excel(name = "数据源ID") + private List dictionaryDataList; + + public List getDictionaryDataList() { + return dictionaryDataList; + } + + public void setDictionaryDataList(List dictionaryDataList) { + this.dictionaryDataList = dictionaryDataList; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setDictionaryName(String dictionaryName) + { + this.dictionaryName = dictionaryName; + } + + public String getDictionaryName() + { + return dictionaryName; + } + public void setDictionaryKey(String dictionaryKey) + { + this.dictionaryKey = dictionaryKey; + } + + public String getDictionaryKey() + { + return dictionaryKey; + } + + public Long getDataSourceId() { + return dataSourceId; + } + + public void setDataSourceId(Long dataSourceId) { + this.dataSourceId = dataSourceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dictionaryName", getDictionaryName()) + .append("dictionaryKey", getDictionaryKey()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DictionaryData.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DictionaryData.java new file mode 100644 index 0000000..3833ccf --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/domain/DictionaryData.java @@ -0,0 +1,94 @@ +package com.muyu.etl.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; + +/** + * 【请填写功能名称】对象 dictionary_data + * + * @author ruoyi + * @date 2024-04-24 + */ +public class DictionaryData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 字典表ID */ + @Excel(name = "字典表ID") + private Long dictionaryId; + + /** 字典标签 */ + @Excel(name = "字典标签") + private String label; + + /** 字典值 */ + @Excel(name = "字典值") + private String val; + + /** 是否修改 */ + @Excel(name = "字典值") + private Boolean isEdit=false; + + public Boolean getEdit() { + return isEdit=false; + } + + public void setEdit(Boolean edit) { + isEdit = false; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setDictionaryId(Long dictionaryId) + { + this.dictionaryId = dictionaryId; + } + + public Long getDictionaryId() + { + return dictionaryId; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dictionaryId", getDictionaryId()) + .append("label", getLabel()) + .append("val", getVal()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetModelMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetModelMapper.java index 7207e64..ec7649a 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetModelMapper.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/AssetModelMapper.java @@ -61,4 +61,6 @@ public interface AssetModelMapper public int deleteAssetModelByIds(Long[] ids); void batchInsert(@Param("tableAssets") List tableAssets); + + List getAssetModelList(@Param("longs") List longs); } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java index 25e626c..6b31b79 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DataAssetMapper.java @@ -64,4 +64,6 @@ public interface DataAssetMapper void batchInsert(@Param("dataAssets") ArrayList dataAssets); List selectDataAssetBatchId(@Param("longs") List longs); + + List getDataAssetList(@Param("ids") Long[] ids); } diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryDataMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryDataMapper.java new file mode 100644 index 0000000..8e41c60 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryDataMapper.java @@ -0,0 +1,66 @@ +package com.muyu.etl.mapper; + +import java.util.List; +import com.muyu.etl.domain.DictionaryData; +import org.apache.ibatis.annotations.Param; + +/** + * 【请填写功能名称】Mapper接口 + * + * @author ruoyi + * @date 2024-04-24 + */ +public interface DictionaryDataMapper +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public DictionaryData selectDictionaryDataById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionaryData 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectDictionaryDataList(DictionaryData dictionaryData); + + /** + * 新增【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + public int insertDictionaryData(DictionaryData dictionaryData); + + /** + * 修改【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + public int updateDictionaryData(DictionaryData dictionaryData); + + /** + * 删除【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteDictionaryDataById(Long id); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDictionaryDataByIds(Long[] ids); + + List getDictionaryDataList(@Param("dictionaryIds") List dictionaryIds); + + void deleteDictionaryData(@Param("dictionaryIds") List dictionaryIds); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryMapper.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryMapper.java new file mode 100644 index 0000000..bd98c5b --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/mapper/DictionaryMapper.java @@ -0,0 +1,64 @@ +package com.muyu.etl.mapper; + +import java.util.List; +import com.muyu.etl.domain.Dictionary; +import org.apache.ibatis.annotations.Param; + +/** + * 【请填写功能名称】Mapper接口 + * + * @author ruoyi + * @date 2024-04-24 + */ +public interface DictionaryMapper +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public Dictionary selectDictionaryById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionary 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectDictionaryList(Dictionary dictionary); + + /** + * 新增【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + public int insertDictionary(Dictionary dictionary); + + /** + * 修改【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + public int updateDictionary(Dictionary dictionary); + + /** + * 删除【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteDictionaryById(Long id); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDictionaryByIds(Long[] ids); + + List getDictionaryList(@Param("dataSourceId") Long dataSourceId); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryDataService.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryDataService.java new file mode 100644 index 0000000..2e5fe24 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryDataService.java @@ -0,0 +1,61 @@ +package com.muyu.etl.service; + +import java.util.List; +import com.muyu.etl.domain.DictionaryData; + +/** + * 【请填写功能名称】Service接口 + * + * @author ruoyi + * @date 2024-04-24 + */ +public interface IDictionaryDataService +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public DictionaryData selectDictionaryDataById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionaryData 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectDictionaryDataList(DictionaryData dictionaryData); + + /** + * 新增【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + public int insertDictionaryData(DictionaryData dictionaryData); + + /** + * 修改【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + public int updateDictionaryData(DictionaryData dictionaryData); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键集合 + * @return 结果 + */ + public int deleteDictionaryDataByIds(Long[] ids); + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteDictionaryDataById(Long id); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryService.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryService.java new file mode 100644 index 0000000..baf7437 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/IDictionaryService.java @@ -0,0 +1,67 @@ +package com.muyu.etl.service; + +import java.util.List; + +import com.muyu.common.core.domain.Result; +import com.muyu.etl.domain.Dictionary; + +/** + * 【请填写功能名称】Service接口 + * + * @author ruoyi + * @date 2024-04-24 + */ +public interface IDictionaryService +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public Dictionary selectDictionaryById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionary 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectDictionaryList(Dictionary dictionary); + + /** + * 新增【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + public int insertDictionary(Dictionary dictionary); + + /** + * 修改【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + public int updateDictionary(Dictionary dictionary); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键集合 + * @return 结果 + */ + public int deleteDictionaryByIds(Long[] ids); + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteDictionaryById(Long id); + + Result getDictionaryList(Long dataSourceId); + + Result deleteDictionary(Long id); +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java index 9cce0f9..81db1a7 100644 --- a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DataSourceServiceImpl.java @@ -47,7 +47,8 @@ public class DataSourceServiceImpl implements IDataSourceService @Override public DataSource selectDataSourceById(Long id) { - return dataSourceMapper.selectDataSourceById(id); + DataSource dataSource = dataSourceMapper.selectDataSourceById(id); + return dataSource; } /** @@ -60,45 +61,6 @@ public class DataSourceServiceImpl implements IDataSourceService public List selectDataSourceList(DataSource dataSource) { List dataSources = dataSourceMapper.selectDataSourceList(dataSource); -// dataSources.stream() -// .map(source -> { -// String user = source.getUsername(); -// String password = source.getPassword(); -// String jdbcDriver = "com.mysql.cj.jdbc.Driver"; -// String jdbcUrl = "jdbc:mysql://"+source.getLinkAddress()+":"+source.getPort()+"/"+source.getDatabaseName(); -// Connection conn = null; -// Result result = this.testConnection(source); -// if (result.getCode()==200){ -// try { -// Class.forName(jdbcDriver); -// conn = DriverManager.getConnection(jdbcUrl, user, password); -// List tableNames = new ArrayList<>(); -// String sql="SELECT TABLE_NAME table_name,TABLE_COMMENT table_comment,TABLE_ROWS table_count FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '"+source.getDatabaseName()+"'"; -// PreparedStatement ps = conn.prepareStatement(sql); -// ResultSet resultSet = ps.executeQuery(); -// while (resultSet.next()){ -// TableDetail tableDetail = new TableDetail(); -// tableDetail.setTableName(resultSet.getString("table_name")); -// tableDetail.setTableComment(resultSet.getString("table_comment")); -// tableDetail.setTableCount(Long.valueOf(resultSet.getString("table_count"))); -// tableNames.add(tableDetail); -// } -// source.setTableList(tableNames); -// ps.close(); -// sql="SELECT count(*) count FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '"+source.getDatabaseName()+"'"; -// PreparedStatement pst = conn.prepareStatement(sql); -// ResultSet resultSet1 = pst.executeQuery(); -// while (resultSet1.next()){ -// long count = resultSet1.getLong("count"); -// source.setCount(count); -// } -// pst.close(); -// } catch (ClassNotFoundException | SQLException e) { -// throw new RuntimeException(e); -// } -// } -// return null; -// }).toList(); return dataSources; } @@ -147,11 +109,26 @@ public class DataSourceServiceImpl implements IDataSourceService * @return 结果 */ @Override + @Transactional public int deleteDataSourceByIds(Long[] ids) { + deleteChildLevel(ids); return dataSourceMapper.deleteDataSourceByIds(ids); } + public void deleteChildLevel(Long[] ids){ + List dataAssetList=dataAssetMapper.getDataAssetList(ids); + if (!dataAssetList.isEmpty()){ + List dataAssetIds = dataAssetList.stream().map(DataAsset::getId).toList(); + List assetModelList=assetModelMapper.getAssetModelList(dataAssetIds); + dataAssetMapper.deleteDataAssetByIds(dataAssetIds.toArray(Long[]::new)); + if (!assetModelList.isEmpty()){ + List assetModelIds = assetModelList.stream().map(AssetModel::getId).toList(); + assetModelMapper.deleteAssetModelByIds(assetModelIds.toArray(Long[]::new)); + } + } + } + /** * 删除【请填写功能名称】信息 * @@ -387,6 +364,7 @@ public class DataSourceServiceImpl implements IDataSourceService @Override public Result synchronousData(DataSource dataSource) { + deleteChildLevel(new Long[]{dataSource.getId()}); String jdbcUrl = ""; String sql=""; jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName(); diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryDataServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryDataServiceImpl.java new file mode 100644 index 0000000..46f4f3c --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryDataServiceImpl.java @@ -0,0 +1,99 @@ +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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.etl.mapper.DictionaryDataMapper; +import com.muyu.etl.domain.DictionaryData; +import com.muyu.etl.service.IDictionaryDataService; + +/** + * 【请填写功能名称】Service业务层处理 + * + * @author ruoyi + * @date 2024-04-24 + */ +@Service +public class DictionaryDataServiceImpl implements IDictionaryDataService +{ + @Autowired + private DictionaryDataMapper dictionaryDataMapper; + + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + @Override + public DictionaryData selectDictionaryDataById(Long id) + { + return dictionaryDataMapper.selectDictionaryDataById(id); + } + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionaryData 【请填写功能名称】 + * @return 【请填写功能名称】 + */ + @Override + public List selectDictionaryDataList(DictionaryData dictionaryData) + { + return dictionaryDataMapper.selectDictionaryDataList(dictionaryData); + } + + /** + * 新增【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + @Override + public int insertDictionaryData(DictionaryData dictionaryData) + { + dictionaryData.setCreateTime(DateUtils.getNowDate()); + dictionaryData.setCreateBy(SecurityUtils.getUsername()); + return dictionaryDataMapper.insertDictionaryData(dictionaryData); + } + + /** + * 修改【请填写功能名称】 + * + * @param dictionaryData 【请填写功能名称】 + * @return 结果 + */ + @Override + public int updateDictionaryData(DictionaryData dictionaryData) + { + dictionaryData.setUpdateTime(DateUtils.getNowDate()); + dictionaryData.setUpdateBy(SecurityUtils.getUsername()); + return dictionaryDataMapper.updateDictionaryData(dictionaryData); + } + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteDictionaryDataByIds(Long[] ids) + { + return dictionaryDataMapper.deleteDictionaryDataByIds(ids); + } + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteDictionaryDataById(Long id) + { + return dictionaryDataMapper.deleteDictionaryDataById(id); + } +} diff --git a/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryServiceImpl.java b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryServiceImpl.java new file mode 100644 index 0000000..676e366 --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/java/com/muyu/etl/service/impl/DictionaryServiceImpl.java @@ -0,0 +1,137 @@ +package com.muyu.etl.service.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.DictionaryData; +import com.muyu.etl.mapper.DictionaryDataMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.etl.mapper.DictionaryMapper; +import com.muyu.etl.domain.Dictionary; +import com.muyu.etl.service.IDictionaryService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 【请填写功能名称】Service业务层处理 + * + * @author ruoyi + * @date 2024-04-24 + */ +@Service +public class DictionaryServiceImpl implements IDictionaryService +{ + @Autowired + private DictionaryMapper dictionaryMapper; + + @Autowired + private DictionaryDataMapper dictionaryDataMapper; + + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + @Override + public Dictionary selectDictionaryById(Long id) + { + return dictionaryMapper.selectDictionaryById(id); + } + + /** + * 查询【请填写功能名称】列表 + * + * @param dictionary 【请填写功能名称】 + * @return 【请填写功能名称】 + */ + @Override + public List selectDictionaryList(Dictionary dictionary) + { + return dictionaryMapper.selectDictionaryList(dictionary); + } + + /** + * 新增【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + @Override + public int insertDictionary(Dictionary dictionary) + { + dictionary.setCreateTime(DateUtils.getNowDate()); + dictionary.setCreateBy(SecurityUtils.getUsername()); + return dictionaryMapper.insertDictionary(dictionary); + } + + /** + * 修改【请填写功能名称】 + * + * @param dictionary 【请填写功能名称】 + * @return 结果 + */ + @Override + public int updateDictionary(Dictionary dictionary) + { + dictionary.setUpdateTime(DateUtils.getNowDate()); + dictionary.setUpdateBy(SecurityUtils.getUsername()); + return dictionaryMapper.updateDictionary(dictionary); + } + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteDictionaryByIds(Long[] ids) + { + return dictionaryMapper.deleteDictionaryByIds(ids); + } + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteDictionaryById(Long id) + { + return dictionaryMapper.deleteDictionaryById(id); + } + + @Override + public Result getDictionaryList(Long dataSourceId) { + List dictionaryList=dictionaryMapper.getDictionaryList(dataSourceId); + if (!dictionaryList.isEmpty()){ + List dictionaryDataList=dictionaryDataMapper.getDictionaryDataList(dictionaryList.stream().map(Dictionary::getId).toList()); + dictionaryList.stream() + .forEach(dictionary -> { + List dictionaryDatas = dictionaryDataList.stream().filter(dictionaryData -> dictionaryData.getDictionaryId() == dictionary.getId()).toList(); + dictionary.setDictionaryDataList(dictionaryDatas); + }); + } + return Result.success(dictionaryList); + } + + @Override + @Transactional + public Result deleteDictionary(Long id) { + Dictionary dictionary = new Dictionary(); + dictionary.setId(id); + List dictionaryList = dictionaryMapper.selectDictionaryList(dictionary); + if (!dictionaryList.isEmpty()){ + dictionaryDataMapper.deleteDictionaryData(dictionaryList.stream().map(Dictionary::getId).toList()); + } + dictionaryMapper.deleteDictionaryById(id); + return Result.success(); + } +} diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetModelMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetModelMapper.xml index 164284f..981ab6e 100644 --- a/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetModelMapper.xml +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/AssetModelMapper.xml @@ -51,7 +51,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + insert into asset_model diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml index d6dc5b5..b64f12f 100644 --- a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DataAssetMapper.xml @@ -45,6 +45,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + insert into data_asset diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryDataMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryDataMapper.xml new file mode 100644 index 0000000..c0c976c --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryDataMapper.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + select id, dictionary_id, label, val, create_by, create_time, update_by, update_time, remark from dictionary_data + + + + + + + + + insert into dictionary_data + + dictionary_id, + label, + val, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dictionaryId}, + #{label}, + #{val}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update dictionary_data + + dictionary_id = #{dictionaryId}, + label = #{label}, + val = #{val}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from dictionary_data where id = #{id} + + + + delete from dictionary_data where id in + + #{id} + + + + delete from dictionary_data where dictionary_id in ( + + #{id} + + ) + + \ No newline at end of file diff --git a/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryMapper.xml b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryMapper.xml new file mode 100644 index 0000000..7e72c3a --- /dev/null +++ b/muyu-modules/muyu-etl/src/main/resources/mapper/system/DictionaryMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + select id, dictionary_name, dictionary_key,data_source_id, create_by, create_time, update_by, update_time, remark from dictionary + + + + + + + + + insert into dictionary + + dictionary_name, + dictionary_key, + data_source_id, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dictionaryName}, + #{dictionaryKey}, + #{dataSourceId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update dictionary + + dictionary_name = #{dictionaryName}, + dictionary_key = #{dictionaryKey}, + data_source_id = #{dataSourceId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from dictionary where id = #{id} + + + + delete from dictionary where id in + + #{id} + + + \ No newline at end of file