指标库:查询所有表信息
This commit is contained in:
parent
ca2546b524
commit
60e022ff32
@ -0,0 +1,36 @@
|
||||
package iet.ustb.sf.controller;
|
||||
|
||||
import iet.ustb.sf.common.R;
|
||||
import iet.ustb.sf.service.TableColumnService;
|
||||
import iet.ustb.sf.vo.TableVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库表列配置
|
||||
* TableColumnController
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/8/6 15:44:56
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tableColumn")
|
||||
@Tag(name = "数据库表列配置")
|
||||
public class TableColumnController {
|
||||
|
||||
@Resource
|
||||
private TableColumnService tableColumnService;
|
||||
|
||||
@Operation(summary = "查询所有表信息")
|
||||
@PostMapping("/getTablesInfo")
|
||||
public R<List<TableVo>> getTablesInfo() {
|
||||
List<TableVo> result = tableColumnService.getTablesInfo();
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
@ -2,46 +2,21 @@ package iet.ustb.sf.mapper;
|
||||
|
||||
import iet.ustb.sf.domain.TableColumn;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import iet.ustb.sf.vo.TableVo;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【mbgk_table_column】的数据库操作Mapper
|
||||
* @createDate 2025-08-05 12:33:36
|
||||
* @Entity iet.ustb.sf.domain.TableColumn
|
||||
*/
|
||||
* @author hyy
|
||||
* @description 针对表【mbgk_table_column】的数据库操作Mapper
|
||||
* @createDate 2025-08-05 12:33:36
|
||||
* @Entity iet.ustb.sf.domain.TableColumn
|
||||
*/
|
||||
public interface TableColumnMapper extends BaseMapper<TableColumn> {
|
||||
|
||||
@Select("SELECT DISTINCT c.table_name AS \"tableName\", " +
|
||||
" c.column_name AS \"columnName\", " +
|
||||
" c.data_type AS \"colnumnType\", " +
|
||||
" cc.comments AS \"columnNameCn\", " +
|
||||
" t.comments AS \"tableNameCn\", " +
|
||||
" t.owner AS \"schema\", " +
|
||||
" CASE " +
|
||||
" WHEN kcu.column_name IS NOT NULL THEN '1' " +
|
||||
" ELSE '0' " +
|
||||
" END AS \"isPrimary\" " +
|
||||
"FROM all_tab_columns c " +
|
||||
" JOIN all_tab_comments t " +
|
||||
" ON c.table_name = t.table_name " +
|
||||
" AND c.owner = t.owner " +
|
||||
" LEFT JOIN all_col_comments cc " +
|
||||
" ON c.table_name = cc.table_name " +
|
||||
" AND c.column_name = cc.column_name " +
|
||||
" AND c.owner = cc.owner " +
|
||||
" LEFT JOIN all_cons_columns kcu " +
|
||||
" ON c.table_name = kcu.table_name " +
|
||||
" AND c.column_name = kcu.column_name " +
|
||||
" AND c.owner = kcu.owner " +
|
||||
" LEFT JOIN all_constraints ku " +
|
||||
" ON kcu.constraint_name = ku.constraint_name " +
|
||||
" AND ku.constraint_type = 'P' " +
|
||||
"WHERE c.table_name = ?1")
|
||||
List<Map<String,?>> getOriColumnByTableName(String tableName);
|
||||
@Select("select distinct table_name,table_name_cn,`schema` from mbgk_table_column where is_delete=0")
|
||||
List<TableVo> getTablesInfo();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,9 @@ package iet.ustb.sf.service;
|
||||
|
||||
import iet.ustb.sf.domain.TableColumn;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import iet.ustb.sf.vo.TableVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
@ -13,4 +16,6 @@ public interface TableColumnService extends IService<TableColumn> {
|
||||
String syncTableData(String tableName);
|
||||
|
||||
String syncTableDataByDb(String dbName);
|
||||
|
||||
List<TableVo> getTablesInfo();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import iet.ustb.sf.mapper.TablesMapper;
|
||||
import iet.ustb.sf.service.TableColumnService;
|
||||
import iet.ustb.sf.mapper.TableColumnMapper;
|
||||
import iet.ustb.sf.util.CheckUtils;
|
||||
import iet.ustb.sf.vo.TableVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -106,6 +107,11 @@ public class TableColumnServiceImpl extends ServiceImpl<TableColumnMapper, Table
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableVo> getTablesInfo() {
|
||||
return tableColumnMapper.getTablesInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
25
src/main/java/iet/ustb/sf/vo/TableVo.java
Normal file
25
src/main/java/iet/ustb/sf/vo/TableVo.java
Normal file
@ -0,0 +1,25 @@
|
||||
package iet.ustb.sf.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* TableVo
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/3/27 17:36:56
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableVo {
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String tableNameCn;
|
||||
|
||||
private String schema;
|
||||
}
|
Loading…
Reference in New Issue
Block a user