代码生成器-获取数据表
This commit is contained in:
parent
efb984ae49
commit
97dc15dead
|
|
@ -3,6 +3,7 @@ package com.hxkj.admin.controller;
|
|||
import com.hxkj.admin.service.IGenerateService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -20,10 +21,18 @@ public class GenerateController {
|
|||
@Resource
|
||||
IGenerateService iGenerateService;
|
||||
|
||||
/**
|
||||
* 数据表列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/db")
|
||||
public Object db(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
List<Map<String, String>> list = iGenerateService.db(pageParam, params);
|
||||
PageResult<Map<String, String>> list = iGenerateService.db(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -10,6 +11,14 @@ import java.util.Map;
|
|||
*/
|
||||
public interface IGenerateService {
|
||||
|
||||
List<Map<String, String>> db(PageParam pageParam, Map<String, String> params);
|
||||
/**
|
||||
* 数据表列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<Map<String, String>>
|
||||
*/
|
||||
PageResult<Map<String, String>> db(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,19 +10,30 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 代码生成器服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class GenerateServiceImpl implements IGenerateService {
|
||||
|
||||
@Resource
|
||||
GenTableMapper genTableMapper;
|
||||
|
||||
/**
|
||||
* 数据表列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<Map<String, String>>
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, String>> db(PageParam pageParam, Map<String, String> params) {
|
||||
public PageResult<Map<String, String>> db(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Map<String, String>> tables = genTableMapper.selectDbTableList();
|
||||
List<Map<String, String>> tables = genTableMapper.selectDbTableList(params);
|
||||
|
||||
List<Map<String, String>> list = new LinkedList<>();
|
||||
for (Map<String, String> item : tables) {
|
||||
|
|
@ -33,8 +44,8 @@ public class GenerateServiceImpl implements IGenerateService {
|
|||
map.put("updateTime", item.getOrDefault("update_time", ""));
|
||||
list.add(map);
|
||||
}
|
||||
System.out.println(PageResult.pageHelper(tables));
|
||||
return list;
|
||||
|
||||
return PageResult.pageHelper(tables, list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,26 @@ import java.util.Map;
|
|||
@Mapper
|
||||
public interface GenTableMapper extends IBaseMapper<GenTable> {
|
||||
|
||||
@Select(
|
||||
/**
|
||||
* 查询库中的数据表
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return List<Map<String, String>>
|
||||
*/
|
||||
@Select({"<script>",
|
||||
"SELECT table_name, table_comment, create_time, update_time " +
|
||||
"FROM information_schema.tables " +
|
||||
"WHERE table_schema = (SELECT database()) " +
|
||||
"AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' " +
|
||||
"AND table_name NOT IN (select table_name from ls_gen_table)"
|
||||
)
|
||||
List<Map<String, String>> selectDbTableList();
|
||||
"AND table_name NOT IN (select table_name from ls_gen_table)",
|
||||
"<if test=\"tableName != null and tableName != ''\">" +
|
||||
"AND lower(table_name) like lower(concat('%', #{tableName}, '%'))" +
|
||||
"</if>",
|
||||
"<if test=\"tableComment != null and tableComment != ''\">" +
|
||||
"AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))" +
|
||||
"</if>",
|
||||
"</script>"})
|
||||
List<Map<String, String>> selectDbTableList(Map<String, String> params);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue