Search in sources :

Example 1 with AgileGeneratorTableInfo

use of com.jeeagile.generator.vo.AgileGeneratorTableInfo in project jeeagile by jeeagile.

the class AgileGeneratorTableServiceImpl method selectTableInfoById.

@Override
public AgileGeneratorTableInfo selectTableInfoById(String agileGeneratorTableId) {
    AgileGeneratorTableInfo agileGeneratorTableInfo = new AgileGeneratorTableInfo();
    AgileGeneratorTable agileGeneratorTable = this.getById(agileGeneratorTableId);
    BeanUtils.copyProperties(agileGeneratorTable, agileGeneratorTableInfo);
    if (agileGeneratorTable != null && !AgileStringUtil.isEmpty(agileGeneratorTable.getId())) {
        agileGeneratorTableInfo.setAgileGeneratorTableColumnList(agileGeneratorTableColumnService.selectListByTableId(agileGeneratorTableId));
    }
    return agileGeneratorTableInfo;
}
Also used : AgileGeneratorTableInfo(com.jeeagile.generator.vo.AgileGeneratorTableInfo) AgileGeneratorTable(com.jeeagile.generator.entity.AgileGeneratorTable)

Example 2 with AgileGeneratorTableInfo

use of com.jeeagile.generator.vo.AgileGeneratorTableInfo in project jeeagile by jeeagile.

the class AgileGeneratorTableServiceImpl method downloadCode.

@Override
public byte[] downloadCode(List<String> agileGeneratorTableIdList) {
    try {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
        for (String agileGeneratorTableId : agileGeneratorTableIdList) {
            AgileGeneratorTableInfo agileGeneratorTableInfo = this.selectTableInfoById(agileGeneratorTableId);
            if (agileGeneratorTableInfo != null && AgileStringUtil.isNotEmpty(agileGeneratorTableInfo.getId())) {
                AgileGeneratorUtil.generatorCode(agileGeneratorTableInfo, zipOutputStream);
            }
        }
        IOUtils.close(zipOutputStream);
        return outputStream.toByteArray();
    } catch (Exception ex) {
        throw new AgileFrameException("代码生成异常!");
    }
}
Also used : AgileGeneratorTableInfo(com.jeeagile.generator.vo.AgileGeneratorTableInfo) ZipOutputStream(java.util.zip.ZipOutputStream) AgileFrameException(com.jeeagile.core.exception.AgileFrameException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AgileValidateException(com.jeeagile.core.exception.AgileValidateException) AgileFrameException(com.jeeagile.core.exception.AgileFrameException)

Example 3 with AgileGeneratorTableInfo

use of com.jeeagile.generator.vo.AgileGeneratorTableInfo in project jeeagile by jeeagile.

the class AgileGeneratorTableServiceImpl method syncTableById.

@Override
public boolean syncTableById(String agileGeneratorTableId) {
    AgileGeneratorTableInfo tableInfo = this.selectTableInfoById(agileGeneratorTableId);
    if (tableInfo != null) {
        List<AgileGeneratorTableColumn> tableColumnList = tableInfo.getAgileGeneratorTableColumnList();
        List<String> tableColumnNameList = tableColumnList.stream().map(AgileGeneratorTableColumn::getColumnName).collect(Collectors.toList());
        List<AgileGeneratorTableColumn> dbTableColumnList = this.getBaseMapper().selectDbTableColumnByTableName(tableInfo.getTableName());
        List<String> dbTableColumnNameList = dbTableColumnList.stream().map(AgileGeneratorTableColumn::getColumnName).collect(Collectors.toList());
        for (AgileGeneratorTableColumn agileGeneratorTableColumn : dbTableColumnList) {
            if (!tableColumnNameList.contains(agileGeneratorTableColumn.getColumnName())) {
                AgileGeneratorUtil.initColumnField(tableInfo, agileGeneratorTableColumn);
                agileGeneratorTableColumnService.save(agileGeneratorTableColumn);
            }
        }
        List<String> deleteColumnIdList = tableColumnList.stream().filter(genTableColumn -> !dbTableColumnNameList.contains(genTableColumn.getColumnName())).map(AgileGeneratorTableColumn::getId).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(deleteColumnIdList)) {
            agileGeneratorTableColumnService.removeByIds(deleteColumnIdList);
        }
    } else {
        throw new AgileValidateException("表生成信息已不存在无法同步!");
    }
    return true;
}
Also used : AgileGeneratorTableInfo(com.jeeagile.generator.vo.AgileGeneratorTableInfo) AgileValidateException(com.jeeagile.core.exception.AgileValidateException) AgileGeneratorTableColumn(com.jeeagile.generator.entity.AgileGeneratorTableColumn)

Aggregations

AgileGeneratorTableInfo (com.jeeagile.generator.vo.AgileGeneratorTableInfo)3 AgileValidateException (com.jeeagile.core.exception.AgileValidateException)2 AgileFrameException (com.jeeagile.core.exception.AgileFrameException)1 AgileGeneratorTable (com.jeeagile.generator.entity.AgileGeneratorTable)1 AgileGeneratorTableColumn (com.jeeagile.generator.entity.AgileGeneratorTableColumn)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ZipOutputStream (java.util.zip.ZipOutputStream)1