编写了数据字典的增删改查
parent
d771ab6505
commit
d5c5d390ed
|
@ -5,12 +5,15 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.source.domain.resp.DictDataResp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -47,4 +50,14 @@ public class DictType extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "数据源ID")
|
||||
private Integer assetId;
|
||||
|
||||
public DictDataResp toDataDictResp(List<DictData> list) {
|
||||
return DictDataResp.builder()
|
||||
.id(this.getId())
|
||||
.dictName(this.getDictName())
|
||||
.dictType(this.getDictType())
|
||||
.assetId(this.getAssetId())
|
||||
.dictData(list)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.source.domain.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:28
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DictTypeReq {
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@Schema(type = "Integer",defaultValue = "1",description = "数据源id")
|
||||
private Integer assetId;
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "字典类型",description = "字典类型")
|
||||
private String dictType;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.muyu.source.domain.resp;
|
||||
|
||||
import com.muyu.source.domain.DictData;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:28
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DictDataResp {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Schema(type = "Long",defaultValue = "主键",description = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "字典名称",description = "字典名称")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "字典类型",description = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 数据源编号
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "数据源编号",description = "数据源编号")
|
||||
private Integer assetId;
|
||||
|
||||
/**
|
||||
* 字典数据集合
|
||||
*/
|
||||
@Schema(type = "List",defaultValue = "字典数据集合",description = "字典数据集合")
|
||||
private List<DictData> dictData;
|
||||
}
|
|
@ -14,17 +14,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:05
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库结构控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/children")
|
||||
@Tag(name = "数据库结构控制层",description = "进行数据库结构管理,查看等相关操作")
|
||||
@Tag(name = "数据库结构控制层", description = "进行数据库结构管理,查看等相关操作")
|
||||
public class ChildrenController {
|
||||
public ChildrenController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
|
@ -32,26 +32,29 @@ public class ChildrenController {
|
|||
|
||||
@Autowired
|
||||
private ChildrenService childrenService;
|
||||
|
||||
/**
|
||||
* 查询数据库结构
|
||||
*
|
||||
* @param id 数据库id
|
||||
* @return 数据库结构
|
||||
*/
|
||||
@GetMapping("/selectChildren/{id}")
|
||||
@Operation(summary = "查询数据库结构",description = "可以根据数据源的ID查询数据库结构")
|
||||
public Result<Children> selectChildren(@PathVariable("id") Integer id){
|
||||
@Operation(summary = "查询数据库结构", description = "可以根据数据源的ID查询数据库结构")
|
||||
public Result<Children> selectChildren(@PathVariable("id") Integer id) {
|
||||
Children children = childrenService.getById(id);
|
||||
return Result.success(children);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个数据库中表的数量
|
||||
*
|
||||
* @param id 数据库结构ID
|
||||
* @return 资产数据模型数量
|
||||
*/
|
||||
@GetMapping("/getTableDataCount/{id}")
|
||||
@Operation(summary = "查询单个数据库中表的数量",description = "可以根据数据源的ID查询单个数据库中表的数量")
|
||||
public Result getTableDataCount(@PathVariable("id") Integer id){
|
||||
@Operation(summary = "查询单个数据库中表的数量", description = "可以根据数据源的ID查询单个数据库中表的数量")
|
||||
public Result getTableDataCount(@PathVariable("id") Integer id) {
|
||||
//TODO 统计资产模型的总数量
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,17 +18,17 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-18:34
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/dataSource")
|
||||
@Tag(name = "数据源控制层",description = "进行数据源管理,查看等相关操作")
|
||||
@Tag(name = "数据源控制层", description = "进行数据源管理,查看等相关操作")
|
||||
public class DataSourceController extends BaseController {
|
||||
public DataSourceController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
|
@ -43,36 +43,39 @@ public class DataSourceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据ID获取数据
|
||||
*
|
||||
* @param id 数据源ID
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("getDataSourceById/{id}")
|
||||
@Operation(summary = "根据ID获取数据",description = "根据ID获取数据")
|
||||
public Result<DataSource> getDataSourceById(@PathVariable("id") Long id){
|
||||
@Operation(summary = "根据ID获取数据", description = "根据ID获取数据")
|
||||
public Result<DataSource> getDataSourceById(@PathVariable("id") Long id) {
|
||||
DataSource dataSource = dataSourceService.getById(id);
|
||||
return Result.success(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源列表的全部数据
|
||||
*
|
||||
* @param dataSourceQueryReq 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询数据源列表的全部数据",description = "根据数据源的接入名称,来源系统名称可以进行数据源的筛选")
|
||||
public Result<List<DataSource>> list(DataSourceQueryReq dataSourceQueryReq){
|
||||
List<DataSource> list =dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
@Operation(summary = "查询数据源列表的全部数据", description = "根据数据源的接入名称,来源系统名称可以进行数据源的筛选")
|
||||
public Result<List<DataSource>> list(DataSourceQueryReq dataSourceQueryReq) {
|
||||
List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据源
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @param response response
|
||||
* @param response response
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
@Operation(summary = "导出数据源",description = "导出数据源为Excel的格式")
|
||||
public void derive(DataSource dataSource,HttpServletResponse response){
|
||||
@Operation(summary = "导出数据源", description = "导出数据源为Excel的格式")
|
||||
public void derive(DataSource dataSource, HttpServletResponse response) {
|
||||
List<DataSource> list = dataSourceService.list(dataSource);
|
||||
ExcelUtil<DataSource> excelUtil = new ExcelUtil<>(DataSource.class);
|
||||
excelUtil.exportExcel(response, list, "数据源数据");
|
||||
|
@ -80,64 +83,67 @@ public class DataSourceController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取数据源详细信息
|
||||
*
|
||||
* @param id 数据源ID
|
||||
* @return 数据源详细信息
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获取数据源详细信息",description = "根据ID获取数据源详细信息")
|
||||
public Result<DataSource> getById(@PathVariable("id") Long id){
|
||||
@Operation(summary = "获取数据源详细信息", description = "根据ID获取数据源详细信息")
|
||||
public Result<DataSource> getById(@PathVariable("id") Long id) {
|
||||
return Result.success(dataSourceService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表数据总数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectTableDataCount")
|
||||
@Operation(summary = "查询接入的数据库的总数",description = "查询接入的数据库的总数")
|
||||
@Operation(summary = "查询接入的数据库的总数", description = "查询接入的数据库的总数")
|
||||
public Result selectTableDataCount() {
|
||||
//TODO 统计出数据接入的数量
|
||||
//TODO 统计出数据接入的数量
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加数据源
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@PostMapping("/insert")
|
||||
@Operation(summary = "数据源的添加",description = "数据源的添加")
|
||||
public Result insert(@RequestBody DataSource dataSource){
|
||||
@Operation(summary = "数据源的添加", description = "数据源的添加")
|
||||
public Result insert(@RequestBody DataSource dataSource) {
|
||||
dataSourceService.save(dataSource);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据源
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "数据源的修改",description = "数据源的修改")
|
||||
public Result update(@RequestBody DataSource dataSource){
|
||||
@Operation(summary = "数据源的修改", description = "数据源的修改")
|
||||
public Result update(@RequestBody DataSource dataSource) {
|
||||
dataSourceService.updateById(dataSource);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据源
|
||||
*
|
||||
* @param id 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "数据源的删除",description = "可以根据数据源的ID删除/批量删除")
|
||||
public Result delete(@PathVariable("id") List<Long> id){
|
||||
@Operation(summary = "数据源的删除", description = "可以根据数据源的ID删除/批量删除")
|
||||
public Result delete(@PathVariable("id") List<Long> id) {
|
||||
dataSourceService.removeBatchByIds(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,21 +21,23 @@ import org.springframework.web.bind.annotation.*;
|
|||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/dict_data")
|
||||
@Tag(name = "数据字典控制层",description = "进行数据字典管理,查看等相关操作")
|
||||
@Tag(name = "数据字典控制层", description = "进行数据字典管理,查看等相关操作")
|
||||
public class DictDataController {
|
||||
public DictDataController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DictDataService dictDataService;
|
||||
|
||||
/**
|
||||
* 添加字典数据
|
||||
*
|
||||
* @param dictData 数据字典
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping("addDictData")
|
||||
@Operation(summary = "添加字典数据",description = "添加字典数据")
|
||||
@Operation(summary = "添加字典数据", description = "添加字典数据")
|
||||
public Result addDictData(@RequestBody DictData dictData) {
|
||||
dictDataService.save(dictData);
|
||||
return Result.success();
|
||||
|
@ -43,11 +45,12 @@ public class DictDataController {
|
|||
|
||||
/**
|
||||
* 修改字典数据
|
||||
*
|
||||
* @param dictData 数据字典
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PostMapping("editDictData")
|
||||
@Operation(summary = "修改字典数据",description = "修改字典数据")
|
||||
@Operation(summary = "修改字典数据", description = "修改字典数据")
|
||||
public Result editDictData(@RequestBody DictData dictData) {
|
||||
dictDataService.updateById(dictData);
|
||||
return Result.success();
|
||||
|
@ -55,11 +58,12 @@ public class DictDataController {
|
|||
|
||||
/**
|
||||
* 删除字典数据
|
||||
*
|
||||
* @param id 数据字典ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@GetMapping("/delDictData/{id}")
|
||||
@Operation(summary = "删除字典数据",description = "根据ID删除字典数据")
|
||||
@Operation(summary = "删除字典数据", description = "根据ID删除字典数据")
|
||||
public Result delDictData(@PathVariable("id") Long id) {
|
||||
dictDataService.removeById(id);
|
||||
return Result.success();
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import com.muyu.source.domain.DictType;
|
||||
import com.muyu.source.domain.req.DictTypeReq;
|
||||
import com.muyu.source.domain.resp.DictDataResp;
|
||||
import com.muyu.source.service.DictDataService;
|
||||
import com.muyu.source.service.DictTypeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:21
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型控制层
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/dict_type")
|
||||
public class DictTypeController {
|
||||
public DictTypeController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DictDataService dictDataService;
|
||||
@Autowired
|
||||
private DictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 根据字典类型id查询字典数据
|
||||
*
|
||||
* @param id 字典类型id
|
||||
* @return 字典数据
|
||||
*/
|
||||
@GetMapping("/getDictDataList/{id}")
|
||||
@Operation(summary = "查询字典数据", description = "根据字典类型id查询字典数据")
|
||||
public Result<List<DictDataResp>> getDictDataList(@PathVariable("id") Integer id) {
|
||||
List<DictDataResp> dictDataRespList = dictTypeService.getDictDataList(id);
|
||||
return Result.success(dictDataRespList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据对象查询字典数据列表
|
||||
*
|
||||
* @param dictTypeReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getDictData")
|
||||
@Operation(summary = "查询字典数据列表", description = "根据对象查询字典数据列表")
|
||||
public Result getDictData(@RequestBody DictTypeReq dictTypeReq) {
|
||||
List<DictData> dictData = dictTypeService.getDictData(dictTypeReq);
|
||||
return Result.success(dictData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加字典类型
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping("/addDictType")
|
||||
@Operation(summary = "添加字典类型", description = "添加字典类型")
|
||||
public Result addDictType(@RequestBody DictType dictType) {
|
||||
dictTypeService.save(dictType);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*
|
||||
* @param id 字典类型id
|
||||
* @return 删除结果
|
||||
*/
|
||||
@GetMapping("/delDictType/{id}")
|
||||
@Operation(summary = "删除字典类型", description = "根据ID删除字典类型")
|
||||
public Result delDictType(@PathVariable("id") Long id) {
|
||||
// 删除字典类型
|
||||
dictTypeService.removeById(id);
|
||||
// 删除相对应的字典数据
|
||||
dictDataService.remove(new LambdaQueryWrapper<>() {{
|
||||
eq(DictData::getDictTypeId, id);
|
||||
}});
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -14,17 +14,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:51
|
||||
* @ Version:1.0
|
||||
* @ Description:表结构控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/tableData")
|
||||
@Tag(name = "表结构控制层",description = "进行表结构管理,查看等相关操作")
|
||||
@Tag(name = "表结构控制层", description = "进行表结构管理,查看等相关操作")
|
||||
public class TableDataController {
|
||||
public TableDataController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
|
@ -35,27 +35,28 @@ public class TableDataController {
|
|||
|
||||
/**
|
||||
* 根据id查询表结构
|
||||
*
|
||||
* @param id id
|
||||
* @return 表结构
|
||||
*/
|
||||
@GetMapping("/selectTableData/{id}")
|
||||
@Operation(summary = "根据id查询表结构",description = "可以根据根据id查询表结构")
|
||||
public Result<TableData> selectTableData(@PathVariable("id") Integer id){
|
||||
@Operation(summary = "根据id查询表结构", description = "可以根据根据id查询表结构")
|
||||
public Result<TableData> selectTableData(@PathVariable("id") Integer id) {
|
||||
return Result.success(tableDataService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计出一个表中字段的数量
|
||||
*
|
||||
* @param id 表ID
|
||||
* @return 数量
|
||||
*/
|
||||
@GetMapping("/selectTableDataCount/{id}")
|
||||
@Operation(summary = "统计出一个表中字段的数量",description = "可以根据表的ID统计单个表中中表的数量")
|
||||
public Result selectTableDataCount(@PathVariable("id") Integer id){
|
||||
@Operation(summary = "统计出一个表中字段的数量", description = "可以根据表的ID统计单个表中中表的数量")
|
||||
public Result selectTableDataCount(@PathVariable("id") Integer id) {
|
||||
//TODO 统计出数据模型的数量
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import com.muyu.source.domain.Children;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:06
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库结构持久层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChildrenMapper extends BaseMapper<Children> {
|
||||
|
|
|
@ -5,12 +5,12 @@ import com.muyu.source.domain.DataSource;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-20:03
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源持久层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataSourceMapper extends BaseMapper<DataSource> {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.source.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.source.domain.DictType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:23
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型持久层
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictTypeMapper extends BaseMapper<DictType> {
|
||||
}
|
|
@ -5,12 +5,12 @@ import com.muyu.source.domain.TableData;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:52
|
||||
* @ Version:1.0
|
||||
* @ Description:表结构持久层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Mapper
|
||||
public interface TableDataMapper extends BaseMapper<TableData> {
|
||||
|
|
|
@ -6,12 +6,12 @@ import com.muyu.source.domain.Children;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:07
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库结构业务层
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface ChildrenService extends IService<Children> {
|
||||
|
||||
|
|
|
@ -6,17 +6,18 @@ import com.muyu.source.domain.DataSource;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-20:06
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源业务层
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface DataSourceService extends IService<DataSource> {
|
||||
|
||||
/**
|
||||
* 查询数据源的列表
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
|
|
|
@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.muyu.source.domain.DictData;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:14
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典业务层
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface DictDataService extends IService<DictData> {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import com.muyu.source.domain.DictType;
|
||||
import com.muyu.source.domain.req.DictTypeReq;
|
||||
import com.muyu.source.domain.resp.DictDataResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:24
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型业务层
|
||||
*/
|
||||
public interface DictTypeService extends IService<DictType> {
|
||||
/**
|
||||
* 根据字典类型id查询字典数据
|
||||
*
|
||||
* @param id 字典类型id
|
||||
* @return 字典数据
|
||||
*/
|
||||
List<DictDataResp> getDictDataList(Integer id);
|
||||
/**
|
||||
* 根据对象查询字典数据列表
|
||||
*
|
||||
* @param dictTypeReq
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<DictData> getDictData(DictTypeReq dictTypeReq);
|
||||
}
|
|
@ -12,12 +12,12 @@ import java.util.stream.IntStream;
|
|||
import java.util.stream.LongStream;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:08
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库结构业务实现层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Service
|
||||
public class ChildrenServiceImpl extends ServiceImpl<ChildrenMapper, Children> implements ChildrenService {
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-20-20:06
|
||||
* @ Version:1.0
|
||||
* @ Description:数据源业务层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Service
|
||||
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements DataSourceService {
|
||||
|
@ -25,17 +25,18 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
|
||||
/**
|
||||
* 查询数据源的列表
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> list(DataSource dataSource) {
|
||||
LambdaQueryWrapper<DataSource> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if(StringUtils.isNotEmpty(dataSource.getName())){
|
||||
lambdaQueryWrapper.like(DataSource::getName,dataSource.getName());
|
||||
if (StringUtils.isNotEmpty(dataSource.getName())) {
|
||||
lambdaQueryWrapper.like(DataSource::getName, dataSource.getName());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataSource.getSystemName())){
|
||||
lambdaQueryWrapper.like(DataSource::getSystemName,dataSource.getSystemName());
|
||||
if (StringUtils.isNotEmpty(dataSource.getSystemName())) {
|
||||
lambdaQueryWrapper.like(DataSource::getSystemName, dataSource.getSystemName());
|
||||
}
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package com.muyu.source.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import com.muyu.source.domain.DictType;
|
||||
import com.muyu.source.domain.req.DictTypeReq;
|
||||
import com.muyu.source.domain.resp.DictDataResp;
|
||||
import com.muyu.source.mapper.DictTypeMapper;
|
||||
import com.muyu.source.service.DictDataService;
|
||||
import com.muyu.source.service.DictTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:24
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型业务实现层
|
||||
*/
|
||||
@Service
|
||||
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {
|
||||
@Autowired
|
||||
private DictDataService dictDataService;
|
||||
/**
|
||||
* 根据字典类型id查询字典数据
|
||||
*
|
||||
* @param id 字典类型id
|
||||
* @return 字典数据
|
||||
*/
|
||||
@Override
|
||||
public List<DictDataResp> getDictDataList(Integer id) {
|
||||
List<DictType> dictTypeList = list(new LambdaQueryWrapper<>() {{
|
||||
eq(DictType::getAssetId, id);
|
||||
}});
|
||||
|
||||
List<DictDataResp> dictDataRespList = dictTypeList.stream().map(dictType -> {
|
||||
List<DictData> dictDataList = dictDataService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(DictData::getDictTypeId, dictType.getId());
|
||||
}});
|
||||
return dictType.toDataDictResp(dictDataList);
|
||||
}).toList();
|
||||
|
||||
return dictDataRespList;
|
||||
}
|
||||
/**
|
||||
* 根据对象查询字典数据列表
|
||||
*
|
||||
* @param dictTypeReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DictData> getDictData(DictTypeReq dictTypeReq) {
|
||||
DictType dictType = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(DictType::getAssetId, dictTypeReq.getAssetId());
|
||||
eq(DictType::getDictType, dictTypeReq.getDictType());
|
||||
}});
|
||||
List<DictData> dictData = dictDataService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(DictData::getDictTypeId, dictType.getId());
|
||||
}});
|
||||
return dictData;
|
||||
}
|
||||
}
|
|
@ -7,12 +7,12 @@ import com.muyu.source.service.TableDataService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:53
|
||||
* @ Version:1.0
|
||||
* @ Description:表结构业务实现层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Service
|
||||
public class TableDataServiceImpl extends ServiceImpl<TableDataMapper, TableData> implements TableDataService {
|
||||
|
|
|
@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.muyu.source.domain.TableData;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-21-19:53
|
||||
* @ Version:1.0
|
||||
* @ Description:表结构业务层
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface TableDataService extends IService<TableData> {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue