diff --git a/mall-member/member-boot/src/main/java/com/youlai/mall/member/MemberApplication.java b/mall-member/member-boot/src/main/java/com/youlai/mall/member/MemberApplication.java
index a96cd510f..c4c323892 100644
--- a/mall-member/member-boot/src/main/java/com/youlai/mall/member/MemberApplication.java
+++ b/mall-member/member-boot/src/main/java/com/youlai/mall/member/MemberApplication.java
@@ -13,7 +13,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
* @since 0.0.1
*/
@SpringBootApplication
-@EnableDiscoveryClient()
+@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = {SkuFeignClient.class})
public class MemberApplication {
public static void main(String[] args) {
diff --git a/youlai-codegen/pom.xml b/youlai-codegen/pom.xml
index 8ee374a70..23ddbfc20 100644
--- a/youlai-codegen/pom.xml
+++ b/youlai-codegen/pom.xml
@@ -72,6 +72,11 @@
velocity-engine-core
+
+ com.youlai
+ system-api
+
+
\ No newline at end of file
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/CodegenApplication.java b/youlai-codegen/src/main/java/com/youlai/codegen/CodegenApplication.java
index 5fc367f95..af28332f0 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/CodegenApplication.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/CodegenApplication.java
@@ -1,15 +1,20 @@
package com.youlai.codegen;
+import com.youlai.system.api.MenuFeignClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
/**
- * 系统服务启动类
+ * 代码生成器启动类
*
* @author Ray
- * @since 0.0.1
+ * @since 4.0.0
*/
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients(basePackageClasses = {MenuFeignClient.class})
public class CodegenApplication {
public static void main(String[] args) {
SpringApplication.run(CodegenApplication.class, args);
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/controller/CodegenController.java b/youlai-codegen/src/main/java/com/youlai/codegen/controller/CodegenController.java
index ac0303487..a765af6a6 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/controller/CodegenController.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/controller/CodegenController.java
@@ -7,7 +7,7 @@ import com.youlai.common.result.Result;
import com.youlai.codegen.config.CodegenProperties;
import com.youlai.codegen.model.form.GenConfigForm;
import com.youlai.codegen.model.query.TablePageQuery;
-import com.youlai.codegen.model.vo.CodePreviewVO;
+import com.youlai.codegen.model.vo.CodegenPreviewVO;
import com.youlai.codegen.model.vo.TablePageVO;
import com.youlai.codegen.service.GenConfigService;
import com.youlai.codegen.service.CodegenService;
@@ -91,14 +91,14 @@ public class CodegenController {
@Operation(summary = "获取预览生成代码")
@GetMapping("/{tableName}/preview")
- public Result> getCodePreviewData(@PathVariable String tableName) {
- List list = codegenService.getCodePreviewData(tableName);
+ public Result> getCodePreviewData(@PathVariable String tableName) {
+ List list = codegenService.getCodePreviewData(tableName);
return Result.success(list);
}
@Operation(summary = "下载代码")
@GetMapping("/{tableName}/download")
- public void downloadZip(HttpServletResponse response, @PathVariable String tableName) throws IOException {
+ public void downloadZip(HttpServletResponse response, @PathVariable String tableName) {
String[] tableNames = tableName.split(",");
byte[] data = codegenService.downloadCode(tableNames);
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/converter/CodegenConverter.java b/youlai-codegen/src/main/java/com/youlai/codegen/converter/CodegenConverter.java
index f65a9f1f8..73f356736 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/converter/CodegenConverter.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/converter/CodegenConverter.java
@@ -3,6 +3,7 @@ package com.youlai.codegen.converter;
import com.youlai.codegen.model.entity.GenConfig;
import com.youlai.codegen.model.entity.GenFieldConfig;
import com.youlai.codegen.model.form.GenConfigForm;
+import com.youlai.system.dto.CodegenMenuDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@@ -36,4 +37,8 @@ public interface CodegenConverter {
GenFieldConfig toGenFieldConfig(GenConfigForm.FieldConfig fieldConfig);
+
+ @Mapping(source = "parentMenuId", target = "parentMenuId")
+ CodegenMenuDTO toCodegenMenuDTO(Long parentMenuId, GenConfig genConfig);
+
}
\ No newline at end of file
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodePreviewVO.java b/youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodegenPreviewVO.java
similarity index 93%
rename from youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodePreviewVO.java
rename to youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodegenPreviewVO.java
index 52489d8b1..2aa611168 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodePreviewVO.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/model/vo/CodegenPreviewVO.java
@@ -5,7 +5,7 @@ import lombok.Data;
@Schema(description = "代码生成代码预览VO")
@Data
-public class CodePreviewVO {
+public class CodegenPreviewVO {
@Schema(description = "生成文件路径")
private String path;
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/service/CodegenService.java b/youlai-codegen/src/main/java/com/youlai/codegen/service/CodegenService.java
index 9deb2bfe9..902f205c2 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/service/CodegenService.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/service/CodegenService.java
@@ -2,7 +2,7 @@ package com.youlai.codegen.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.codegen.model.query.TablePageQuery;
-import com.youlai.codegen.model.vo.CodePreviewVO;
+import com.youlai.codegen.model.vo.CodegenPreviewVO;
import com.youlai.codegen.model.vo.TablePageVO;
import java.util.List;
@@ -29,7 +29,7 @@ public interface CodegenService {
* @param tableName 表名
* @return 包含代码预览信息的列表
*/
- List getCodePreviewData(String tableName);
+ List getCodePreviewData(String tableName);
/**
* 下载代码
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/service/GenConfigService.java b/youlai-codegen/src/main/java/com/youlai/codegen/service/GenConfigService.java
index 1ac50f32a..846c6c013 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/service/GenConfigService.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/service/GenConfigService.java
@@ -12,7 +12,6 @@ import com.youlai.codegen.model.form.GenConfigForm;
*/
public interface GenConfigService extends IService {
-
/**
* 获取代码生成配置
*
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/CodegenServiceImpl.java b/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/CodegenServiceImpl.java
index 7177b9b46..bbc8ad5f6 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/CodegenServiceImpl.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/CodegenServiceImpl.java
@@ -17,7 +17,7 @@ import com.youlai.codegen.enums.JavaTypeEnum;
import com.youlai.codegen.model.entity.GenConfig;
import com.youlai.codegen.model.entity.GenFieldConfig;
import com.youlai.codegen.model.query.TablePageQuery;
-import com.youlai.codegen.model.vo.CodePreviewVO;
+import com.youlai.codegen.model.vo.CodegenPreviewVO;
import com.youlai.codegen.model.vo.TablePageVO;
import com.youlai.codegen.service.DatabaseService;
import com.youlai.codegen.service.GenConfigService;
@@ -93,9 +93,9 @@ public class CodegenServiceImpl implements CodegenService {
* @return 预览数据
*/
@Override
- public List getCodePreviewData(String tableName) {
+ public List getCodePreviewData(String tableName) {
- List list = new ArrayList<>();
+ List list = new ArrayList<>();
GenConfig genConfig = genConfigService.getOne(new LambdaQueryWrapper()
.eq(GenConfig::getTableName, tableName)
@@ -116,7 +116,7 @@ public class CodegenServiceImpl implements CodegenService {
// 遍历模板配置
Map templateConfigs = codegenProperties.getTemplateConfigs();
for (Map.Entry templateConfigEntry : templateConfigs.entrySet()) {
- CodePreviewVO previewVO = new CodePreviewVO();
+ CodegenPreviewVO previewVO = new CodegenPreviewVO();
CodegenProperties.TemplateConfig templateConfig = templateConfigEntry.getValue();
@@ -308,9 +308,9 @@ public class CodegenServiceImpl implements CodegenService {
* @param zip 压缩文件输出流
*/
private void generateAndZipCode(String tableName, ZipOutputStream zip) {
- List codePreviewList = getCodePreviewData(tableName);
+ List codePreviewList = getCodePreviewData(tableName);
- for (CodePreviewVO codePreview : codePreviewList) {
+ for (CodegenPreviewVO codePreview : codePreviewList) {
String fileName = codePreview.getFileName();
String content = codePreview.getContent();
String path = codePreview.getPath();
diff --git a/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/GenConfigServiceImpl.java b/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/GenConfigServiceImpl.java
index dc126f1c6..88a7ef5f2 100644
--- a/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/GenConfigServiceImpl.java
+++ b/youlai-codegen/src/main/java/com/youlai/codegen/service/impl/GenConfigServiceImpl.java
@@ -21,6 +21,8 @@ import com.youlai.codegen.model.entity.GenFieldConfig;
import com.youlai.codegen.model.form.GenConfigForm;
import com.youlai.codegen.service.GenConfigService;
import com.youlai.codegen.service.GenFieldConfigService;
+import com.youlai.system.api.MenuFeignClient;
+import com.youlai.system.dto.CodegenMenuDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -41,7 +43,7 @@ public class GenConfigServiceImpl extends ServiceImpl genFieldConfigs = codegenConverter.toGenFieldConfig(formData.getFieldConfigs());
diff --git a/youlai-codegen/src/main/resources/bootstrap.yml b/youlai-codegen/src/main/resources/bootstrap.yml
index 4f53553fb..704100b7b 100644
--- a/youlai-codegen/src/main/resources/bootstrap.yml
+++ b/youlai-codegen/src/main/resources/bootstrap.yml
@@ -3,12 +3,12 @@ server:
spring:
application:
- name: youlai-generator
+ name: youlai-codegen
profiles:
active: dev
# 代码生成器配置
-generator:
+codegen:
# 下载代码文件名称
downloadFileName: youlai-mall-code.zip
# 后端项目名称
diff --git a/youlai-common/common-base/src/main/java/com/youlai/common/enums/EnvEnum.java b/youlai-common/common-base/src/main/java/com/youlai/common/enums/EnvEnum.java
index 23e893f55..d1cd333e3 100644
--- a/youlai-common/common-base/src/main/java/com/youlai/common/enums/EnvEnum.java
+++ b/youlai-common/common-base/src/main/java/com/youlai/common/enums/EnvEnum.java
@@ -12,8 +12,8 @@ import lombok.Getter;
@Getter
public enum EnvEnum implements IBaseEnum {
- DEV("dev", "开发"),
- PROD("prod", "生产");
+ DEV("dev", "开发环境"),
+ PROD("prod", "生产环境");
private final String value;
diff --git a/youlai-system/system-api/src/main/java/com/youlai/system/api/MenuFeignClient.java b/youlai-system/system-api/src/main/java/com/youlai/system/api/MenuFeignClient.java
new file mode 100644
index 000000000..5abba6e36
--- /dev/null
+++ b/youlai-system/system-api/src/main/java/com/youlai/system/api/MenuFeignClient.java
@@ -0,0 +1,14 @@
+package com.youlai.system.api;
+
+import com.youlai.common.core.config.FeignDecoderConfig;
+import com.youlai.system.dto.CodegenMenuDTO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@FeignClient(value = "youlai-system", contextId = "menu", configuration = {FeignDecoderConfig.class})
+public interface MenuFeignClient {
+
+ @PostMapping("/api/v1/menus/codegen")
+ void addMenuForCodegen( @RequestBody CodegenMenuDTO data);
+}
diff --git a/youlai-system/system-api/src/main/java/com/youlai/system/api/UserFeignClient.java b/youlai-system/system-api/src/main/java/com/youlai/system/api/UserFeignClient.java
index 47084e29a..c2de0ed0c 100644
--- a/youlai-system/system-api/src/main/java/com/youlai/system/api/UserFeignClient.java
+++ b/youlai-system/system-api/src/main/java/com/youlai/system/api/UserFeignClient.java
@@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
-@FeignClient(value = "youlai-system", fallback = UserFeignFallbackClient.class, configuration = {FeignDecoderConfig.class})
+@FeignClient(value = "youlai-system", contextId = "user", fallback = UserFeignFallbackClient.class, configuration = {FeignDecoderConfig.class})
public interface UserFeignClient {
@GetMapping("/api/v1/users/{username}/authInfo")
diff --git a/youlai-system/system-boot/src/main/java/com/youlai/system/controller/MenuController.java b/youlai-system/system-boot/src/main/java/com/youlai/system/controller/MenuController.java
index fd8fc84eb..062941ffd 100644
--- a/youlai-system/system-boot/src/main/java/com/youlai/system/controller/MenuController.java
+++ b/youlai-system/system-boot/src/main/java/com/youlai/system/controller/MenuController.java
@@ -113,16 +113,14 @@ public class MenuController {
return Result.judge(result);
}
-
/**
* 代码生成器生成代码新增菜单
*/
@PostMapping("/codegen")
- public Result createCodegenMenu(
+ public Result addMenuForCodegen(
@RequestBody @Valid CodegenMenuDTO data
) {
-
- boolean result = menuService.createCodegenMenu(data);
+ boolean result = menuService.addMenuForCodegen(data);
return Result.judge(result);
}
diff --git a/youlai-system/system-boot/src/main/java/com/youlai/system/service/MenuService.java b/youlai-system/system-boot/src/main/java/com/youlai/system/service/MenuService.java
index 5a96aa8a4..008fa88be 100644
--- a/youlai-system/system-boot/src/main/java/com/youlai/system/service/MenuService.java
+++ b/youlai-system/system-boot/src/main/java/com/youlai/system/service/MenuService.java
@@ -64,5 +64,5 @@ public interface MenuService extends IService