添加方法查询所有表

master
面包骑士 2024-08-27 20:19:35 +08:00
parent 5f0be34298
commit aa9fd1e5f0
6 changed files with 69 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableColumn;
import com.muyu.gen.domain.GenTableResp;
import com.muyu.gen.service.IGenTableColumnService;
import com.muyu.gen.service.IGenTableService;
import jakarta.servlet.http.HttpServletResponse;
@ -216,6 +217,13 @@ public class GenController extends BaseController
return Result.success(genTableService.selDbNameAll());
}
/**
* ,
*/
@GetMapping("/db/listAll")
public Result<List<GenTableResp>> genListAll() {
return success(genTableService.selectDbTableListAll());
}
/**
*

View File

@ -0,0 +1,43 @@
package com.muyu.gen.domain;
import com.muyu.common.core.constant.GenConstants;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.web.domain.BaseEntity;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.ArrayUtils;
import java.util.List;
/**
* gen_table
*
* @author muyu
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class GenTableResp extends BaseEntity {
private String dbName;
/**
*
*/
private String tableName;
/**
*
*/
private String tableComment;
}

View File

@ -1,6 +1,7 @@
package com.muyu.gen.mapper;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableResp;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -85,4 +86,6 @@ public interface GenTableMapper
public int deleteGenTableByIds(@Param("ids") Long[] ids);
List<String> selDbNameAll();
List<GenTableResp> selectDbTableListAll();
}

View File

@ -10,6 +10,7 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableColumn;
import com.muyu.gen.domain.GenTableResp;
import com.muyu.gen.mapper.GenTableColumnMapper;
import com.muyu.gen.mapper.GenTableMapper;
import com.muyu.gen.util.GenUtils;
@ -437,6 +438,10 @@ public class GenTableServiceImpl implements IGenTableService
return genTableMapper.selDbNameAll();
}
@Override
public List<GenTableResp> selectDbTableListAll() {
return genTableMapper.selectDbTableListAll();
}
/**

View File

@ -1,6 +1,7 @@
package com.muyu.gen.service;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableResp;
import java.util.List;
import java.util.Map;
@ -123,4 +124,6 @@ public interface IGenTableService
public void validateEdit(GenTable genTable);
List<String> selDbNameAll();
List<GenTableResp> selectDbTableListAll();
}

View File

@ -155,6 +155,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selFilterableByDbNameAndTableName" resultType="java.lang.String">
</select>
<select id="selectDbTableListAll" resultType="com.muyu.gen.domain.GenTableResp">
select table_name,table_comment,table_schema from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
and table_schema in (select table_schema from information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
GROUP BY table_schema)
</select>
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
insert into gen_table (