Search in sources :

Example 1 with TableFormDataVo

use of com.albedo.java.modules.gen.domain.vo.TableFormDataVo in project albedo by somowhere.

the class TableServiceImpl method findFormData.

@Override
public TableFormDataVo findFormData(TableFromDto tableFromDto) {
    // 验证参数缺失
    ArgumentAssert.isTrue(tableFromDto == null || StringUtil.isNotEmpty(tableFromDto.getId()) || StringUtil.isNotEmpty(tableFromDto.getTableName()) || StringUtil.isNotEmpty(tableFromDto.getDsName()), "参数缺失!");
    TableFormDataVo tableFormDataVo = new TableFormDataVo();
    TableDto tableDto = new TableDto(tableFromDto);
    tableFormDataVo.setTableList(CollUtil.convertSelectVoList(findTableListFormDb(tableDto), TableDo.F_NAME, TableDo.F_NAMESANDTITLE));
    // 验证表是否存在
    ArgumentAssert.isTrue(StringUtil.isNotEmpty(tableFromDto.getId()) || checkTableName(tableFromDto.getTableName()), StringUtil.toAppendStr("下一步失败!", tableFromDto.getTableName(), " 表已经添加!"));
    if (ObjectUtil.isNotEmpty(tableFromDto.getId())) {
        tableDto = getOneDto(tableFromDto.getId());
        tableDto.setColumnList(tableColumnService.list(Wrappers.<TableColumnDo>query().eq(TableColumnDo.F_SQL_GENTABLEID, tableFromDto.getId())).stream().map(item -> tableColumnService.copyBeanToDto(item)).collect(Collectors.toList()));
    }
    // 获取物理表字段
    tableDto = getTableFormDb(tableDto);
    tableFormDataVo.setColumnList(CollUtil.convertSelectVoList(tableDto.getColumnList(), TableDo.F_NAME, TableDo.F_NAMESANDTITLE));
    tableFormDataVo.setTableVo(tableDto);
    GenConfig config = GenUtil.getConfig();
    tableFormDataVo.setConfig(config);
    tableFormDataVo.setDsNameList(CollUtil.convertSelectVoList(datasourceConfService.list(), DatasourceConfDo.F_NAME, DatasourceConfDo.F_NAME));
    tableFormDataVo.setQueryTypeList(CollUtil.convertSelectVoList(config.getQueryTypeList(), DictDo.F_VAL, DictDo.F_NAME));
    tableFormDataVo.setQueryTypeList(CollUtil.convertSelectVoList(config.getQueryTypeList(), DictDo.F_VAL, DictDo.F_NAME));
    tableFormDataVo.setShowTypeList(CollUtil.convertSelectVoList(config.getShowTypeList(), DictDo.F_VAL, DictDo.F_NAME));
    tableFormDataVo.setJavaTypeList(CollUtil.convertSelectVoList(config.getJavaTypeList(), DictDo.F_VAL, DictDo.F_NAME));
    if (ObjectUtil.isNotEmpty(tableDto.getId())) {
        Collections.sort(tableDto.getColumnList());
    }
    return tableFormDataVo;
}
Also used : GenConfig(com.albedo.java.modules.gen.domain.xml.GenConfig) TableFormDataVo(com.albedo.java.modules.gen.domain.vo.TableFormDataVo) TableColumnDo(com.albedo.java.modules.gen.domain.TableColumnDo) TableDto(com.albedo.java.modules.gen.domain.dto.TableDto)

Aggregations

TableColumnDo (com.albedo.java.modules.gen.domain.TableColumnDo)1 TableDto (com.albedo.java.modules.gen.domain.dto.TableDto)1 TableFormDataVo (com.albedo.java.modules.gen.domain.vo.TableFormDataVo)1 GenConfig (com.albedo.java.modules.gen.domain.xml.GenConfig)1