初始代码
This commit is contained in:
21
yunzhupaas-visualdev/yunzhupaas-visualdev-generater/pom.xml
Normal file
21
yunzhupaas-visualdev/yunzhupaas-visualdev-generater/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-generater</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yunzhupaas-visualdev-generater-entity</module>
|
||||
<module>yunzhupaas-visualdev-generater-biz</module>
|
||||
<module>yunzhupaas-visualdev-generater-controller</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-generater</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-generater-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-generater-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-base-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-onlinedev-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.generater.service;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.model.DownloadCodeForm;
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
|
||||
/**
|
||||
* 可视化开发功能表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-04-02
|
||||
*/
|
||||
public interface VisualdevGenService extends SuperService<VisualdevEntity> {
|
||||
|
||||
/**
|
||||
* 代码生成v3
|
||||
*
|
||||
* @param visualdevEntity 可视化开发功能
|
||||
* @param downloadCodeForm 下载相关信息
|
||||
* @return 下载文件名
|
||||
* @throws Exception ignore
|
||||
*/
|
||||
String codeGengerateV3(VisualdevEntity visualdevEntity, DownloadCodeForm downloadCodeForm) throws Exception;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.yunzhupaas.generater.service.impl;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.mapper.VisualdevMapper;
|
||||
import com.yunzhupaas.base.model.DownloadCodeForm;
|
||||
import com.yunzhupaas.base.model.VisualWebTypeEnum;
|
||||
import com.yunzhupaas.base.service.DbLinkService;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.service.SysconfigService;
|
||||
import com.yunzhupaas.base.service.VisualAliasService;
|
||||
import com.yunzhupaas.base.util.VisualUtils;
|
||||
import com.yunzhupaas.base.util.common.AliasModel;
|
||||
import com.yunzhupaas.base.util.common.GenerateCommon;
|
||||
import com.yunzhupaas.base.util.common.GenerateParamModel;
|
||||
import com.yunzhupaas.base.util.custom.VelocityEnum;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.GenerateConstant;
|
||||
import com.yunzhupaas.database.model.entity.DbLinkEntity;
|
||||
import com.yunzhupaas.database.util.DataSourceUtil;
|
||||
import com.yunzhupaas.generater.factory.CodeGenerateFactoryV3;
|
||||
import com.yunzhupaas.generater.model.FormDesign.TemplateMethodEnum;
|
||||
import com.yunzhupaas.generater.service.VisualdevGenService;
|
||||
import com.yunzhupaas.model.FileListVO;
|
||||
import com.yunzhupaas.model.OnlineDevData;
|
||||
import com.yunzhupaas.model.visualJson.TableModel;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 可视化开发功能表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-04-02
|
||||
*/
|
||||
@Service
|
||||
public class VisualdevGenServiceImpl extends SuperServiceImpl<VisualdevMapper, VisualdevEntity> implements VisualdevGenService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private DataSourceUtil dataSourceUtil;
|
||||
@Autowired
|
||||
private DbLinkService dataSourceApi;
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
@Autowired
|
||||
private CodeGenerateFactoryV3 GenerateFactoryV3;
|
||||
|
||||
@Autowired
|
||||
private SysconfigService sysconfigService;
|
||||
|
||||
@Autowired
|
||||
private VisualAliasService aliasService;
|
||||
|
||||
/**
|
||||
* vue3代码生成
|
||||
*
|
||||
* @param entity 可视化开发功能
|
||||
* @param downloadCodeForm 下载相关信息
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String codeGengerateV3(VisualdevEntity entity, DownloadCodeForm downloadCodeForm) throws Exception {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
DbLinkEntity linkEntity = null;
|
||||
if (entity != null) {
|
||||
//初始化模板
|
||||
Velocity.reset();
|
||||
VelocityEnum.init.initVelocity(GenerateCommon.getLocalBasePath() + configValueUtil.getTemplateCodePathVue3());
|
||||
|
||||
//视图代码生成独立逻辑
|
||||
if(VisualWebTypeEnum.DATA_VIEW.getType().equals(entity.getWebType())){
|
||||
String fileName = entity.getFullName() + "_" + DateUtil.nowDateTime();
|
||||
String mainClass = "St" + entity.getEnCode();
|
||||
downloadCodeForm.setMainClassName(mainClass);
|
||||
System.out.print(GenerateCommon.getLocalBasePath());
|
||||
System.out.print(configValueUtil.getTemplateCodePathVue3());
|
||||
//执行代码生成器
|
||||
GenerateParamModel generateParamModel = new GenerateParamModel().builder()
|
||||
.path(GenerateCommon.getLocalBasePath() + configValueUtil.getTemplateCodePathVue3())
|
||||
.fileName(fileName)
|
||||
.downloadCodeForm(downloadCodeForm)
|
||||
.entity(entity)
|
||||
.userInfo(userInfo)
|
||||
.configValueUtil(configValueUtil)
|
||||
.className(mainClass)
|
||||
.templatesPath(TemplateMethodEnum.T6.getMethod())
|
||||
.template7Model(GenerateCommon.getTemplate7Model(sysconfigService.getList(GenerateConstant.SYSCONFIG)))
|
||||
.build();
|
||||
GenerateFactoryV3.runGenerator(TemplateMethodEnum.T6.getMethod(), generateParamModel);
|
||||
return fileName;
|
||||
}
|
||||
// 是否存在关联数据库
|
||||
if (StringUtil.isNotEmpty(entity.getDbLinkId())) {
|
||||
linkEntity = dataSourceApi.getInfo(entity.getDbLinkId());
|
||||
}
|
||||
// 是否存在关联表
|
||||
if (StringUtil.isNotEmpty(entity.getVisualTables())) {
|
||||
String fileName = entity.getFullName() + "_" + DateUtil.nowDateTime();
|
||||
|
||||
List<TableModel> list = JsonUtil.getJsonToList(entity.getVisualTables(), TableModel.class);
|
||||
Map<String, AliasModel> tableAliasMap = aliasService.getAllFiledsAlias(entity.getId());
|
||||
|
||||
//获取主表
|
||||
String mainTable = list.stream().filter(t -> "1".equals(t.getTypeId())).findFirst().orElse(null).getTable();
|
||||
Map<String, String> fieldsMap = tableAliasMap.get(mainTable).getFieldsMap();
|
||||
//获取主键
|
||||
String pKeyName = VisualUtils.getpKey(linkEntity, mainTable);
|
||||
|
||||
//自定义包名
|
||||
String modulePackageName = StringUtil.isNotEmpty(downloadCodeForm.getModulePackageName()) ? downloadCodeForm.getModulePackageName() :
|
||||
GenerateConstant.PACKAGE_NAME;
|
||||
downloadCodeForm.setModulePackageName(modulePackageName);
|
||||
downloadCodeForm.setMainClassName(tableAliasMap.get(mainTable).getAliasName());
|
||||
//获取其他子表的主键
|
||||
Map<String, Object> childpKeyMap = new HashMap<>(16);
|
||||
for (TableModel tableModel : list) {
|
||||
String childKey = VisualUtils.getpKey(linkEntity, tableModel.getTable());
|
||||
if (childKey.length() > 2) {
|
||||
if ("f_".equals(childKey.substring(0, 2).toLowerCase())) {
|
||||
childKey = childKey.substring(2);
|
||||
}
|
||||
}
|
||||
childpKeyMap.put(tableModel.getTable(), childKey);
|
||||
}
|
||||
|
||||
String templatesPath = null;
|
||||
//功能表单
|
||||
if (OnlineDevData.FORM_TYPE_DEV.equals(entity.getType())) {
|
||||
switch (entity.getWebType()) {
|
||||
case 1:
|
||||
templatesPath = downloadCodeForm.getEnableFlow() == 1 ? TemplateMethodEnum.T5.getMethod() : TemplateMethodEnum.T4.getMethod() ;
|
||||
break;
|
||||
case 2:
|
||||
templatesPath = downloadCodeForm.getEnableFlow() == 1 ? TemplateMethodEnum.T3.getMethod() : TemplateMethodEnum.T2.getMethod() ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//非本地模板需要下载-获取模板如下
|
||||
if (!FileUploadUtils.getDefaultPlatform().startsWith(GenerateConstant.LOCAL)) {
|
||||
List<FileListVO> fileList = new ArrayList<>();
|
||||
fileList.addAll(FileUploadUtils.getDefaultFileList(configValueUtil.getTemplateCodePathVue3()));
|
||||
String basePath = FileUploadUtils.getBasePath();
|
||||
for (FileListVO fileListVO : fileList) {
|
||||
String eachFileName = fileListVO.getFileName();
|
||||
int index = eachFileName.lastIndexOf("/");
|
||||
//服务器路径
|
||||
String floderName = eachFileName.substring(0, index + 1);
|
||||
if(StringUtil.isNotEmpty(basePath) && floderName.contains(basePath)){
|
||||
floderName = floderName.substring(basePath.length());
|
||||
}
|
||||
//本地路径
|
||||
String filePath = FileUploadUtils.getLocalBasePath() + floderName;
|
||||
//文件名
|
||||
String objectName = eachFileName.substring(index + 1);
|
||||
FileUploadUtils.downLocal(floderName, filePath, objectName);
|
||||
}
|
||||
}
|
||||
System.out.print(GenerateCommon.getLocalBasePath());
|
||||
System.out.print(configValueUtil.getTemplateCodePathVue3());
|
||||
//执行代码生成器
|
||||
GenerateParamModel generateParamModel = new GenerateParamModel().builder()
|
||||
.dataSourceUtil(dataSourceUtil)
|
||||
.path(GenerateCommon.getLocalBasePath() + configValueUtil.getTemplateCodePathVue3())
|
||||
.fileName(fileName)
|
||||
.templatesPath(templatesPath)
|
||||
.downloadCodeForm(downloadCodeForm)
|
||||
.entity(entity)
|
||||
.userInfo(userInfo)
|
||||
.configValueUtil(configValueUtil)
|
||||
.linkEntity(linkEntity)
|
||||
.pKeyNameOriginal(pKeyName)
|
||||
.pKeyName(fieldsMap.get(pKeyName))
|
||||
.template7Model(GenerateCommon.getTemplate7Model(sysconfigService.getList(GenerateConstant.SYSCONFIG)))
|
||||
.tableAliseMap(tableAliasMap)
|
||||
.build();
|
||||
GenerateFactoryV3.runGenerator(templatesPath, generateParamModel);
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-generater</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-generater-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-generater-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,294 @@
|
||||
package com.yunzhupaas.generater.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.entity.VisualdevReleaseEntity;
|
||||
import com.yunzhupaas.base.model.DownloadCodeForm;
|
||||
import com.yunzhupaas.base.model.VisualAliasForm;
|
||||
import com.yunzhupaas.base.model.read.ReadListVO;
|
||||
import com.yunzhupaas.base.model.read.ReadModel;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.VisualAliasService;
|
||||
import com.yunzhupaas.base.service.VisualdevReleaseService;
|
||||
import com.yunzhupaas.base.service.VisualdevService;
|
||||
import com.yunzhupaas.base.util.ReadFile;
|
||||
import com.yunzhupaas.base.util.VisualUtil;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.FileTypeConstant;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.generater.service.VisualdevGenService;
|
||||
import com.yunzhupaas.model.visualJson.TableModel;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 可视化开发功能表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024/3/16
|
||||
*/
|
||||
@Tag(name = "代码生成器", description = "Generater")
|
||||
@RestController
|
||||
@RequestMapping("/api/visualdev/Generater")
|
||||
public class VisualdevGenController {
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private VisualdevService visualdevService;
|
||||
@Autowired
|
||||
private VisualdevReleaseService visualdevReleaseService;
|
||||
@Autowired
|
||||
private VisualdevGenService visualdevGenService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private VisualAliasService aliasService;
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@NoDataSourceBind()
|
||||
@Operation(summary = "下载文件")
|
||||
@GetMapping("/DownloadVisCode")
|
||||
public void downloadCode() throws DataException {
|
||||
HttpServletRequest request = ServletUtil.getRequest();
|
||||
String reqJson = request.getParameter("encryption");
|
||||
String name = request.getParameter("name");
|
||||
String fileNameAll = DesUtil.aesDecode(reqJson);
|
||||
if (!StringUtil.isEmpty(fileNameAll)) {
|
||||
String token = fileNameAll.split("#")[0];
|
||||
if (TicketUtil.parseTicket(token) != null) {
|
||||
TicketUtil.deleteTicket(token);
|
||||
String fileName = fileNameAll.split("#")[1];
|
||||
String path = FilePathUtil.getFilePath(FileTypeConstant.CODETEMP);
|
||||
//下载到本地
|
||||
byte[] bytes = FileUploadUtils.downloadFileByte(path, fileName, false);
|
||||
FileDownloadUtil.downloadFile(bytes, fileName, name);
|
||||
//删除打包的临时文件,释放存储
|
||||
FileUploadUtils.deleteFileByPathAndFileName(path, fileName);
|
||||
} else {
|
||||
throw new DataException(MsgCode.VS014.get());
|
||||
}
|
||||
} else {
|
||||
throw new DataException(MsgCode.VS014.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取命名空间")
|
||||
@GetMapping("/AreasName")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult getAreasName() {
|
||||
String areasName = configValueUtil.getCodeAreasName();
|
||||
List<String> areasNameList = new ArrayList(Arrays.asList(areasName.split(",")));
|
||||
return ActionResult.success(areasNameList);
|
||||
}
|
||||
|
||||
@Operation(summary = "下载代码")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@PostMapping("/{id}/Actions/DownloadCode")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
@DSTransactional
|
||||
public ActionResult downloadCode(@PathVariable("id") String id, @RequestBody DownloadCodeForm downloadCodeForm) throws Exception {
|
||||
if (downloadCodeForm.getModule() != null) {
|
||||
DictionaryDataEntity info = dictionaryDataApi.getInfo(downloadCodeForm.getModule());
|
||||
if (info != null) {
|
||||
downloadCodeForm.setModule(info.getEnCode());
|
||||
}
|
||||
}
|
||||
VisualdevEntity visualdevEntity = JsonUtil.getJsonToBean(visualdevReleaseService.getById(id), VisualdevEntity.class);
|
||||
String s = VisualUtil.checkPublishVisualModel(visualdevEntity, MsgCode.VS006.get());
|
||||
if (s != null) {
|
||||
return ActionResult.fail(s);
|
||||
}
|
||||
DownloadVO vo;
|
||||
String fileName = visualdevGenService.codeGengerateV3(visualdevEntity, downloadCodeForm);
|
||||
|
||||
//服务器生成路径
|
||||
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + fileName + ".zip";
|
||||
FileUtil.toZip(filePath, true, FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + fileName);
|
||||
// 删除源文件
|
||||
FileUtil.deleteFileAll(new File(FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + fileName));
|
||||
|
||||
//上传压缩包到服务器
|
||||
MultipartFile multipartFile = FileUtil.createFileItem(new File(XSSEscape.escapePath(filePath)));
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, configValueUtil.getServiceDirectoryPath(), fileName + ".zip");
|
||||
// 删除压缩包
|
||||
FileUtil.deleteFileAll(new File(filePath));
|
||||
//下载文件服务器上的压缩包
|
||||
vo = DownloadVO.builder().name(fileInfo.getFilename()).url(UploaderUtil.uploaderVisualFile(fileInfo.getFilename()) + "&name=" + fileName + ".zip").build();
|
||||
if (vo == null) {
|
||||
return ActionResult.fail(MsgCode.FA006.get());
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输出移动开发模板
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "预览代码")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@PostMapping("/{id}/Actions/CodePreview")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult codePreview(@PathVariable("id") String id, @RequestBody DownloadCodeForm downloadCodeForm) throws Exception {
|
||||
if (downloadCodeForm.getModule() != null) {
|
||||
DictionaryDataEntity info = dictionaryDataApi.getInfo(downloadCodeForm.getModule());
|
||||
if (info != null) {
|
||||
downloadCodeForm.setModule(info.getEnCode());
|
||||
}
|
||||
}
|
||||
VisualdevReleaseEntity releaseEntity = visualdevReleaseService.getById(id);
|
||||
VisualdevEntity visualdevEntity = JsonUtil.getJsonToBean(releaseEntity, VisualdevEntity.class);
|
||||
String s = VisualUtil.checkPublishVisualModel(visualdevEntity, "预览");
|
||||
if (s != null) {
|
||||
return ActionResult.fail(s);
|
||||
}
|
||||
String fileName = visualdevGenService.codeGengerateV3(visualdevEntity, downloadCodeForm);
|
||||
|
||||
List<ReadListVO> dataList = ReadFile.priviewCode(FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + fileName);
|
||||
// 删除源文件
|
||||
FileUtil.deleteFileAll(new File(FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + fileName));
|
||||
if (dataList.size() == 0) {
|
||||
return ActionResult.fail(MsgCode.FA015.get());
|
||||
}
|
||||
|
||||
//代码对比
|
||||
if (downloadCodeForm.isContrast()) {
|
||||
VisualdevEntity oldEntity = visualdevService.getInfo(id);
|
||||
//修改状态 - 旧的是已发布,新的是草稿版本;发布状态 - 旧的是 旧的发布版本,新的是当前发布版本;
|
||||
boolean statusUpdate = true;
|
||||
if (Objects.equals(oldEntity.getState(), 1) && StringUtil.isNotBlank(releaseEntity.getOldContent())) {
|
||||
statusUpdate = false;
|
||||
VisualdevEntity jsonToBean = JsonUtil.getJsonToBean(releaseEntity.getOldContent(), VisualdevEntity.class);
|
||||
oldEntity.setVisualTables(jsonToBean.getVisualTables());
|
||||
oldEntity.setFormData(jsonToBean.getFormData());
|
||||
oldEntity.setColumnData(jsonToBean.getColumnData());
|
||||
oldEntity.setAppColumnData(jsonToBean.getAppColumnData());
|
||||
oldEntity.setWebType(jsonToBean.getWebType());
|
||||
oldEntity.setDbLinkId(jsonToBean.getDbLinkId());
|
||||
}
|
||||
|
||||
String oldFileName = visualdevGenService.codeGengerateV3(oldEntity, downloadCodeForm);
|
||||
List<ReadListVO> oldDataList = ReadFile.priviewCode(FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + oldFileName);
|
||||
// 删除源文件
|
||||
FileUtil.deleteFileAll(new File(FileUploadUtils.getLocalBasePath() + configValueUtil.getServiceDirectoryPath() + oldFileName));
|
||||
|
||||
for (ReadListVO m : dataList) {
|
||||
ReadListVO n = oldDataList.stream().filter(t -> m.getFileName().equals(t.getFileName())).findFirst().orElse(null);
|
||||
if (Objects.nonNull(n)) {
|
||||
List<ReadModel> mChildren = m.getChildren();
|
||||
List<ReadModel> nChildren = n.getChildren();
|
||||
for (ReadModel mChild : mChildren) {
|
||||
ReadModel nChild = nChildren.stream().filter(t -> mChild.getFileName().equals(t.getFileName())).findFirst().orElse(null);
|
||||
String nfileContent = Objects.nonNull(nChild) ? nChild.getFileContent() : "";
|
||||
if (statusUpdate) {
|
||||
mChild.setOldFileContent(mChild.getFileContent());
|
||||
mChild.setFileContent(nfileContent);
|
||||
} else {
|
||||
mChild.setOldFileContent(nfileContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListVO datas = new ListVO<>();
|
||||
datas.setList(dataList);
|
||||
return ActionResult.success(datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* App预览(后台APP表单设计)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "App预览(后台APP表单设计)")
|
||||
@Parameters({
|
||||
@Parameter(name = "data", description = "数据"),
|
||||
})
|
||||
@PostMapping("/App/Preview")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult appPreview(String data) {
|
||||
String id = RandomUtil.uuId();
|
||||
redisUtil.insert(id, data, 300);
|
||||
return ActionResult.success((Object) id);
|
||||
}
|
||||
|
||||
/**
|
||||
* App预览(后台APP表单设计)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "App预览查看")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@GetMapping("/App/{id}/Preview")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult preview(@PathVariable("id") String id) {
|
||||
if (redisUtil.exists(id)) {
|
||||
Object object = redisUtil.getString(id);
|
||||
return ActionResult.success(object);
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA019.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取命名规范")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@GetMapping("/{id}/Alias/Info")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult getAliasInfo(@PathVariable("id") String id) {
|
||||
List<TableModel> aliasInfo = aliasService.getAliasInfo(id);
|
||||
return ActionResult.success(aliasInfo);
|
||||
}
|
||||
|
||||
@Operation(summary = "命名规范保存")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@PostMapping("/{id}/Alias/Save")
|
||||
@SaCheckPermission(value = {"onlineDev.webDesign", "generator.webForm", "generator.flowForm"}, mode = SaMode.OR)
|
||||
public ActionResult aliasSave(@PathVariable("id") String id, @RequestBody VisualAliasForm form) {
|
||||
aliasService.aliasSave(id, form);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-generater</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-generater-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-all</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2022/7/5
|
||||
*/
|
||||
@Data
|
||||
public class ColumnChildListModel {
|
||||
private String label;
|
||||
private String tableField;
|
||||
private String vModel;
|
||||
private List<ColumnListModel> fields;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
|
||||
import com.yunzhupaas.model.visualJson.FieLdsModel;
|
||||
import com.yunzhupaas.model.visualJson.analysis.FormMastTableModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列表字段
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
@Data
|
||||
public class ColumnListDataModel {
|
||||
/**
|
||||
* model别名
|
||||
*/
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 外键
|
||||
*/
|
||||
private String relationField;
|
||||
|
||||
/**
|
||||
* 外键首字母大写
|
||||
*/
|
||||
private String relationUpField;
|
||||
|
||||
/**
|
||||
* 关联主键
|
||||
*/
|
||||
private String mainKey;
|
||||
|
||||
/**
|
||||
* 关联主键首字母大写
|
||||
*/
|
||||
private String mainUpKey;
|
||||
|
||||
/**
|
||||
* 所拥有字段
|
||||
*/
|
||||
private List<String> fieldList;
|
||||
|
||||
/**
|
||||
* 控件属性
|
||||
*/
|
||||
private List<FormMastTableModel> fieLdsModelList;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 首字母小写
|
||||
*/
|
||||
private String modelLowName;
|
||||
|
||||
/**
|
||||
* 首字母大写
|
||||
*/
|
||||
private String modelUpName;
|
||||
|
||||
/**
|
||||
* 当前表主键
|
||||
*/
|
||||
private String mainField;
|
||||
|
||||
/**
|
||||
* 对应控件(去除yunzhupaas)
|
||||
*/
|
||||
private List<FieLdsModel> fieLdsModels;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
|
||||
import com.yunzhupaas.model.visualJson.FieLdsModel;
|
||||
import com.yunzhupaas.model.visualJson.config.ConfigModel;
|
||||
import com.yunzhupaas.model.visualJson.options.ColumnOptionModel;
|
||||
import com.yunzhupaas.model.visualJson.props.PropsModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024/8/17
|
||||
*/
|
||||
@Data
|
||||
public class ColumnListModel extends FieLdsModel {
|
||||
|
||||
private boolean first = false;
|
||||
|
||||
/**
|
||||
* 字段
|
||||
*/
|
||||
private String prop;
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* 对齐
|
||||
*/
|
||||
private String align;
|
||||
|
||||
private String yunzhupaasKey;
|
||||
|
||||
private String dataType;
|
||||
|
||||
private String vModel;
|
||||
|
||||
private Boolean sortable;
|
||||
|
||||
/**
|
||||
* 列表子表表名
|
||||
*/
|
||||
private String columnTableName;
|
||||
|
||||
/**
|
||||
* 处理后的prop
|
||||
*/
|
||||
private String newProp;
|
||||
|
||||
private Boolean multiple;
|
||||
|
||||
private ConfigModel config;
|
||||
private String placeholder;
|
||||
private Object style;
|
||||
private Boolean clearable;
|
||||
private String prefixIcon;
|
||||
private Integer precision;
|
||||
private String suffixIcon;
|
||||
private String maxlength;
|
||||
private Boolean showWordLimit;
|
||||
private Boolean readonly;
|
||||
private Boolean disabled;
|
||||
/**
|
||||
* 关联表单id
|
||||
*/
|
||||
private String modelId="";
|
||||
/**
|
||||
* 关联表单 二维码 条形码 字段
|
||||
*/
|
||||
private String relationField;
|
||||
private Boolean hasPage;
|
||||
private String pageSize;
|
||||
private String type;
|
||||
private Object autosize;
|
||||
private Integer step;
|
||||
private Boolean stepstrictly;
|
||||
private String controls;
|
||||
private Object textStyle;
|
||||
private Integer lineHeight;
|
||||
private Integer fontSize;
|
||||
private Boolean showChinese;
|
||||
private Boolean showPassword;
|
||||
|
||||
/**
|
||||
* 大小
|
||||
*/
|
||||
private String size;
|
||||
private Boolean filterable;
|
||||
/**
|
||||
* 冻结
|
||||
*/
|
||||
private String fixed = "none";
|
||||
/**
|
||||
* 关联表单属性
|
||||
*/
|
||||
private String showField;
|
||||
/**
|
||||
* 待定
|
||||
*/
|
||||
private PropsModel props;
|
||||
/**
|
||||
* 待定
|
||||
*/
|
||||
private Boolean showAllLevels;
|
||||
private String separator;
|
||||
private Boolean isrange;
|
||||
private String rangeseparator;
|
||||
private String startplaceholder;
|
||||
private String endplaceholder;
|
||||
private String format;
|
||||
private String valueformat;
|
||||
private Object pickeroptions;
|
||||
private Integer max;
|
||||
private Integer count;
|
||||
private Boolean allowhalf;
|
||||
private Boolean showText;
|
||||
private Boolean showScore;
|
||||
private Boolean showAlpha;
|
||||
private String colorformat;
|
||||
private String activetext;
|
||||
private String inactivetext;
|
||||
private String activecolor;
|
||||
private String inactivecolor;
|
||||
private String activeValue;
|
||||
private String inactiveValue;
|
||||
private Integer min;
|
||||
private Boolean showStops;
|
||||
private Boolean range;
|
||||
private String content;
|
||||
private String header;
|
||||
private Boolean accordion;
|
||||
private String tabPosition;
|
||||
/**
|
||||
* 未找到
|
||||
*/
|
||||
private String accept;
|
||||
private Boolean showTip;
|
||||
private Integer fileSize;
|
||||
private String sizeUnit;
|
||||
private Integer limit;
|
||||
private String contentposition;
|
||||
private String buttonText;
|
||||
private Integer level;
|
||||
private String options;
|
||||
private String actionText;
|
||||
private String shadow;
|
||||
private String name;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 查询方式 1.eq 2.like 3.between
|
||||
*/
|
||||
private Integer searchType;
|
||||
private String interfaceId;
|
||||
private List<ColumnOptionModel> columnOptions;
|
||||
private String propsValue;
|
||||
|
||||
/**
|
||||
* 开关 值
|
||||
*/
|
||||
private String activeTxt = "开";
|
||||
private String inactiveTxt = "关";
|
||||
|
||||
/**
|
||||
* 条形码 条码颜色
|
||||
*/
|
||||
private String lineColor;
|
||||
/**
|
||||
* 条形码 背景色
|
||||
*/
|
||||
private String background;
|
||||
/**
|
||||
* 条形码 宽高
|
||||
*/
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
/**
|
||||
* 条形码 二维码 固定值
|
||||
*/
|
||||
private String staticText;
|
||||
|
||||
|
||||
/**
|
||||
* 二维码 条码颜色
|
||||
*/
|
||||
private String colorDark;
|
||||
|
||||
/**
|
||||
* 二维码 背景色
|
||||
*/
|
||||
private String colorLight;
|
||||
|
||||
/**
|
||||
* 子表是否合计
|
||||
*/
|
||||
private Boolean showSummary;
|
||||
|
||||
/**
|
||||
* 子表合计字段
|
||||
*/
|
||||
private String summaryField;
|
||||
|
||||
/**
|
||||
* 所属部门展示内容
|
||||
*/
|
||||
private String showLevel;
|
||||
|
||||
/**
|
||||
* 弹窗 样式属性
|
||||
*/
|
||||
private String popupType;
|
||||
private String popupTitle;
|
||||
private String popupWidth;
|
||||
|
||||
private String selectType;
|
||||
|
||||
//自定义
|
||||
private String ableIds;
|
||||
private String ableDepIds;
|
||||
private String ablePosIds;
|
||||
private String ableUserIds;
|
||||
private String ableRoleIds;
|
||||
private String ableGroupIds;
|
||||
|
||||
private ColumnChildListModel columnChildListModel;
|
||||
|
||||
//数字输入-金额大小写等属性
|
||||
private String addonAfter;
|
||||
private String addonBefore;
|
||||
private Boolean isAmountChinese;
|
||||
private Boolean thousands;
|
||||
|
||||
//时间控件新增字段
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String startRelationField;
|
||||
private String endRelationField;
|
||||
|
||||
//单选多选样式
|
||||
private String direction;
|
||||
private String optionType;
|
||||
//单选样式风格
|
||||
private String buttonStyle;
|
||||
/**
|
||||
* 下拉补全展示条数
|
||||
*/
|
||||
private Integer total;
|
||||
private String id;
|
||||
|
||||
private Boolean useScan = false;
|
||||
private Boolean useMask = false;
|
||||
private Object maskConfig;
|
||||
|
||||
/**
|
||||
* 定位地图属性
|
||||
*/
|
||||
private boolean autoLocation = false;
|
||||
private boolean enableLocationScope = false;
|
||||
private int adjustmentScope;
|
||||
private boolean enableDesktopLocation = false;
|
||||
private List<Object> locationScope;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2021/10/22
|
||||
*/
|
||||
@Data
|
||||
public class ListSearchGroupModel {
|
||||
/**
|
||||
* 模型名
|
||||
*/
|
||||
private String modelName;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
/**
|
||||
* 外键
|
||||
*/
|
||||
private String ForeignKey;
|
||||
/**
|
||||
* 关联主键
|
||||
*/
|
||||
private String mainKey;
|
||||
|
||||
/**
|
||||
* 该表下的查询字段
|
||||
*/
|
||||
private List<SearchTypeModel> searchTypeModelList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
|
||||
import com.yunzhupaas.model.visualJson.config.ConfigModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 代码生成器查询条件
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2021/8/9
|
||||
*/
|
||||
@Data
|
||||
public class SearchTypeModel {
|
||||
private String vModel;
|
||||
private String dataType;
|
||||
private Integer searchType;
|
||||
private String label;
|
||||
private String yunzhupaasKey;
|
||||
private String format;
|
||||
private String multiple;
|
||||
/**
|
||||
* 搜索框显示
|
||||
*/
|
||||
private String placeholder;
|
||||
private ConfigModel config;
|
||||
|
||||
private String TableName;
|
||||
//表别名
|
||||
private String tableAliasName;
|
||||
//字段别名
|
||||
private String afterVModel;
|
||||
|
||||
private String showLevel;
|
||||
|
||||
//新增 拼接之后的vmodel和label
|
||||
/**
|
||||
* vmodel 子表副表拼接后得名称
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* label 子表副表拼接后得名称
|
||||
*/
|
||||
private String fullName;
|
||||
/**
|
||||
* 查询是否多选
|
||||
*/
|
||||
private String searchMultiple;
|
||||
/**
|
||||
* 是否关键词
|
||||
*/
|
||||
private Boolean isKeyword;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.generater.model.FormDesign;
|
||||
|
||||
/**
|
||||
* 模板路径
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024/10/8
|
||||
*/
|
||||
public enum TemplateMethodEnum {
|
||||
T1("TemplateCode1"),
|
||||
T2("TemplateCode2"),
|
||||
T3("TemplateCode3"),
|
||||
T4("TemplateCode4"),
|
||||
T5("TemplateCode5"),
|
||||
T6("TemplateCode6");
|
||||
|
||||
TemplateMethodEnum(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
private String method;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user