feat: 新增了字典表的新增,删除,和字典表数据的新增,修改

master
yaoxin 2024-04-24 21:57:57 +08:00
parent 7f0e928cd5
commit 69e70e451b
19 changed files with 1131 additions and 42 deletions

View File

@ -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));
}
/**

View File

@ -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<TableDataInfo<Dictionary>> list(Dictionary dictionary)
{
startPage();
List<Dictionary> list = dictionaryService.selectDictionaryList(dictionary);
return getDataTable(list);
}
/**
*
*/
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Dictionary dictionary)
{
List<Dictionary> list = dictionaryService.selectDictionaryList(dictionary);
ExcelUtil<Dictionary> util = new ExcelUtil<Dictionary>(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));
}
}

View File

@ -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<TableDataInfo<DictionaryData>> list(DictionaryData dictionaryData)
{
startPage();
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
return getDataTable(list);
}
/**
*
*/
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DictionaryData dictionaryData)
{
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
ExcelUtil<DictionaryData> util = new ExcelUtil<DictionaryData>(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));
}
}

View File

@ -101,6 +101,8 @@ public class DataSource extends BaseEntity
@Excel(name = "数据来源名称")
private String modeName;
public String getJdbcDriver() {
return jdbcDriver;
}

View File

@ -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<DictionaryData> dictionaryDataList;
public List<DictionaryData> getDictionaryDataList() {
return dictionaryDataList;
}
public void setDictionaryDataList(List<DictionaryData> 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();
}
}

View File

@ -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();
}
}

View File

@ -61,4 +61,6 @@ public interface AssetModelMapper
public int deleteAssetModelByIds(Long[] ids);
void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets);
List<AssetModel> getAssetModelList(@Param("longs") List<Long> longs);
}

View File

@ -64,4 +64,6 @@ public interface DataAssetMapper
void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets);
List<DataAsset> selectDataAssetBatchId(@Param("longs") List<Long> longs);
List<DataAsset> getDataAssetList(@Param("ids") Long[] ids);
}

View File

@ -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<DictionaryData> 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<DictionaryData> getDictionaryDataList(@Param("dictionaryIds") List<Long> dictionaryIds);
void deleteDictionaryData(@Param("dictionaryIds") List<Long> dictionaryIds);
}

View File

@ -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<Dictionary> 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<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId);
}

View File

@ -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<DictionaryData> 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);
}

View File

@ -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<Dictionary> 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);
}

View File

@ -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<DataSource> selectDataSourceList(DataSource dataSource)
{
List<DataSource> 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<TableDetail> 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<DataAsset> dataAssetList=dataAssetMapper.getDataAssetList(ids);
if (!dataAssetList.isEmpty()){
List<Long> dataAssetIds = dataAssetList.stream().map(DataAsset::getId).toList();
List<AssetModel> assetModelList=assetModelMapper.getAssetModelList(dataAssetIds);
dataAssetMapper.deleteDataAssetByIds(dataAssetIds.toArray(Long[]::new));
if (!assetModelList.isEmpty()){
List<Long> 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();

View File

@ -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<DictionaryData> 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);
}
}

View File

@ -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<Dictionary> 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<Dictionary> dictionaryList=dictionaryMapper.getDictionaryList(dataSourceId);
if (!dictionaryList.isEmpty()){
List<DictionaryData> dictionaryDataList=dictionaryDataMapper.getDictionaryDataList(dictionaryList.stream().map(Dictionary::getId).toList());
dictionaryList.stream()
.forEach(dictionary -> {
List<DictionaryData> 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<Dictionary> dictionaryList = dictionaryMapper.selectDictionaryList(dictionary);
if (!dictionaryList.isEmpty()){
dictionaryDataMapper.deleteDictionaryData(dictionaryList.stream().map(Dictionary::getId).toList());
}
dictionaryMapper.deleteDictionaryById(id);
return Result.success();
}
}

View File

@ -51,7 +51,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectAssetModelVo"/>
where id = #{id}
</select>
<select id="getAssetModelList" resultType="com.muyu.etl.domain.AssetModel">
<include refid="selectAssetModelVo"></include>
<where>
and data_asset_id in (
<foreach collection="longs" item="id" separator=",">
#{id}
</foreach>
)
</where>
</select>
<insert id="insertAssetModel" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id">
insert into asset_model
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -45,6 +45,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
)
</select>
<select id="getDataAssetList" resultType="com.muyu.etl.domain.DataAsset">
<include refid="selectDataAssetVo"></include>
<where>
and data_source_id in (
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</where>
</select>
<insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
insert into data_asset

View File

@ -0,0 +1,103 @@
<?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">
<mapper namespace="com.muyu.etl.mapper.DictionaryDataMapper">
<resultMap type="com.muyu.etl.domain.DictionaryData" id="DictionaryDataResult">
<result property="id" column="id" />
<result property="dictionaryId" column="dictionary_id" />
<result property="label" column="label" />
<result property="val" column="val" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDictionaryDataVo">
select id, dictionary_id, label, val, create_by, create_time, update_by, update_time, remark from dictionary_data
</sql>
<select id="selectDictionaryDataList" parameterType="com.muyu.etl.domain.DictionaryData" resultMap="DictionaryDataResult">
<include refid="selectDictionaryDataVo"/>
<where>
<if test="dictionaryId != null "> and dictionary_id = #{dictionaryId}</if>
<if test="label != null and dictionaryTag != ''"> and label = #{label}</if>
<if test="val != null and dictionaryValue != ''"> and val = #{val}</if>
</where>
</select>
<select id="selectDictionaryDataById" parameterType="Long" resultMap="DictionaryDataResult">
<include refid="selectDictionaryDataVo"/>
where id = #{id}
</select>
<select id="getDictionaryDataList" resultType="com.muyu.etl.domain.DictionaryData">
<include refid="selectDictionaryDataVo"></include>
<where>
and dictionary_id in (
<foreach collection="dictionaryIds" item="id" separator=",">
#{id}
</foreach>
)
</where>
</select>
<insert id="insertDictionaryData" parameterType="com.muyu.etl.domain.DictionaryData" useGeneratedKeys="true" keyProperty="id">
insert into dictionary_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictionaryId != null">dictionary_id,</if>
<if test="label != null">label,</if>
<if test="val != null">val,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictionaryId != null">#{dictionaryId},</if>
<if test="label != null">#{label},</if>
<if test="val != null">#{val},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDictionaryData" parameterType="com.muyu.etl.domain.DictionaryData">
update dictionary_data
<trim prefix="SET" suffixOverrides=",">
<if test="dictionaryId != null">dictionary_id = #{dictionaryId},</if>
<if test="label != null">label = #{label},</if>
<if test="val != null">val = #{val},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<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="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDictionaryDataById" parameterType="Long">
delete from dictionary_data where id = #{id}
</delete>
<delete id="deleteDictionaryDataByIds" parameterType="String">
delete from dictionary_data where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteDictionaryData">
delete from dictionary_data where dictionary_id in (
<foreach collection="dictionaryIds" item="id" separator=",">
#{id}
</foreach>
)
</delete>
</mapper>

View File

@ -0,0 +1,92 @@
<?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">
<mapper namespace="com.muyu.etl.mapper.DictionaryMapper">
<resultMap type="com.muyu.etl.domain.Dictionary" id="DictionaryResult">
<result property="id" column="id" />
<result property="dictionaryName" column="dictionary_name" />
<result property="dictionaryKey" column="dictionary_key" />
<result property="dataSourceId" column="data_source_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDictionaryVo">
select id, dictionary_name, dictionary_key,data_source_id, create_by, create_time, update_by, update_time, remark from dictionary
</sql>
<select id="selectDictionaryList" parameterType="com.muyu.etl.domain.Dictionary" resultMap="DictionaryResult">
<include refid="selectDictionaryVo"/>
<where>
<if test="dictionaryName != null and dictionaryName != ''"> and dictionary_name like concat('%', #{dictionaryName}, '%')</if>
<if test="dictionaryKey != null and dictionaryKey != ''"> and dictionary_key = #{dictionaryKey}</if>
<if test="dataSourceId != null"> and data_source_id = #{dataSourceId}</if>
</where>
</select>
<select id="selectDictionaryById" parameterType="Long" resultMap="DictionaryResult">
<include refid="selectDictionaryVo"/>
where id = #{id}
</select>
<select id="getDictionaryList" resultType="com.muyu.etl.domain.Dictionary">
<include refid="selectDictionaryVo"></include>
<where>
and data_source_id = #{dataSourceId}
</where>
</select>
<insert id="insertDictionary" parameterType="com.muyu.etl.domain.Dictionary" useGeneratedKeys="true" keyProperty="id">
insert into dictionary
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictionaryName != null">dictionary_name,</if>
<if test="dictionaryKey != null">dictionary_key,</if>
<if test="dataSourceId != null">data_source_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictionaryName != null">#{dictionaryName},</if>
<if test="dictionaryKey != null">#{dictionaryKey},</if>
<if test="dataSourceId != null">#{dataSourceId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDictionary" parameterType="com.muyu.etl.domain.Dictionary">
update dictionary
<trim prefix="SET" suffixOverrides=",">
<if test="dictionaryName != null">dictionary_name = #{dictionaryName},</if>
<if test="dictionaryKey != null">dictionary_key = #{dictionaryKey},</if>
<if test="dataSourceId != null">data_source_id = #{dataSourceId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<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="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDictionaryById" parameterType="Long">
delete from dictionary where id = #{id}
</delete>
<delete id="deleteDictionaryByIds" parameterType="String">
delete from dictionary where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>