feat: 字典表
parent
a46e405889
commit
8a1ffb7da2
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,7 +17,7 @@ import java.util.List;
|
|||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@SuperBuilder
|
||||
public class Diction {
|
||||
/**
|
||||
* 主鍵
|
||||
|
@ -37,10 +38,4 @@ public class Diction {
|
|||
|
||||
private List<Dictionaryy> dictionaryTypes;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,12 +15,19 @@ import java.util.Date;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class DictionaryType {
|
||||
|
||||
public class DictionaryType extends BaseEntity{
|
||||
|
||||
/**
|
||||
* 主鍵
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 接口注入
|
||||
*/
|
||||
private Integer dataAccess;
|
||||
|
||||
/**
|
||||
* 名稱
|
||||
*/
|
||||
|
@ -33,28 +40,4 @@ public class DictionaryType {
|
|||
* 狀態
|
||||
*/
|
||||
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
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public class Dictionaryy extends BaseEntity {
|
||||
@Builder
|
||||
public class Dictionaryy {
|
||||
/**
|
||||
* 主鍵
|
||||
*/
|
||||
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
|
||||
public class AssetStructureList {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String systemName;
|
||||
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.SysUser;
|
||||
import com.muyu.kvt.dictionary.Diction;
|
||||
import com.muyu.kvt.dictionary.DictionaryType;
|
||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
import com.muyu.kvt.domain.req.KvtEditReq;
|
||||
|
@ -216,18 +217,45 @@ public class KvtController extends BaseController {
|
|||
|
||||
//查询字典
|
||||
@PostMapping("/selectDictionaryy")
|
||||
public Result<List<Diction>> selectDictionaryy(@RequestParam String databaseName){
|
||||
List<Diction> list= kvtService.selectDictionaryy(databaseName);
|
||||
public Result<List<Diction>> selectDictionaryy(@RequestParam Integer id){
|
||||
List<Diction> list= kvtService.selectDictionaryy(id);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//同步数据添加到数据库
|
||||
@PostMapping("/synchronizationAdd")
|
||||
public Result synchronizationAdd(@RequestBody Kvt kvt) throws SQLException, ClassNotFoundException {
|
||||
|
||||
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.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.kvt.dictionary.Diction;
|
||||
import com.muyu.kvt.dictionary.DictionaryType;
|
||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
|
@ -57,9 +58,21 @@ public interface KvtMapper extends BaseMapper<Kvt> {
|
|||
|
||||
List<String> selectTable(String databaseName);
|
||||
|
||||
List<Dictionaryy> selectDictionaryy(String databaseName);
|
||||
List<DictionaryType> selectDictionaryy(Integer id);
|
||||
|
||||
DictionaryType selectDictionaryType(String type);
|
||||
|
||||
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.system.domain.SysDept;
|
||||
import com.muyu.kvt.dictionary.Diction;
|
||||
import com.muyu.kvt.dictionary.DictionaryType;
|
||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
import com.muyu.kvt.domain.req.AssetStructureResponse;
|
||||
|
@ -62,12 +63,20 @@ public interface KvtService extends IService<Kvt> {
|
|||
|
||||
List<SysDept> deptList();
|
||||
|
||||
List<Diction> selectDictionaryy(String databaseName);
|
||||
List<Diction> selectDictionaryy(Integer id);
|
||||
|
||||
List<DataAuthorization> selectDataAuthorization(String databaseName);
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -344,34 +344,34 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Diction> selectDictionaryy(String databaseName) {
|
||||
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();
|
||||
public List<Diction> selectDictionaryy(Integer id) {
|
||||
|
||||
boolean exists = dictions.stream()
|
||||
.anyMatch(d -> d.getType().equals(build.getType()) &&
|
||||
d.getStatus().equals(build.getStatus()) &&
|
||||
d.getName().equals(build.getName()) &&
|
||||
d.getId().equals(build.getId()));
|
||||
List<DictionaryType> dictions = baseMapper.selectDictionaryy(id);
|
||||
|
||||
// 如果不存在,则添加到列表中
|
||||
if (!exists) {
|
||||
dictions.add(build);
|
||||
}
|
||||
List<Diction> dictions1 = dictions.stream()
|
||||
.map(dictionaryType -> {
|
||||
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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
from kvt
|
||||
</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">
|
||||
truncate table #{tableName}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="dataTypeList" resultType="com.muyu.kvt.domain.DataType">
|
||||
select * from data_type
|
||||
</select>
|
||||
|
@ -106,12 +118,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
TABLE_SCHEMA = #{databaseName}
|
||||
</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 * from dictionary_type where type =#{type}
|
||||
</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">
|
||||
|
@ -161,4 +187,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
VALUES ( #{name}, #{as}, #{dataTotal}
|
||||
, #{isPrimaryKey})
|
||||
</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>
|
||||
|
|
Loading…
Reference in New Issue