feat: 字典表
parent
a46e405889
commit
8a1ffb7da2
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Builder
|
@SuperBuilder
|
||||||
public class Diction {
|
public class Diction {
|
||||||
/**
|
/**
|
||||||
* 主鍵
|
* 主鍵
|
||||||
|
@ -37,10 +38,4 @@ public class Diction {
|
||||||
|
|
||||||
private List<Dictionaryy> dictionaryTypes;
|
private List<Dictionaryy> dictionaryTypes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,19 @@ import java.util.Date;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class DictionaryType {
|
|
||||||
|
public class DictionaryType extends BaseEntity{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主鍵
|
* 主鍵
|
||||||
*/
|
*/
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口注入
|
||||||
|
*/
|
||||||
|
private Integer dataAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名稱
|
* 名稱
|
||||||
*/
|
*/
|
||||||
|
@ -33,28 +40,4 @@ public class DictionaryType {
|
||||||
* 狀態
|
* 狀態
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
* 更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,13 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@Builder
|
||||||
|
public class Dictionaryy {
|
||||||
public class Dictionaryy extends BaseEntity {
|
|
||||||
/**
|
/**
|
||||||
* 主鍵
|
* 主鍵
|
||||||
*/
|
*/
|
||||||
private Integer id;
|
private Integer id;
|
||||||
/**
|
|
||||||
* 接口注入
|
|
||||||
*/
|
|
||||||
private String dataAccess;
|
|
||||||
/**
|
/**
|
||||||
* 字典名稱
|
* 字典名稱
|
||||||
*/
|
*/
|
||||||
|
@ -40,8 +36,7 @@ public class Dictionaryy extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 狀態
|
* 狀態
|
||||||
*/
|
*/
|
||||||
private String status;
|
private Integer dictionStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class AssetStructureList {
|
public class AssetStructureList {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private String systemName;
|
private String systemName;
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.SysDept;
|
import com.muyu.common.system.domain.SysDept;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.kvt.dictionary.Diction;
|
import com.muyu.kvt.dictionary.Diction;
|
||||||
|
import com.muyu.kvt.dictionary.DictionaryType;
|
||||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||||
import com.muyu.kvt.domain.*;
|
import com.muyu.kvt.domain.*;
|
||||||
import com.muyu.kvt.domain.req.KvtEditReq;
|
import com.muyu.kvt.domain.req.KvtEditReq;
|
||||||
|
@ -216,18 +217,45 @@ public class KvtController extends BaseController {
|
||||||
|
|
||||||
//查询字典
|
//查询字典
|
||||||
@PostMapping("/selectDictionaryy")
|
@PostMapping("/selectDictionaryy")
|
||||||
public Result<List<Diction>> selectDictionaryy(@RequestParam String databaseName){
|
public Result<List<Diction>> selectDictionaryy(@RequestParam Integer id){
|
||||||
List<Diction> list= kvtService.selectDictionaryy(databaseName);
|
List<Diction> list= kvtService.selectDictionaryy(id);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//同步数据添加到数据库
|
//同步数据添加到数据库
|
||||||
@PostMapping("/synchronizationAdd")
|
@PostMapping("/synchronizationAdd")
|
||||||
public Result synchronizationAdd(@RequestBody Kvt kvt) throws SQLException, ClassNotFoundException {
|
public Result synchronizationAdd(@RequestBody Kvt kvt) throws SQLException, ClassNotFoundException {
|
||||||
|
|
||||||
return kvtService.synchronizationAdd(kvt);
|
return kvtService.synchronizationAdd(kvt);
|
||||||
}
|
}
|
||||||
|
//添加字典
|
||||||
|
@PostMapping("/dictionaryTypeAdd")
|
||||||
|
public Result dictionaryTypeAdd(@RequestBody Dictionaryy dictionaryy) {
|
||||||
|
kvtService.dictionaryTypeAdd(dictionaryy);
|
||||||
|
return Result.success("添加成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
//添加字典类型
|
||||||
|
@PostMapping("/dictionTypeAdd")
|
||||||
|
public Result dictionTypeAdd(@RequestBody DictionaryType dictionaryType) {
|
||||||
|
kvtService.dictionTypeAdd(dictionaryType);
|
||||||
|
return Result.success("添加成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
//查询字典是否存在
|
||||||
|
@PostMapping("/selectDictionaryTypeId")
|
||||||
|
public Result selectDictionaryTypeId(@RequestBody Dictionaryy dictionaryy) {
|
||||||
|
Dictionaryy dictionaryType = kvtService.selectDictionaryTypeId(dictionaryy.getId());
|
||||||
|
if (dictionaryy !=null ){
|
||||||
|
kvtService.delDictionaryTypeId(dictionaryy);
|
||||||
|
return Result.success("修改成功");
|
||||||
|
}
|
||||||
|
return Result.success("添加成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.kvt.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.common.system.domain.SysDept;
|
import com.muyu.common.system.domain.SysDept;
|
||||||
|
import com.muyu.kvt.dictionary.Diction;
|
||||||
import com.muyu.kvt.dictionary.DictionaryType;
|
import com.muyu.kvt.dictionary.DictionaryType;
|
||||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||||
import com.muyu.kvt.domain.*;
|
import com.muyu.kvt.domain.*;
|
||||||
|
@ -57,9 +58,21 @@ public interface KvtMapper extends BaseMapper<Kvt> {
|
||||||
|
|
||||||
List<String> selectTable(String databaseName);
|
List<String> selectTable(String databaseName);
|
||||||
|
|
||||||
List<Dictionaryy> selectDictionaryy(String databaseName);
|
List<DictionaryType> selectDictionaryy(Integer id);
|
||||||
|
|
||||||
DictionaryType selectDictionaryType(String type);
|
DictionaryType selectDictionaryType(String type);
|
||||||
|
|
||||||
void childAdd(Child build1);
|
void childAdd(Child build1);
|
||||||
|
|
||||||
|
void dictionaryTypeAdd(Dictionaryy diction);
|
||||||
|
|
||||||
|
void dictionTypeAdd(DictionaryType dictionaryType);
|
||||||
|
|
||||||
|
List<Diction> selectDictionary();
|
||||||
|
|
||||||
|
List<Dictionaryy> selectDiction(String type);
|
||||||
|
|
||||||
|
Dictionaryy selectDictionaryTypeId(Integer id);
|
||||||
|
|
||||||
|
void updateDictionaryTypeId(Dictionaryy dictionaryy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.system.domain.SysDept;
|
import com.muyu.common.system.domain.SysDept;
|
||||||
import com.muyu.kvt.dictionary.Diction;
|
import com.muyu.kvt.dictionary.Diction;
|
||||||
|
import com.muyu.kvt.dictionary.DictionaryType;
|
||||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||||
import com.muyu.kvt.domain.*;
|
import com.muyu.kvt.domain.*;
|
||||||
import com.muyu.kvt.domain.req.AssetStructureResponse;
|
import com.muyu.kvt.domain.req.AssetStructureResponse;
|
||||||
|
@ -62,12 +63,20 @@ public interface KvtService extends IService<Kvt> {
|
||||||
|
|
||||||
List<SysDept> deptList();
|
List<SysDept> deptList();
|
||||||
|
|
||||||
List<Diction> selectDictionaryy(String databaseName);
|
List<Diction> selectDictionaryy(Integer id);
|
||||||
|
|
||||||
List<DataAuthorization> selectDataAuthorization(String databaseName);
|
List<DataAuthorization> selectDataAuthorization(String databaseName);
|
||||||
|
|
||||||
Result synchronizationAdd(Kvt kvt) throws SQLException, ClassNotFoundException;
|
Result synchronizationAdd(Kvt kvt) throws SQLException, ClassNotFoundException;
|
||||||
|
|
||||||
|
void dictionaryTypeAdd(Dictionaryy diction);
|
||||||
|
|
||||||
|
void dictionTypeAdd(DictionaryType dictionaryType);
|
||||||
|
|
||||||
|
Dictionaryy selectDictionaryTypeId(Integer id);
|
||||||
|
|
||||||
|
void delDictionaryTypeId(Dictionaryy dictionaryy);
|
||||||
|
|
||||||
|
|
||||||
// List<String> kvtList(Kvt kvt) throws ClassNotFoundException, SQLException;
|
// List<String> kvtList(Kvt kvt) throws ClassNotFoundException, SQLException;
|
||||||
|
|
||||||
|
|
|
@ -344,34 +344,34 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Diction> selectDictionaryy(String databaseName) {
|
public List<Diction> selectDictionaryy(Integer id) {
|
||||||
List<Dictionaryy> list = baseMapper.selectDictionaryy(databaseName);
|
|
||||||
List<Diction> dictions = new ArrayList<>();
|
|
||||||
for (Dictionaryy dictionaryy : list) {
|
|
||||||
DictionaryType dictionaryType= baseMapper.selectDictionaryType(dictionaryy.getType());
|
|
||||||
Diction build = Diction.builder()
|
|
||||||
.dictionaryTypes(list)
|
|
||||||
.type(dictionaryType.getType())
|
|
||||||
.status(0)
|
|
||||||
.name(dictionaryType.getName())
|
|
||||||
.id(dictionaryType.getId())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
boolean exists = dictions.stream()
|
List<DictionaryType> dictions = baseMapper.selectDictionaryy(id);
|
||||||
.anyMatch(d -> d.getType().equals(build.getType()) &&
|
|
||||||
d.getStatus().equals(build.getStatus()) &&
|
|
||||||
d.getName().equals(build.getName()) &&
|
|
||||||
d.getId().equals(build.getId()));
|
|
||||||
|
|
||||||
// 如果不存在,则添加到列表中
|
List<Diction> dictions1 = dictions.stream()
|
||||||
if (!exists) {
|
.map(dictionaryType -> {
|
||||||
dictions.add(build);
|
List<Dictionaryy> list = baseMapper.selectDiction(dictionaryType.getType());
|
||||||
}
|
Diction build = Diction.builder()
|
||||||
|
.id(dictionaryType.getId())
|
||||||
|
.status(dictionaryType.getStatus())
|
||||||
|
.dictionaryTypes(list)
|
||||||
|
.name(dictionaryType.getName())
|
||||||
|
.type(dictionaryType.getType())
|
||||||
|
.build();
|
||||||
|
return build;
|
||||||
|
}).toList();
|
||||||
|
return dictions1;
|
||||||
|
// List<DictionaryType> dictTypeList = list(new LambdaQueryWrapper<>() {{
|
||||||
|
// eq(Dictionaryy::get, id);
|
||||||
|
// }});
|
||||||
|
//
|
||||||
|
// List<Diction> dictDataRespList = dictTypeList.stream().map(dictType -> {
|
||||||
|
// List<DictData> dictDataList = dictDataService.list(new LambdaQueryWrapper<>() {{
|
||||||
|
// eq(DictData::getDictTypeId, dictType.getId());
|
||||||
|
// }});
|
||||||
|
// return dictType.toDataDictResp(dictDataList);
|
||||||
|
// }).toList();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return dictions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -528,10 +528,28 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Result.success(kvt,"同步成功");
|
return Result.success("同步成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dictionaryTypeAdd(Dictionaryy diction) {
|
||||||
|
baseMapper.dictionaryTypeAdd(diction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dictionTypeAdd(DictionaryType dictionaryType) {
|
||||||
|
baseMapper. dictionTypeAdd(dictionaryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dictionaryy selectDictionaryTypeId(Integer id) {
|
||||||
|
return baseMapper.selectDictionaryTypeId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delDictionaryTypeId(Dictionaryy dictionaryy) {
|
||||||
|
baseMapper.updateDictionaryTypeId(dictionaryy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
|
|
@ -31,10 +31,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select id, name, system_name, type, host, port, database_name, connection_param, init_num, max_num, max_wait_time, max_wait_size, remark, create_by, create_time, update_by, update_time
|
select id, name, system_name, type, host, port, database_name, connection_param, init_num, max_num, max_wait_time, max_wait_size, remark, create_by, create_time, update_by, update_time
|
||||||
from kvt
|
from kvt
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<update id="updateDictionaryTypeId">
|
||||||
|
UPDATE `data_basete`.`dictionary`
|
||||||
|
SET `dictionary_name` = #{dictionaryName},
|
||||||
|
`dictionary_value` = #{dictionaryValue},
|
||||||
|
`type` = #{type},
|
||||||
|
`diction_status` = #{dictionStatus}
|
||||||
|
WHERE `id` = #{id}
|
||||||
|
|
||||||
|
|
||||||
|
</update>
|
||||||
<delete id="del">
|
<delete id="del">
|
||||||
truncate table #{tableName}
|
truncate table #{tableName}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
<select id="dataTypeList" resultType="com.muyu.kvt.domain.DataType">
|
<select id="dataTypeList" resultType="com.muyu.kvt.domain.DataType">
|
||||||
select * from data_type
|
select * from data_type
|
||||||
</select>
|
</select>
|
||||||
|
@ -106,12 +118,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE
|
WHERE
|
||||||
TABLE_SCHEMA = #{databaseName}
|
TABLE_SCHEMA = #{databaseName}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectDictionaryy" resultType="com.muyu.kvt.dictionary.Dictionaryy">
|
|
||||||
select * from dictionary where data_access =#{databaseName}
|
|
||||||
</select>
|
|
||||||
<select id="selectDictionaryType" resultType="com.muyu.kvt.dictionary.DictionaryType">
|
<select id="selectDictionaryType" resultType="com.muyu.kvt.dictionary.DictionaryType">
|
||||||
select * from dictionary_type where type =#{type}
|
select * from dictionary_type where type =#{type}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDictionary" resultType="com.muyu.kvt.dictionary.Diction">
|
||||||
|
SELECT dictionary_type.*, dictionary.dictionary_name, dictionary.dictionary_value, dictionary.`status`
|
||||||
|
FROM dictionary_type
|
||||||
|
LEFT JOIN dictionary on dictionary.type = dictionary_type.type
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="selectDictionaryy" resultType="com.muyu.kvt.dictionary.DictionaryType">
|
||||||
|
select * from dictionary_type
|
||||||
|
where data_access = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectDiction" resultType="com.muyu.kvt.dictionary.Dictionaryy">
|
||||||
|
select * from dictionary where type =#{type}
|
||||||
|
</select>
|
||||||
|
<select id="selectDictionaryTypeId" resultType="com.muyu.kvt.dictionary.Dictionaryy">
|
||||||
|
select * from dictionary where id =#{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="synchronizationAdd">
|
<insert id="synchronizationAdd">
|
||||||
|
@ -161,4 +187,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
VALUES ( #{name}, #{as}, #{dataTotal}
|
VALUES ( #{name}, #{as}, #{dataTotal}
|
||||||
, #{isPrimaryKey})
|
, #{isPrimaryKey})
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="dictionaryTypeAdd">
|
||||||
|
INSERT INTO `data_basete`.`dictionary`
|
||||||
|
( `dictionary_name`, `dictionary_value`, `type`,
|
||||||
|
`diction_status`)
|
||||||
|
VALUES ( #{dictionaryName}, #{dictionaryValue}, #{type}, #{dictionStatus});
|
||||||
|
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
<insert id="dictionTypeAdd">
|
||||||
|
INSERT INTO `data_basete`.`dictionary_type`
|
||||||
|
( `name`, `type`, `status`)
|
||||||
|
VALUES (#{name}, #{type}, #{status});
|
||||||
|
|
||||||
|
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue