办学质量监测教学评价系统
ageer
2025-03-31 412e8bdc105595889231417143b411ada3c761bc
ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/service/GenTableServiceImpl.java
@@ -49,7 +49,7 @@
 *
 * @author Lion Li
 */
@DS("#header.datasource")
//@DS("#header.datasource")
@Slf4j
@RequiredArgsConstructor
@Service
@@ -228,17 +228,29 @@
        return dataMap;
    }
    @Override
    public byte[] downloadCode(Long tableId) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ZipOutputStream zip = new ZipOutputStream(outputStream);
        generatorCode(tableId, zip);
        IoUtil.close(zip);
        return outputStream.toByteArray();
    }
    /**
     * 生成代码(下载方式)
     *
     * @param tableName 表名称
     * @param tableIds 表名称
     * @return 数据
     */
    @Override
    public byte[] downloadCode(String tableName) {
    public byte[] downloadCode(String[] tableIds) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ZipOutputStream zip = new ZipOutputStream(outputStream);
        generatorCode(tableName, zip);
        for (String tableId : tableIds) {
            generatorCode(Long.parseLong(tableId), zip);
        }
        IoUtil.close(zip);
        return outputStream.toByteArray();
    }
@@ -327,28 +339,14 @@
    }
    /**
     * 批量生成代码(下载方式)
     *
     * @param tableNames 表数组
     * @return 数据
     * 查询表信息并生成代码
     */
    @Override
    public byte[] downloadCode(String[] tableNames) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ZipOutputStream zip = new ZipOutputStream(outputStream);
        for (String tableName : tableNames) {
            generatorCode(tableName, zip);
        }
        IoUtil.close(zip);
        return outputStream.toByteArray();
    }
    /**
     * 查询表信息并生成代码
     */
    private void generatorCode(String tableName, ZipOutputStream zip) {
    private void generatorCode(Long tableId, ZipOutputStream zip) {
        // 查询表信息
        GenTable table = baseMapper.selectGenTableByName(tableName);
        GenTable table = baseMapper.selectGenTableById(tableId);
        List<Long> menuIds = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            menuIds.add(identifierGenerator.nextId(null).longValue());