fix: 修复完善了字典表的新增,删除,和字典表数据的新增,修改,以及在资产数据字典的展示
parent
69e70e451b
commit
ba27959f19
|
@ -18,6 +18,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- PostgreSQL JDBC驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
|
|
@ -80,7 +80,7 @@ public class AssetModelController extends BaseController
|
|||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@PostMapping("/UpdateAssetModel")
|
||||
public Result edit(@RequestBody AssetModel assetModel)
|
||||
{
|
||||
return toAjax(assetModelService.updateAssetModel(assetModel));
|
||||
|
|
|
@ -5,6 +5,8 @@ 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;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 asset_model
|
||||
*
|
||||
|
@ -65,6 +67,29 @@ public class AssetModel extends BaseEntity
|
|||
/** 字典key */
|
||||
@Excel(name = "字典key")
|
||||
private String dictKey;
|
||||
/** 字典id */
|
||||
@Excel(name = "字典key")
|
||||
private Long dictionaryId;
|
||||
|
||||
/** 字典信息 */
|
||||
@Excel(name = "字典信息")
|
||||
private List<DictionaryData> dictionaryDatas;
|
||||
|
||||
public Long getDictionaryId() {
|
||||
return dictionaryId;
|
||||
}
|
||||
|
||||
public void setDictionaryId(Long dictionaryId) {
|
||||
this.dictionaryId = dictionaryId;
|
||||
}
|
||||
|
||||
public List<DictionaryData> getDictionaryDatas() {
|
||||
return dictionaryDatas;
|
||||
}
|
||||
|
||||
public void setDictionaryDatas(List<DictionaryData> dictionaryDatas) {
|
||||
this.dictionaryDatas = dictionaryDatas;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.etl.feign;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @ClassName SysUserFeignService
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/25 16:05
|
||||
*/
|
||||
@FeignClient("muyu-system")
|
||||
public interface SysUserFeignService {
|
||||
@GetMapping("/user/list")
|
||||
public Result<TableDataInfo<SysUser>> list (SysUser user);
|
||||
}
|
|
@ -63,4 +63,6 @@ public interface AssetModelMapper
|
|||
void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets);
|
||||
|
||||
List<AssetModel> getAssetModelList(@Param("longs") List<Long> longs);
|
||||
|
||||
void updAssetModelDict(Long id);
|
||||
}
|
||||
|
|
|
@ -62,5 +62,5 @@ public interface DictionaryDataMapper
|
|||
|
||||
List<DictionaryData> getDictionaryDataList(@Param("dictionaryIds") List<Long> dictionaryIds);
|
||||
|
||||
void deleteDictionaryData(@Param("dictionaryIds") List<Long> dictionaryIds);
|
||||
void deleteDictionaryData(@Param("id") Long id);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -61,4 +62,6 @@ public interface DictionaryMapper
|
|||
public int deleteDictionaryByIds(Long[] ids);
|
||||
|
||||
List<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId);
|
||||
|
||||
List<Dictionary> getDictionaryDataList(@Param("strings") List<String> strings);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ 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.AssetModelMapper;
|
||||
|
@ -67,6 +68,7 @@ public class AssetModelServiceImpl implements IAssetModelService
|
|||
public int updateAssetModel(AssetModel assetModel)
|
||||
{
|
||||
assetModel.setUpdateTime(DateUtils.getNowDate());
|
||||
assetModel.setUpdateBy(SecurityUtils.getUsername());
|
||||
return assetModelMapper.updateAssetModel(assetModel);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
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.*;
|
||||
import com.muyu.etl.domain.Dictionary;
|
||||
import com.muyu.etl.domain.custom.*;
|
||||
import com.muyu.etl.mapper.AssetModelMapper;
|
||||
import com.muyu.etl.mapper.DataAssetMapper;
|
||||
import com.muyu.etl.feign.SysUserFeignService;
|
||||
import com.muyu.etl.mapper.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.etl.mapper.DataSourceMapper;
|
||||
import com.muyu.etl.service.IDataSourceService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -38,6 +35,21 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
@Autowired
|
||||
private AssetModelMapper assetModelMapper;
|
||||
|
||||
@Autowired
|
||||
private DictionaryDataMapper dictionaryDataMapper;
|
||||
|
||||
@Autowired
|
||||
private DictionaryServiceImpl dictionaryService;
|
||||
|
||||
@Autowired
|
||||
private SourceAccreditMapper sourceAccreditMapper;
|
||||
|
||||
@Autowired
|
||||
private AssetAccreditMapper assetAccreditMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserFeignService sysUserFeignService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -112,14 +124,24 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
@Transactional
|
||||
public int deleteDataSourceByIds(Long[] ids)
|
||||
{
|
||||
deleteChildLevel(ids);
|
||||
deleteChildLevel(ids,"delete");
|
||||
return dataSourceMapper.deleteDataSourceByIds(ids);
|
||||
}
|
||||
|
||||
public void deleteChildLevel(Long[] ids){
|
||||
public void deleteAccredit(List<Long> sourceIds,List<Long> assetIds){
|
||||
if (!sourceIds.isEmpty()){
|
||||
sourceAccreditMapper.deleteSourceAccreditBySourceIds(sourceIds);
|
||||
}
|
||||
if (!assetIds.isEmpty()){
|
||||
assetAccreditMapper.deleteAssetAccreditByAssetIds(assetIds);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteChildLevel(Long[] ids,String type){
|
||||
List<DataAsset> dataAssetList=dataAssetMapper.getDataAssetList(ids);
|
||||
List<Long> dataAssetIds = new ArrayList<>();
|
||||
if (!dataAssetList.isEmpty()){
|
||||
List<Long> dataAssetIds = dataAssetList.stream().map(DataAsset::getId).toList();
|
||||
dataAssetIds = dataAssetList.stream().map(DataAsset::getId).toList();
|
||||
List<AssetModel> assetModelList=assetModelMapper.getAssetModelList(dataAssetIds);
|
||||
dataAssetMapper.deleteDataAssetByIds(dataAssetIds.toArray(Long[]::new));
|
||||
if (!assetModelList.isEmpty()){
|
||||
|
@ -127,6 +149,12 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
assetModelMapper.deleteAssetModelByIds(assetModelIds.toArray(Long[]::new));
|
||||
}
|
||||
}
|
||||
if ("delete".equals(type)){
|
||||
deleteAccredit(Arrays.stream(ids).toList(),dataAssetIds);
|
||||
}else{
|
||||
deleteAccredit(new ArrayList<Long>(),dataAssetIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,7 +392,7 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
|
||||
@Override
|
||||
public Result synchronousData(DataSource dataSource) {
|
||||
deleteChildLevel(new Long[]{dataSource.getId()});
|
||||
deleteChildLevel(new Long[]{dataSource.getId()},"synchronous");
|
||||
String jdbcUrl = "";
|
||||
String sql="";
|
||||
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
|
@ -439,6 +467,19 @@ public class DataSourceServiceImpl implements IDataSourceService
|
|||
AssetModel assetModel = new AssetModel();
|
||||
assetModel.setDataAssetId(dataAsset.getId());
|
||||
List<AssetModel> assetModels = assetModelMapper.selectAssetModelList(assetModel);
|
||||
List<String> strings = assetModels.stream().map(AssetModel::getDictKey).toList();
|
||||
if (!strings.isEmpty()){
|
||||
Result<List<Dictionary>> result = dictionaryService.getDictionaryDataList(strings);
|
||||
List<Dictionary> data = result.getData();
|
||||
assetModels.stream()
|
||||
.forEach(assetModel1 -> {
|
||||
data.stream().forEach(dataInfo -> {
|
||||
if (assetModel1.getDictKey().equals(dataInfo.getDictionaryKey())){
|
||||
assetModel1.setDictionaryDatas(dataInfo.getDictionaryDataList());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return Result.success(assetModels);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.AssetModelMapper;
|
||||
import com.muyu.etl.mapper.DictionaryDataMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -32,6 +33,9 @@ public class DictionaryServiceImpl implements IDictionaryService
|
|||
@Autowired
|
||||
private DictionaryDataMapper dictionaryDataMapper;
|
||||
|
||||
@Autowired
|
||||
private AssetModelMapper assetModelMapper;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
|
@ -125,13 +129,22 @@ public class DictionaryServiceImpl implements IDictionaryService
|
|||
@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());
|
||||
}
|
||||
dictionaryDataMapper.deleteDictionaryData(id);
|
||||
dictionaryMapper.deleteDictionaryById(id);
|
||||
assetModelMapper.updAssetModelDict(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
public Result getDictionaryDataList(List<String> strings) {
|
||||
List<Dictionary> dictionaryList = dictionaryMapper.getDictionaryDataList(strings);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="isDict" column="is_dict" />
|
||||
<result property="defaultValue" column="default_value" />
|
||||
<result property="dictKey" column="dict_key" />
|
||||
<result property="dictionaryId" column="dictionary_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectAssetModelVo">
|
||||
select id, 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, update_by, update_time, remark from asset_model
|
||||
select id, data_asset_id, name, comment, is_primary_key, type, mapping_type, length, decimal_places, is_null, is_dict,default_value, dict_key,dictionary_id, create_by, create_time, update_by, update_time, remark from asset_model
|
||||
</sql>
|
||||
|
||||
<select id="selectAssetModelList" parameterType="com.muyu.etl.domain.AssetModel" resultMap="AssetModelResult">
|
||||
|
@ -44,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDict != null and isDict != ''"> and is_dict = #{isDict}</if>
|
||||
<if test="defaultValue != null and defaultValue != ''"> and default_value = #{defaultValue}</if>
|
||||
<if test="dictKey != null and dictKey != ''"> and dict_key = #{dictKey}</if>
|
||||
<if test="dictionaryId != null and dictionaryId != ''"> and dictionary_id = #{dictionaryId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
@ -158,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDict != null">is_dict = #{isDict},</if>
|
||||
<if test="defaultValue != null">default_value = #{defaultValue},</if>
|
||||
<if test="dictKey != null">dict_key = #{dictKey},</if>
|
||||
<if test="dictionaryId != null">dictionary_id = #{dictionaryId},</if>
|
||||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
|
@ -166,6 +169,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updAssetModelDict">
|
||||
update asset_model set is_dict='', dict_key='',dictionary_id=null where dictionary_id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAssetModelById" parameterType="Long">
|
||||
delete from asset_model where id = #{id}
|
||||
|
|
|
@ -94,10 +94,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteDictionaryData">
|
||||
delete from dictionary_data where dictionary_id in (
|
||||
<foreach collection="dictionaryIds" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
delete from dictionary_data where dictionary_id = #{id}
|
||||
</delete>
|
||||
</mapper>
|
|
@ -39,6 +39,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and data_source_id = #{dataSourceId}
|
||||
</where>
|
||||
</select>
|
||||
<select id="getDictionaryDataList" resultType="com.muyu.etl.domain.Dictionary">
|
||||
<include refid="selectDictionaryVo"></include>
|
||||
<where>
|
||||
and dictionary_key in (
|
||||
<foreach collection="strings" item="string" separator=",">
|
||||
#{string}
|
||||
</foreach>
|
||||
)
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertDictionary" parameterType="com.muyu.etl.domain.Dictionary" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into dictionary
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
|
|
@ -59,7 +59,6 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@RequiresPermissions("system:user:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysUser>> list (SysUser user) {
|
||||
startPage();
|
||||
|
|
Loading…
Reference in New Issue