feat(): 资产结构数据的数据字典
parent
c66661c52c
commit
8fcbd510f7
|
@ -0,0 +1,51 @@
|
|||
package com.etl.data.dictionary.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.etl.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
* @author Chao
|
||||
* @ClassName: Dictionary
|
||||
* @CreateTime: 2024/4/27 上午9:07
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("data_dictionary")
|
||||
public class DataDictionary extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 资产结构id
|
||||
*/
|
||||
private Long assetStructureId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 字典名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*
|
||||
* 字典类型
|
||||
*/
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.etl.data.dictionary.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.etl.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 数据字典类型
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryType 数据字典类型
|
||||
* @CreateTime: 2024/4/27 上午9:55
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("data_dictionary_type")
|
||||
public class DataDictionaryType extends BaseEntity {
|
||||
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典id
|
||||
*/
|
||||
private Long dataDictionaryId;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
private String value;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.etl.data.dictionary.domain.resp;
|
||||
|
||||
import com.etl.data.dictionary.domain.DataDictionary;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据返回类
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDicitonaryResp 字典数据返回类
|
||||
* @CreateTime: 2024/4/27 下午7:00
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DataDictionaryResp {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 资产结构id
|
||||
*/
|
||||
private Long assetStructureId;
|
||||
|
||||
/**
|
||||
* 字典名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private List<DataDictionaryType> dataDictionaryTypeList;
|
||||
|
||||
public static DataDictionaryResp dataDictionaryBuilder(DataDictionary dataDictionary, List<DataDictionaryType> dataDictionaryTypes) {
|
||||
return DataDictionaryResp.builder()
|
||||
.id(dataDictionary.getId())
|
||||
.assetStructureId(dataDictionary.getAssetStructureId())
|
||||
.name(dataDictionary.getName())
|
||||
.type(dataDictionary.getType())
|
||||
.dataDictionaryTypeList(dataDictionaryTypes)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.etl.data.dictionary.controller;
|
||||
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.log.annotation.Log;
|
||||
import com.etl.common.log.enums.BusinessType;
|
||||
import com.etl.common.security.annotation.RequiresPermissions;
|
||||
import com.etl.data.dictionary.domain.DataDictionary;
|
||||
import com.etl.data.dictionary.domain.resp.DataDictionaryResp;
|
||||
import com.etl.data.dictionary.service.IDataDictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典Controller层
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryController 数据字典Controller层
|
||||
* @CreateTime: 2024/4/27 上午9:13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dictionary")
|
||||
public class DataDictionaryController {
|
||||
|
||||
@Autowired
|
||||
private IDataDictionaryService dataDictionaryService;
|
||||
|
||||
/**
|
||||
* 获取数据字典列表
|
||||
*
|
||||
* @return 数据字典集合
|
||||
*/
|
||||
@GetMapping("dictionaryList/{assetStructureId}")
|
||||
public Result<List<DataDictionaryResp>> list(@PathVariable("assetStructureId") Long assetStructureId) {
|
||||
return Result.success(dataDictionaryService.dictionaryList(assetStructureId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典
|
||||
*/
|
||||
@RequiresPermissions("data:dictionary:save")
|
||||
@Log(title = "新增字典", businessType = BusinessType.INSERT)
|
||||
@PostMapping("dictionarySave")
|
||||
public Result save(@RequestBody DataDictionary dataDictionary) {
|
||||
dataDictionaryService.save(dataDictionary);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.etl.data.dictionary.controller;
|
||||
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.log.annotation.Log;
|
||||
import com.etl.common.log.enums.BusinessType;
|
||||
import com.etl.common.security.annotation.RequiresPermissions;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
import com.etl.data.dictionary.service.IDataDictionaryTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 数据字典类型Controller
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryTypeController 数据字典类型Controller
|
||||
* @CreateTime: 2024/4/27 上午9:55
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dictionaryType")
|
||||
public class DataDictionaryTypeController {
|
||||
|
||||
@Autowired
|
||||
private IDataDictionaryTypeService dataDictionaryTypeService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@RequiresPermissions("data:dictionaryType:save")
|
||||
@Log(title = "数据源信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping()
|
||||
public Result save(@RequestBody DataDictionaryType dataDictionaryType) {
|
||||
dataDictionaryTypeService.save(dataDictionaryType);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据源信息
|
||||
*/
|
||||
@RequiresPermissions("data:dictionary:edit")
|
||||
@Log(title = "数据源信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody DataDictionaryType dataDictionary) {
|
||||
return Result.success(dataDictionaryTypeService.updateById(dataDictionary));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.etl.data.dictionary.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.data.dictionary.domain.DataDictionary;
|
||||
|
||||
/**
|
||||
* 数据字典mapper接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryMapper 数据字典mapper接口
|
||||
* @CreateTime: 2024/4/27 上午9:35
|
||||
*/
|
||||
public interface DataDictionaryMapper extends BaseMapper<DataDictionary> {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.etl.data.dictionary.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
|
||||
/**
|
||||
* 字典类型mapper接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryTypeMapper 字典类型mapper接口
|
||||
* @CreateTime: 2024/4/27 下午3:29
|
||||
*/
|
||||
public interface DataDictionaryTypeMapper extends BaseMapper<DataDictionaryType> {
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.etl.data.dictionary.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.data.dictionary.domain.DataDictionary;
|
||||
import com.etl.data.dictionary.domain.resp.DataDictionaryResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典Service接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: IDataDictionaryService 数据字典Service接口
|
||||
* @CreateTime: 2024/4/27 上午9:28
|
||||
*/
|
||||
public interface IDataDictionaryService extends IService<DataDictionary> {
|
||||
|
||||
/**
|
||||
* 查询该数据源下所有的字典表
|
||||
* @param assetStructureId 数据id
|
||||
* @return
|
||||
*/
|
||||
List<DataDictionaryResp> dictionaryList(Long assetStructureId);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.etl.data.dictionary.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
|
||||
/**
|
||||
* 字典类型Service接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: IDataDictionaryType 字典类型Service接口
|
||||
* @CreateTime: 2024/4/27 上午10:07
|
||||
*/
|
||||
public interface IDataDictionaryTypeService extends IService<DataDictionaryType> {
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.etl.data.dictionary.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
import com.etl.data.dictionary.mapper.DataDictionaryTypeMapper;
|
||||
import com.etl.data.dictionary.service.IDataDictionaryTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 字典类型Service业务实现层
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: DataDictionaryTypeServiceImpl 字典类型Service业务实现层
|
||||
* @CreateTime: 2024/4/27 下午3:27
|
||||
*/
|
||||
@Service
|
||||
public class DataDictionaryTypeServiceImpl extends ServiceImpl<DataDictionaryTypeMapper, DataDictionaryType> implements IDataDictionaryTypeService {
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.etl.data.dictionary.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.data.dictionary.domain.DataDictionary;
|
||||
import com.etl.data.dictionary.domain.DataDictionaryType;
|
||||
import com.etl.data.dictionary.domain.resp.DataDictionaryResp;
|
||||
import com.etl.data.dictionary.mapper.DataDictionaryMapper;
|
||||
import com.etl.data.dictionary.service.IDataDictionaryService;
|
||||
import com.etl.data.dictionary.service.IDataDictionaryTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据字典Service接口业务处理层
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: IDataDictionaryServiceImpl 数据字典Service接口实现层
|
||||
* @CreateTime: 2024/4/27 上午9:28
|
||||
*/
|
||||
@Service
|
||||
public class IDataDictionaryServiceImpl extends ServiceImpl<DataDictionaryMapper, DataDictionary> implements IDataDictionaryService {
|
||||
|
||||
@Autowired
|
||||
private IDataDictionaryTypeService dataDictionaryTypeService;
|
||||
|
||||
/**
|
||||
* 查询当前数据源下所有的字典表
|
||||
*
|
||||
* @param assetStructureId 数据id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DataDictionaryResp> dictionaryList(Long assetStructureId) {
|
||||
List<DataDictionary> dataDictionaryList = this.list(
|
||||
new LambdaQueryWrapper<DataDictionary>()
|
||||
.eq(DataDictionary::getAssetStructureId, assetStructureId)
|
||||
);
|
||||
List<DataDictionaryType> dataDictionaryTypeList = dataDictionaryTypeService.list();
|
||||
return dataDictionaryList.stream().map(
|
||||
dataDictionary -> {
|
||||
List<DataDictionaryType> dataDictionaryTypes = dataDictionaryTypeList.stream()
|
||||
.filter(
|
||||
dataDictionaryType -> dataDictionaryType.getDataDictionaryId().equals(dataDictionary.getId())
|
||||
).collect(Collectors.toList());
|
||||
return DataDictionaryResp.dataDictionaryBuilder(dataDictionary, dataDictionaryTypes);
|
||||
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue