编写了数据字典的增删改
parent
64dec29ad1
commit
d771ab6505
|
@ -24,7 +24,6 @@ import java.util.HashMap;
|
|||
public class DataSourceConfig {
|
||||
//数据源连接池
|
||||
private static HashMap<Long, DruidDataSource> dataSourceMap = new HashMap<>();
|
||||
|
||||
//数据源连接池
|
||||
public static void init(DataSource source, DataType dataType) {
|
||||
//创建连接池
|
||||
|
|
|
@ -21,7 +21,7 @@ import lombok.experimental.SuperBuilder;
|
|||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("asset_accredit")
|
||||
@TableName(value = "asset_accredit", autoResultMap = true)
|
||||
public class AssetAccredit {
|
||||
/**
|
||||
* 主键
|
||||
|
@ -35,7 +35,7 @@ public class AssetAccredit {
|
|||
@Excel(name = "授权编号")
|
||||
private String accreditNo;
|
||||
/**
|
||||
* 数据源id
|
||||
* 授权数据
|
||||
*/
|
||||
private Long dataId;
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
|
@ -20,6 +21,7 @@ import lombok.NoArgsConstructor;
|
|||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
|
|
@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
|
@ -20,6 +21,7 @@ import lombok.NoArgsConstructor;
|
|||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.req.DataSourceQueryReq;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -37,18 +38,21 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "主键")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 接入源名称
|
||||
*/
|
||||
@Excel(name = "接入源名称")
|
||||
@TableField("name")
|
||||
|
||||
private String name;
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
@Excel(name = "数据来源系统名称")
|
||||
@TableField("system_name")
|
||||
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
|
@ -56,6 +60,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "数据库类型")
|
||||
@TableField("data_type")
|
||||
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
|
@ -63,6 +68,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "ip地址")
|
||||
@TableField("ip")
|
||||
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
|
@ -70,6 +76,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "端口号")
|
||||
@TableField("port")
|
||||
|
||||
private String port;
|
||||
|
||||
/**
|
||||
|
@ -77,6 +84,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "数据库名称")
|
||||
@TableField("database_name")
|
||||
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
|
@ -84,6 +92,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "用户名")
|
||||
@TableField("user_name")
|
||||
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
|
@ -91,6 +100,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "密码")
|
||||
@TableField("password")
|
||||
|
||||
private String password;
|
||||
|
||||
/**
|
||||
|
@ -98,6 +108,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "数据连接参数")
|
||||
@TableField("connection_param")
|
||||
|
||||
private String connectionParam;
|
||||
|
||||
/**
|
||||
|
@ -105,6 +116,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "是否初始化")
|
||||
@TableField("is_init")
|
||||
|
||||
private String isInit;
|
||||
|
||||
/**
|
||||
|
@ -112,6 +124,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "初始连接数量")
|
||||
@TableField("init_total")
|
||||
|
||||
private Long initNum;
|
||||
|
||||
/**
|
||||
|
@ -119,6 +132,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "最大连接数量")
|
||||
@TableField("max_num")
|
||||
|
||||
private Long maxNum;
|
||||
|
||||
/**
|
||||
|
@ -126,6 +140,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "最大等待时间")
|
||||
@TableField("max_wait_time")
|
||||
|
||||
private Long maxWaitTime;
|
||||
|
||||
/**
|
||||
|
@ -133,6 +148,7 @@ public class DataSource extends BaseEntity {
|
|||
*/
|
||||
@Excel(name = "最大等待次数")
|
||||
@TableField("max_wait_size")
|
||||
|
||||
private Long maxWaitSize;
|
||||
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ import lombok.experimental.SuperBuilder;
|
|||
* @ Description:数据库类型
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName("data_type")
|
||||
@TableName(value ="data_type", autoResultMap = true)
|
||||
public class DataType {
|
||||
/**
|
||||
* 主键
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-16:20
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "dict_data", autoResultMap = true)
|
||||
public class DictData {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Excel(name = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Excel(name = "字典标签")
|
||||
private String dictLabel;
|
||||
/**
|
||||
* 字典键值
|
||||
*/
|
||||
@Excel(name = "字典键值")
|
||||
private String dictValue;
|
||||
/**
|
||||
* 字典类型ID
|
||||
*/
|
||||
@Excel(name = "字典类型ID")
|
||||
private Long dictTypeId;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.muyu.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-16:22
|
||||
* @ Version:1.0
|
||||
* @ Description:字典类型
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "dict_type", autoResultMap = true)
|
||||
public class DictType extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Excel(name = "主键")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Excel(name = "字典名称")
|
||||
private String dictName;
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
/**
|
||||
* 数据源ID
|
||||
*/
|
||||
@Excel(name = "数据源ID")
|
||||
private Integer assetId;
|
||||
}
|
|
@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
|
@ -19,6 +20,7 @@ import lombok.NoArgsConstructor;
|
|||
* @ Description:表结构
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.source.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -27,84 +28,84 @@ public class DataSourceEditReq extends BaseEntity {
|
|||
/**
|
||||
* 接入源名称
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "接入源名称",description = "接入源名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "数据来源系统",description = "数据来源系统")
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "mysql等",description = "要选择的数据库类型")
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "ip地址",description = "ip地址,要连接的mysql的ip")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "3306",description = "端口号")
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "t_user",description = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "root",description = "用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "root",description = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 数据连接参数
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "useUnicode=true&characterEncoding=utf8",description = "数据连接参数")
|
||||
private String connectionParam;
|
||||
|
||||
/**
|
||||
* 是否初始化
|
||||
*/
|
||||
|
||||
@Schema(type = "String",defaultValue = "Y",description = "是否初始化 状态 'Y'/'N'")
|
||||
private String isInit;
|
||||
|
||||
/**
|
||||
* 初始连接数量
|
||||
*/
|
||||
|
||||
@Schema(type = "Long",defaultValue = "5",description = "初始化连接数量")
|
||||
private Long initTotal;
|
||||
|
||||
/**
|
||||
* 最大连接数量
|
||||
*/
|
||||
|
||||
@Schema(type = "Long",defaultValue = "10",description = "最大连接数量")
|
||||
private Long maxNum;
|
||||
|
||||
/**
|
||||
* 最大等待时间
|
||||
*/
|
||||
|
||||
@Schema(type = "Long",defaultValue = "10",description = "最大等待时间")
|
||||
private Long maxWaitTime;
|
||||
|
||||
/**
|
||||
* 最大等待次数
|
||||
*/
|
||||
|
||||
@Schema(type = "Long",defaultValue = "3",description = "最大等待次数")
|
||||
private Long maxWaitSize;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.source.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -29,11 +30,13 @@ public class DataSourceQueryReq extends BaseEntity {
|
|||
/**
|
||||
* 接入源名称
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "接入源名称",description = "接入源名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据来源系统名称
|
||||
*/
|
||||
@Schema(type = "String",defaultValue = "数据来源系统",description = "数据来源系统")
|
||||
private String systemName;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.Children;
|
||||
import com.muyu.source.service.ChildrenService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -18,10 +21,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
* @ Description:数据库结构控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/children")
|
||||
@Tag(name = "数据库结构控制层",description = "进行数据库结构管理,查看等相关操作")
|
||||
public class ChildrenController {
|
||||
public ChildrenController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ChildrenService childrenService;
|
||||
|
@ -31,6 +38,7 @@ public class ChildrenController {
|
|||
* @return 数据库结构
|
||||
*/
|
||||
@GetMapping("/selectChildren/{id}")
|
||||
@Operation(summary = "查询数据库结构",description = "可以根据数据源的ID查询数据库结构")
|
||||
public Result<Children> selectChildren(@PathVariable("id") Integer id){
|
||||
Children children = childrenService.getById(id);
|
||||
return Result.success(children);
|
||||
|
@ -42,6 +50,7 @@ public class ChildrenController {
|
|||
* @return 资产数据模型数量
|
||||
*/
|
||||
@GetMapping("/getTableDataCount/{id}")
|
||||
@Operation(summary = "查询单个数据库中表的数量",description = "可以根据数据源的ID查询单个数据库中表的数量")
|
||||
public Result getTableDataCount(@PathVariable("id") Integer id){
|
||||
//TODO 统计资产模型的总数量
|
||||
return null;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.source.domain.DataSource;
|
||||
import com.muyu.source.domain.req.DataSourceQueryReq;
|
||||
import com.muyu.source.service.DataSourceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
@ -28,6 +30,9 @@ import java.util.List;
|
|||
@RequestMapping("/dataSource")
|
||||
@Tag(name = "数据源控制层",description = "进行数据源管理,查看等相关操作")
|
||||
public class DataSourceController extends BaseController {
|
||||
public DataSourceController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源业务层
|
||||
|
@ -35,15 +40,6 @@ public class DataSourceController extends BaseController {
|
|||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
/**
|
||||
* 查询数据源的全部数据
|
||||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("/getDataSourceList")
|
||||
public Result<List<DataSource>> list(){
|
||||
List<DataSource> list =dataSourceService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取数据
|
||||
|
@ -51,6 +47,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("getDataSourceById/{id}")
|
||||
@Operation(summary = "根据ID获取数据",description = "根据ID获取数据")
|
||||
public Result<DataSource> getDataSourceById(@PathVariable("id") Long id){
|
||||
DataSource dataSource = dataSourceService.getById(id);
|
||||
return Result.success(dataSource);
|
||||
|
@ -62,6 +59,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询数据源列表的全部数据",description = "根据数据源的接入名称,来源系统名称可以进行数据源的筛选")
|
||||
public Result<List<DataSource>> list(DataSourceQueryReq dataSourceQueryReq){
|
||||
List<DataSource> list =dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
return Result.success(list);
|
||||
|
@ -73,6 +71,7 @@ public class DataSourceController extends BaseController {
|
|||
* @param response response
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
@Operation(summary = "导出数据源",description = "导出数据源为Excel的格式")
|
||||
public void derive(DataSource dataSource,HttpServletResponse response){
|
||||
List<DataSource> list = dataSourceService.list(dataSource);
|
||||
ExcelUtil<DataSource> excelUtil = new ExcelUtil<>(DataSource.class);
|
||||
|
@ -85,6 +84,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源详细信息
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获取数据源详细信息",description = "根据ID获取数据源详细信息")
|
||||
public Result<DataSource> getById(@PathVariable("id") Long id){
|
||||
return Result.success(dataSourceService.getById(id));
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/selectTableDataCount")
|
||||
@Operation(summary = "查询接入的数据库的总数",description = "查询接入的数据库的总数")
|
||||
public Result selectTableDataCount() {
|
||||
//TODO 统计出数据接入的数量
|
||||
return null;
|
||||
|
@ -106,6 +107,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源
|
||||
*/
|
||||
@PostMapping("/insert")
|
||||
@Operation(summary = "数据源的添加",description = "数据源的添加")
|
||||
public Result insert(@RequestBody DataSource dataSource){
|
||||
dataSourceService.save(dataSource);
|
||||
return Result.success();
|
||||
|
@ -117,6 +119,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "数据源的修改",description = "数据源的修改")
|
||||
public Result update(@RequestBody DataSource dataSource){
|
||||
dataSourceService.updateById(dataSource);
|
||||
return Result.success();
|
||||
|
@ -128,6 +131,7 @@ public class DataSourceController extends BaseController {
|
|||
* @return 数据源
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "数据源的删除",description = "可以根据数据源的ID删除/批量删除")
|
||||
public Result delete(@PathVariable("id") List<Long> id){
|
||||
dataSourceService.removeBatchByIds(id);
|
||||
return Result.success();
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import com.muyu.source.service.DictDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:10
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典控制层
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/dict_data")
|
||||
@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 = "添加字典数据")
|
||||
public Result addDictData(@RequestBody DictData dictData) {
|
||||
dictDataService.save(dictData);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @param dictData 数据字典
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PostMapping("editDictData")
|
||||
@Operation(summary = "修改字典数据",description = "修改字典数据")
|
||||
public Result editDictData(@RequestBody DictData dictData) {
|
||||
dictDataService.updateById(dictData);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @param id 数据字典ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@GetMapping("/delDictData/{id}")
|
||||
@Operation(summary = "删除字典数据",description = "根据ID删除字典数据")
|
||||
public Result delDictData(@PathVariable("id") Long id) {
|
||||
dictDataService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package com.muyu.source.controller;
|
||||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.domain.TableData;
|
||||
import com.muyu.source.service.TableDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -18,10 +21,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
* @ Description:表结构控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/tableData")
|
||||
@Tag(name = "表结构控制层",description = "进行表结构管理,查看等相关操作")
|
||||
public class TableDataController {
|
||||
public TableDataController() {
|
||||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private TableDataService tableDataService;
|
||||
|
||||
|
@ -31,6 +39,7 @@ public class TableDataController {
|
|||
* @return 表结构
|
||||
*/
|
||||
@GetMapping("/selectTableData/{id}")
|
||||
@Operation(summary = "根据id查询表结构",description = "可以根据根据id查询表结构")
|
||||
public Result<TableData> selectTableData(@PathVariable("id") Integer id){
|
||||
return Result.success(tableDataService.getById(id));
|
||||
}
|
||||
|
@ -41,6 +50,7 @@ public class TableDataController {
|
|||
* @return 数量
|
||||
*/
|
||||
@GetMapping("/selectTableDataCount/{id}")
|
||||
@Operation(summary = "统计出一个表中字段的数量",description = "可以根据表的ID统计单个表中中表的数量")
|
||||
public Result selectTableDataCount(@PathVariable("id") Integer id){
|
||||
//TODO 统计出数据模型的数量
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.source.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:13
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典持久层
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictDataMapper extends BaseMapper<DictData> {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.domain.DictData;
|
||||
|
||||
/**
|
||||
* @ 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,20 @@
|
|||
package com.muyu.source.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.source.domain.DictData;
|
||||
import com.muyu.source.mapper.DictDataMapper;
|
||||
import com.muyu.source.service.DictDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-08-22-17:15
|
||||
* @ Version:1.0
|
||||
* @ Description:数据字典业务实现层
|
||||
*/
|
||||
@Service
|
||||
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements DictDataService {
|
||||
|
||||
}
|
Loading…
Reference in New Issue