查询所有表信息
This commit is contained in:
parent
1d3ca38052
commit
5b1c4d9202
6
pom.xml
6
pom.xml
@ -118,6 +118,12 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.29</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
40
src/main/java/com/huangge1199/controller/BiController.java
Normal file
40
src/main/java/com/huangge1199/controller/BiController.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.huangge1199.controller;
|
||||
|
||||
import com.huangge1199.base.R;
|
||||
import com.huangge1199.service.IBiTableColumnService;
|
||||
import com.huangge1199.vo.TableVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BiController
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/27 17:38:52
|
||||
*/
|
||||
@Api("数据库表操作")
|
||||
@RestController
|
||||
@RequestMapping("/db")
|
||||
public class BiController {
|
||||
|
||||
@Resource
|
||||
private IBiTableColumnService biTableColumnService;
|
||||
|
||||
@ApiOperation("查询所有表信息")
|
||||
@PostMapping("/getTablesInfo")
|
||||
public R<List<TableVo>> getTablesInfo() {
|
||||
List<TableVo> result;
|
||||
try {
|
||||
result = biTableColumnService.getTablesInfo();
|
||||
} catch (Exception e) {
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
20
src/main/java/com/huangge1199/dao/BiTableColumnDao.java
Normal file
20
src/main/java/com/huangge1199/dao/BiTableColumnDao.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.huangge1199.dao;
|
||||
|
||||
import com.huangge1199.domain.BiTableColumn;
|
||||
import com.huangge1199.vo.TableVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BiTableColumnDao
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/28 8:41:46
|
||||
*/
|
||||
public interface BiTableColumnDao extends JpaRepository<BiTableColumn, Integer> {
|
||||
|
||||
@Query("SELECT DISTINCT NEW com.huangge1199.vo.TableVo(tableName, tableNameCn, schema) FROM BiTableColumn")
|
||||
List<TableVo> getTablesInfo();
|
||||
}
|
63
src/main/java/com/huangge1199/domain/BiTableColumn.java
Normal file
63
src/main/java/com/huangge1199/domain/BiTableColumn.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.huangge1199.domain;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table(name = "MBGK_TABLE_COLUMN")
|
||||
public class BiTableColumn {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private String id;
|
||||
|
||||
@Column(name = "TABLE_NAME")
|
||||
private String tableName;
|
||||
|
||||
@Column(name = "TABLE_NAME_CN")
|
||||
private String tableNameCn;
|
||||
|
||||
@Column(name = "COLUMN_NAME")
|
||||
private String columnName;
|
||||
|
||||
@Column(name = "COLUMN_NAME_CN")
|
||||
private String columnNameCn;
|
||||
|
||||
@Column(name = "COLNUMN_TYPE")
|
||||
private String colnumnType;
|
||||
|
||||
@Column(name = "SCHEMA")
|
||||
private String schema;
|
||||
|
||||
@Column(name = "DATA_SOURCE")
|
||||
private String dataSource;
|
||||
|
||||
@Column(name = "IS_DELETE")
|
||||
private String isDelete;
|
||||
|
||||
@Column(name = "IS_PRIMARY")
|
||||
private String isPrimary;
|
||||
|
||||
@Column(name = "CREATE_TIME")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@Column(name = "UPDATE_TIME")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
@Column(name = "OP")
|
||||
private String op;
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.huangge1199.service;
|
||||
|
||||
import com.huangge1199.domain.BiTableColumn;
|
||||
import com.huangge1199.vo.TableVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IBiTableColumnService
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/28 8:37:06
|
||||
*/
|
||||
public interface IBiTableColumnService {
|
||||
List<TableVo> getTablesInfo();
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.huangge1199.service.impl;
|
||||
|
||||
import com.huangge1199.dao.BiTableColumnDao;
|
||||
import com.huangge1199.domain.BiTableColumn;
|
||||
import com.huangge1199.service.IBiTableColumnService;
|
||||
import com.huangge1199.vo.TableVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BiTableColumnServiceImpl
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/28 8:38:07
|
||||
*/
|
||||
@Service
|
||||
public class BiTableColumnServiceImpl implements IBiTableColumnService {
|
||||
|
||||
@Resource
|
||||
private BiTableColumnDao biTableColumnDao;
|
||||
|
||||
@Override
|
||||
public List<TableVo> getTablesInfo() {
|
||||
List<TableVo> list = biTableColumnDao.getTablesInfo();
|
||||
return list;
|
||||
}
|
||||
}
|
25
src/main/java/com/huangge1199/vo/TableVo.java
Normal file
25
src/main/java/com/huangge1199/vo/TableVo.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.huangge1199.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* TableVo
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/27 17:36:56
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableVo {
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String tableNameCn;
|
||||
|
||||
private String schema;
|
||||
}
|
Loading…
Reference in New Issue
Block a user