代码生成的修改
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run

This commit is contained in:
pch 2024-12-02 12:46:26 +08:00
parent 3d3ee4a5ce
commit 01609ed980
8 changed files with 123 additions and 21 deletions

View File

@ -38,4 +38,6 @@ public interface ErrorCodeConstants {
ErrorCode CARINFO_NOT_EXISTS = new ErrorCode(1_011_013_000, "车辆信息录入不存在");
// ========== 驾驶员信息 1_011_014_000 ==========
ErrorCode DRIVER_NOT_EXISTS = new ErrorCode(1_011_014_000, "驾驶员信息不存在");
// ========== 项目管理 1_011_015_000 ==========
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_011_015_000, "项目管理不存在");
}

View File

@ -81,16 +81,16 @@ public class QjglController {
public CommonResult<PageResult<QjglRespVO>> getQjglPage(@Valid QjglPageReqVO pageReqVO) {
// PageResult<QjglDO> pageResult = qjglService.getQjglPage(getLoginUserId(),pageReqVO);
PageResult<QjglDO> pageResult = qjglService.getQjglPage(pageReqVO);
// return success(BeanUtils.toBean(pageResult, QjglRespVO.class));
return success(BeanUtils.toBean(pageResult, QjglRespVO.class));
if (CollUtil.isEmpty(pageResult.getList())) {
return success(new PageResult<>(pageResult.getTotal()));
}
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(pageResult.getList(), QjglDO::getDeptId));
// 转换并返回结果
return success(new PageResult<>(QjglConvert.INSTANCE.convertList(pageResult.getList(), deptMap), pageResult.getTotal()));
// if (CollUtil.isEmpty(pageResult.getList())) {
// return success(new PageResult<>(pageResult.getTotal()));
// }
// Map<Long, DeptDO> deptMap = deptService.getDeptMap(
// convertList(pageResult.getList(), QjglDO::getDeptId));
//
// // 转换并返回结果
// return success(new PageResult<>(QjglConvert.INSTANCE.convertList(pageResult.getList(), deptMap), pageResult.getTotal()));
}
@GetMapping("/export-excel")

View File

@ -31,6 +31,7 @@ public interface QjglMapper extends BaseMapperX<QjglDO> {
.eqIfPresent(QjglDO::getStatus, reqVO.getStatus())
.orderByDesc(QjglDO::getId));
}
//
default PageResult<QjglDO> selectPage(long userId,QjglPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<QjglDO>()
.eqIfPresent(QjglDO::getTitle, reqVO.getTitle())

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.dal.dataobject.processinstancetodo.ProcessInstanceTodoDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.processinstancetodo.ProcessInstanceTodoMapper;
import cn.iocoder.yudao.module.bpm.service.processinstancetodo.ProcessInstanceTodoService;
import cn.iocoder.yudao.module.home.controller.admin.qjgl.vo.*;
import cn.iocoder.yudao.module.home.dal.dataobject.qjgl.QjglDO;
import cn.iocoder.yudao.module.home.dal.mysql.qjgl.QjglMapper;
@ -37,7 +38,7 @@ public class QjglServiceImpl implements QjglService {
private BpmProcessInstanceApi processInstanceApi;
@Resource
private ProcessInstanceTodoMapper processInstanceTodoMapper;
private ProcessInstanceTodoService processInstanceTodoService;
@Override
public Long createQjgl(Long userId,QjglSaveReqVO createReqVO) {
PROCESS_KEY = createReqVO.getProcessDefinitionKey();
@ -57,13 +58,11 @@ public class QjglServiceImpl implements QjglService {
qjglMapper.updateById(new QjglDO().setId(qjgl.getId()).setProcessInstanceId(processInstanceId));
//同步更新流程待办库
ProcessInstanceTodoDO todo = new ProcessInstanceTodoDO();
todo.setTitle( createReqVO.getTitle() );
todo.setProcessKey( PROCESS_KEY );
todo.setProcessInstanceId( processInstanceId );
todo.setFormCustomCreatePath( createReqVO.getCurfullpath() );
todo.setStatus( 0 );
processInstanceTodoMapper.insert(todo);
processInstanceTodoService.oaCreateProcessInstanceTodo(
createReqVO.getTitle(),
PROCESS_KEY,
processInstanceId,
createReqVO.getCurfullpath());
// 返回
return qjgl.getId();
}

View File

@ -45,6 +45,8 @@ public class CodegenTableRespVO {
@Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
private Integer frontType;
private Integer modelType;
@Schema(description = "父菜单编号", example = "1024")
private Long parentMenuId;

View File

@ -60,6 +60,9 @@ public class CodegenTableSaveReqVO {
@NotNull(message = "前端类型不能为空")
private Integer frontType;
@NotNull(message = "模式类型不能为空")
private Integer modelType;
@Schema(description = "父菜单编号", example = "1024")
private Long parentMenuId;

View File

@ -107,6 +107,7 @@ public class CodegenTableDO extends BaseDO {
*/
private Integer frontType;
private Integer modelType;
// ========== 菜单相关字段 ==========
/**

View File

@ -93,6 +93,37 @@ public class CodegenEngine {
.put("codegen/sql/h2.vm", "sql/h2.sql")
.build();
private static final Map<String, String> SERVER_TEMPLATES2 = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序
// Java module-biz Main
.put(javaTemplatePath("controller/vo/flowPageReqVO"), javaModuleImplVOFilePath("PageReqVO"))
.put(javaTemplatePath("controller/vo/listReqVO"), javaModuleImplVOFilePath("ListReqVO"))
.put(javaTemplatePath("controller/vo/flowRespVO"), javaModuleImplVOFilePath("RespVO"))
.put(javaTemplatePath("controller/vo/flowSaveReqVO"), javaModuleImplVOFilePath("SaveReqVO"))
.put(javaTemplatePath("controller/flowController"), javaModuleImplControllerFilePath())
.put(javaTemplatePath("dal/do"),
javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO"))
.put(javaTemplatePath("dal/do_sub"), // 特殊主子表专属逻辑
javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${subTable.className}DO"))
.put(javaTemplatePath("dal/Mapper"),
javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper"))
.put(javaTemplatePath("dal/mapper_sub"), // 特殊主子表专属逻辑
javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${subTable.className}Mapper"))
.put(javaTemplatePath("dal/mapper.xml"), mapperXmlFilePath())
.put(javaTemplatePath("service/flowServiceImpl"),
javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl"))
.put(javaTemplatePath("service/flowService"),
javaModuleImplMainFilePath("service/${table.businessName}/${table.className}Service"))
.put(javaTemplatePath("service/listener"),
javaModuleImplMainFilePath("service/${table.businessName}/listenter/${table.className}StatusListener"))
// Java module-biz Test
.put(javaTemplatePath("test/serviceTest"),
javaModuleImplTestFilePath("service/${table.businessName}/${table.className}ServiceImplTest"))
// Java module-api Main
.put(javaTemplatePath("enums/errorcode"), javaModuleApiMainFilePath("enums/ErrorCodeConstants_手动操作"))
// SQL
.put("codegen/sql/sql.vm", "sql/sql.sql")
.put("codegen/sql/h2.vm", "sql/h2.sql")
.build();
/**
* 后端的配置模版
*
@ -155,6 +186,63 @@ public class CodegenEngine {
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
.build();
private static final Table<Integer, String, String> FRONT_TEMPLATES2 = ImmutableTable.<Integer, String, String>builder()
// Vue2 标准模版
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/index.vue"),
vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"),
vueFilePath("api/${table.moduleName}/${table.businessName}/index.js"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/form.vue"),
vueFilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_normal.vue"), // 特殊主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_inner.vue"), // 特殊主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_erp.vue"), // 特殊主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_inner.vue"), // 特殊主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_erp.vue"), // 特殊主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
// Vue3 标准模版
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/flowindex.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/flowform.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/flowdetail.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Detail.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_normal.vue"), // 特殊主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_inner.vue"), // 特殊主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_erp.vue"), // 特殊主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_inner.vue"), // 特殊主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_erp.vue"), // 特殊主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/flowapi.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
// Vue3 Schema 模版
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/form.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
// Vue3 vben 模版
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/form.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Modal.vue"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
.build();
@Resource
private CodegenProperties codegenProperties;
@ -231,7 +319,7 @@ public class CodegenEngine {
// 1.1 初始化 bindMap 上下文
Map<String, Object> bindingMap = initBindingMap(table, columns, subTables, subColumnsList);
// 1.2 获得模版
Map<String, String> templates = getTemplates(table.getFrontType());
Map<String, String> templates = getTemplates(table.getFrontType(),table.getModelType() );
// 2. 执行生成
Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(templates.size()); // 有序
@ -404,10 +492,16 @@ public class CodegenEngine {
return bindingMap;
}
private Map<String, String> getTemplates(Integer frontType) {
private Map<String, String> getTemplates(Integer frontType,Integer modelType) {
Map<String, String> templates = new LinkedHashMap<>();
templates.putAll(SERVER_TEMPLATES);
templates.putAll(FRONT_TEMPLATES.row(frontType));
if ( modelType == 0) {
templates.putAll(SERVER_TEMPLATES);
templates.putAll(FRONT_TEMPLATES.row(frontType));
}
if ( modelType == 1) {
templates.putAll(SERVER_TEMPLATES2);
templates.putAll(FRONT_TEMPLATES2.row(frontType));
}
return templates;
}