column : columns) {
+ ColumnEntity columnEntity = new ColumnEntity();
+ columnEntity.setComments(column.get("columnComment"));
+ columnEntity.setLowerAttrName(StringUtils.uncapitalize(GenUtils.columnToJava(column.get("columnName"))));
+ columnList.add(columnEntity);
+ }
+ context.put("columns", columnList);
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+ return StrUtil.trim(StrUtil.removePrefix(writer.toString(), GenUtils.CRUD_PREFIX));
+ }
+
+}
diff --git a/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java
new file mode 100644
index 000000000..72e94731f
--- /dev/null
+++ b/pigx-visual/pigx-code/src/main/java/com/pig4cloud/pigx/code/service/impl/GeneratorServiceImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.code.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.pig4cloud.pigx.code.entity.GenConfig;
+import com.pig4cloud.pigx.code.entity.GenFormConf;
+import com.pig4cloud.pigx.code.mapper.GenFormConfMapper;
+import com.pig4cloud.pigx.code.mapper.GeneratorMapper;
+import com.pig4cloud.pigx.code.service.GeneratorService;
+import com.pig4cloud.pigx.code.util.GenUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.io.ByteArrayOutputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * @author lengleng
+ * @date 2018-07-30
+ *
+ * 代码生成器
+ */
+@Service
+@AllArgsConstructor
+public class GeneratorServiceImpl implements GeneratorService {
+ private final GeneratorMapper generatorMapper;
+ private final GenFormConfMapper genFormConfMapper;
+
+ /**
+ * 分页查询表
+ *
+ * @param tableName 查询条件
+ * @return
+ */
+ @DS("#session.dataSourceName")
+ @Override
+ public IPage>> getPage(Page page, String tableName) {
+ return generatorMapper.queryList(page, tableName);
+ }
+
+ /**
+ * 生成代码
+ *
+ * @param genConfig 生成配置
+ * @return
+ */
+ @DS("#session.dataSourceName")
+ @Override
+ public byte[] generatorCode(GenConfig genConfig) {
+ //根据tableName 查询最新的表单配置
+ List formConfList = genFormConfMapper.selectList(Wrappers.lambdaQuery()
+ .eq(GenFormConf::getTableName, genConfig.getTableName())
+ .orderByDesc(GenFormConf::getCreateTime));
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ ZipOutputStream zip = new ZipOutputStream(outputStream);
+
+ String tableNames = genConfig.getTableName();
+ for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) {
+ //查询表信息
+ Map table = queryTable(tableName);
+ //查询列信息
+ List