From be30e17e3c7685a54f761bf3a03487308c939270 Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期三, 05 三月 2025 18:05:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/BladeX-Tool/blade-starter-develop/src/main/java/org/springblade/develop/support/BladeTemplateEngine.java | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/Source/BladeX-Tool/blade-starter-develop/src/main/java/org/springblade/develop/support/BladeTemplateEngine.java b/Source/BladeX-Tool/blade-starter-develop/src/main/java/org/springblade/develop/support/BladeTemplateEngine.java
new file mode 100644
index 0000000..6477b60
--- /dev/null
+++ b/Source/BladeX-Tool/blade-starter-develop/src/main/java/org/springblade/develop/support/BladeTemplateEngine.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 搴勯獮 (smallchill@163.com)
+ */
+package org.springblade.develop.support;
+
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.baomidou.mybatisplus.generator.config.OutputFile;
+import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
+import com.baomidou.mybatisplus.generator.engine.BeetlTemplateEngine;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.utils.StringUtil;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 浠g爜妯$増鐢熸垚瀹炵幇绫�
+ *
+ * @author Chill
+ */
+@AllArgsConstructor
+public class BladeTemplateEngine extends BeetlTemplateEngine {
+
+ private String outputDir;
+ private String outputWebDir;
+
+ @Override
+ protected void outputCustomFile(List<CustomFile> customFiles, TableInfo tableInfo, Map<String, Object> objectMap) {
+ String packageName = String.valueOf(objectMap.get("packageName"));
+ String serviceCode = String.valueOf(objectMap.get("serviceCode"));
+ String modelCode = String.valueOf(objectMap.get("modelCode"));
+ String entityName = String.valueOf(objectMap.get("modelClass"));
+ String entityNameLower = entityName.toLowerCase();
+
+ customFiles.forEach(customFile -> {
+ String key = customFile.getFileName();
+ String value = customFile.getTemplatePath();
+ String outputPath = getPathInfo(OutputFile.parent);
+ objectMap.put("entityKey", entityNameLower);
+ if (StringUtil.equals(key, "menu.sql")) {
+ objectMap.put("menuId", IdWorker.getId());
+ objectMap.put("addMenuId", IdWorker.getId());
+ objectMap.put("editMenuId", IdWorker.getId());
+ objectMap.put("removeMenuId", IdWorker.getId());
+ objectMap.put("viewMenuId", IdWorker.getId());
+ outputPath = outputDir + StringPool.SLASH + "sql" + StringPool.SLASH + entityNameLower + ".menu.sql";
+ }
+ if (StringUtil.equals(key, "entityVO.java")) {
+ outputPath = outputDir + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "vo" + StringPool.SLASH + entityName + "VO" + StringPool.DOT_JAVA;
+ }
+
+ if (StringUtil.equals(key, "entityDTO.java")) {
+ outputPath = outputDir + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "dto" + StringPool.SLASH + entityName + "DTO" + StringPool.DOT_JAVA;
+ }
+
+ if (StringUtil.equals(key, "wrapper.java")) {
+ outputPath = outputDir + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "wrapper" + StringPool.SLASH + entityName + "Wrapper" + StringPool.DOT_JAVA;
+ }
+
+ if (StringUtil.equals(key, "feign.java")) {
+ outputPath = outputDir + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "feign" + StringPool.SLASH + "I" + entityName + "Client" + StringPool.DOT_JAVA;
+ }
+
+ if (StringUtil.equals(key, "feignclient.java")) {
+ outputPath = outputDir + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "feign" + StringPool.SLASH + entityName + "Client" + StringPool.DOT_JAVA;
+ }
+
+ if (StringUtil.equals(key, "action.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "actions" + StringPool.SLASH + entityNameLower + ".js";
+ }
+
+ if (StringUtil.equals(key, "model.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "models" + StringPool.SLASH + entityNameLower + ".js";
+ }
+
+ if (StringUtil.equals(key, "service.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "services" + StringPool.SLASH + entityNameLower + ".js";
+ }
+
+ if (StringUtil.equals(key, "list.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.firstCharToUpper(modelCode) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + ".js";
+ }
+
+ if (StringUtil.equals(key, "add.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.firstCharToUpper(modelCode) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "Add.js";
+ }
+
+ if (StringUtil.equals(key, "edit.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.firstCharToUpper(modelCode) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "Edit.js";
+ }
+
+ if (StringUtil.equals(key, "view.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.firstCharToUpper(modelCode) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "View.js";
+ }
+
+ if (StringUtil.equals(key, "api.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "api" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + ".js";
+ }
+
+ if (StringUtil.equals(key, "const.js")) {
+ outputPath = outputWebDir + StringPool.SLASH + "const" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + ".js";
+ }
+
+ if (StringUtil.equals(key, "crud.vue")) {
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + ".vue";
+ }
+
+ if (StringUtil.equals(key, "sub.vue")) {
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + "Sub.vue";
+ }
+
+ if (StringUtil.equals(key, "data.ts")) {
+ outputPath = outputWebDir + StringPool.SLASH + "api" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + ".ts";
+ }
+
+ if (StringUtil.equals(key, "data.data.ts")) {
+
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + StringPool.SLASH + modelCode + ".data.ts";
+ }
+
+ if (StringUtil.equals(key, "index.vue")) {
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + StringPool.SLASH + "index.vue";
+ }
+
+ if (StringUtil.equals(key, "Modal.vue")) {
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + StringPool.SLASH + entityName + "Modal.vue";
+ }
+
+ if (StringUtil.equals(key, "lemonSub.vue")) {
+ outputPath = outputWebDir + StringPool.SLASH + "views" + StringPool.SLASH + serviceCode + StringPool.SLASH + modelCode + StringPool.SLASH + entityName + "Sub.vue";
+ }
+ outputFile(new File(String.valueOf(outputPath)), objectMap, value, Boolean.TRUE);
+ });
+ }
+
+
+}
--
Gitblit v1.9.3