优化初始化数据
This commit is contained in:
@@ -29,9 +29,6 @@ public class CodeGen implements Serializable {
|
||||
@Schema(description = "功能ID")
|
||||
private Long itemId;
|
||||
|
||||
@Schema(description = "模块ID")
|
||||
private Long moduleId;
|
||||
|
||||
|
||||
@Hidden
|
||||
@AssertTrue(message = "当代码生成类型为 CONTROLLER 时,功能ID不能为空")
|
||||
@@ -42,15 +39,5 @@ public class CodeGen implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Hidden
|
||||
@AssertTrue(message = "当代码生成类型为 MODULE_DATA_INFO 时,模块ID不能为空")
|
||||
public boolean isModuleIdValid() {
|
||||
if (codeGenType == CodeGenType.MODULE_DATA_INFO) {
|
||||
return moduleId != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ import lombok.Getter;
|
||||
public enum CodeGenType {
|
||||
|
||||
CONTROLLER(0, "controller"),
|
||||
MODULE_DATA_INFO(1, "module_data_info");
|
||||
MODULE_DATA_INFO(1, "module_data_info"),
|
||||
role_permission(2,"role_permission");
|
||||
|
||||
private final int code;
|
||||
private final String desc;
|
||||
|
||||
@@ -15,6 +15,22 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
public class FunOperationTemp extends FunOperationEntity {
|
||||
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
private String moduleName;
|
||||
/**
|
||||
* 模块编码
|
||||
*/
|
||||
private String moduleCode;
|
||||
/**
|
||||
* 功能名称
|
||||
*/
|
||||
private String itemName;
|
||||
/**
|
||||
* 功能编码
|
||||
*/
|
||||
private String itemCode;
|
||||
/**
|
||||
* URL路径
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.cczsa.xinghe.codegen.entity.enums.TemplateTypeEnum;
|
||||
import com.cczsa.xinghe.codegen.mapper.FunItemMapper;
|
||||
import com.cczsa.xinghe.codegen.mapper.FunModuleMapper;
|
||||
import com.cczsa.xinghe.codegen.mapper.FunOperationMapper;
|
||||
import com.cczsa.xinghe.codegen.mapper.def.FunItemDef;
|
||||
import com.cczsa.xinghe.codegen.mapper.def.FunModuleDef;
|
||||
import com.cczsa.xinghe.codegen.mapper.def.FunOperationDef;
|
||||
import com.cczsa.xinghe.codegen.service.TemplateService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
@@ -47,12 +50,6 @@ public class ModuleDataInfoCreate extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Long moduleId = this.getContextBean(Long.class);
|
||||
|
||||
FunModuleEntity moduleEntity = funModuleMapper.selectOneById(moduleId);
|
||||
if (moduleEntity == null){
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取 模版
|
||||
String template = templateService.getTemplateTypeContent(TemplateTypeEnum.MODULE_DATA_INFO);
|
||||
@@ -83,7 +80,17 @@ public class ModuleDataInfoCreate extends NodeComponent {
|
||||
|
||||
ST operationTemplate = group.getInstanceOf("operationTemplate"); // 使用正确的模板名称
|
||||
// 操作数据生成
|
||||
List<FunOperationTemp> funOperationEntities = funOperationMapper.selectListByQueryAs(QueryWrapper.create(),FunOperationTemp.class);
|
||||
FunModuleDef moduleDef = FunModuleDef.FUN_MODULE_ENTITY;
|
||||
FunItemDef itemDefDef = FunItemDef.FUN_ITEM_ENTITY;
|
||||
FunOperationDef operationDef = FunOperationDef.FUN_OPERATION_ENTITY;
|
||||
|
||||
QueryWrapper wrapper = QueryWrapper.create();
|
||||
wrapper.select(operationDef.ALL_COLUMNS,moduleDef.MODULE_NAME,moduleDef.MODULE_CODE,itemDefDef.ITEM_NAME,itemDefDef.ITEM_CODE)
|
||||
.from(operationDef)
|
||||
.leftJoin(moduleDef).on(operationDef.MODULE_ID.eq(moduleDef.ID))
|
||||
.leftJoin(itemDefDef).on(operationDef.ITEM_ID.eq(itemDefDef.ID))
|
||||
.where(operationDef.ID.isNotNull());
|
||||
List<FunOperationTemp> funOperationEntities = funOperationMapper.selectListByQueryAs(wrapper,FunOperationTemp.class);
|
||||
funOperationEntities.sort(Comparator.comparing(FunOperationEntity::getId));
|
||||
funOperationEntities.forEach(FunOperationTemp::info);
|
||||
operationTemplate.add("operation", funOperationEntities);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.cczsa.xinghe.codegen.service.impl;
|
||||
|
||||
import com.cczsa.xinghe.codegen.entity.FunItemEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.FunModuleEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.domain.template.CodeGen;
|
||||
import com.cczsa.xinghe.codegen.entity.domain.template.CodeGenType;
|
||||
import com.cczsa.xinghe.codegen.mapper.FunItemMapper;
|
||||
@@ -43,20 +42,10 @@ public class CodeGenServiceImpl implements CodeGenService {
|
||||
id = req.getItemId();
|
||||
}
|
||||
|
||||
if(req.getCodeGenType() == CodeGenType.MODULE_DATA_INFO){
|
||||
FunModuleEntity funModuleEntity = funModuleMapper.selectOneById(req.getModuleId());
|
||||
if (funModuleEntity == null) {
|
||||
return null;
|
||||
}
|
||||
id = req.getModuleId();
|
||||
}
|
||||
|
||||
if(id != null){
|
||||
LiteflowResponse response = flowExecutor.execute2Resp(req.getCodeGenType().getDesc(),null,id);
|
||||
log.info("执行结果:{}",response);
|
||||
if (response.isSuccess()) {
|
||||
return (byte[]) response.getSlot().getResponseData();
|
||||
}
|
||||
LiteflowResponse response = flowExecutor.execute2Resp(req.getCodeGenType().getDesc(),null,id);
|
||||
log.info("执行结果:{}",response);
|
||||
if (response.isSuccess()) {
|
||||
return (byte[]) response.getSlot().getResponseData();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user