From abda7b6998f4fad0a5b62f718c297405079394d8 Mon Sep 17 00:00:00 2001 From: liulin <lin.liu@88.com> Date: 星期一, 02 十二月 2024 23:35:32 +0800 Subject: [PATCH] search类生成位置 --- src/test/java/com/lunhan/xxx/GenCodeMysql.java | 50 +++++++++++++++++--------------------------------- 1 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/test/java/com/lunhan/xxx/GenCodeMysql.java b/src/test/java/com/lunhan/xxx/GenCodeMysql.java index 2a0c725..3dde862 100644 --- a/src/test/java/com/lunhan/xxx/GenCodeMysql.java +++ b/src/test/java/com/lunhan/xxx/GenCodeMysql.java @@ -38,7 +38,7 @@ public static final String MAPPERXML = "./src/main/resources/mapper/"; public static final String SERVICE = "./src/main/java/com/lunhan/water/service/"; public static final String Controller = "./src/main/java/com/lunhan/water/host/controller/"; - public static final String SEARCH = "./src/main/java/com/lunhan/water/entity/dto/search/"; + public static final String SEARCH = "./src/main/java/com/lunhan/water/entity/search/"; public static final String RequestDTO = "./src/main/java/com/lunhan/water/entity/request/"; public static final String ResponseDTO = "./src/main/java/com/lunhan/water/entity/response/"; } @@ -54,7 +54,7 @@ public static final String MAPPER = "com.lunhan.water.repository"; public static final String SERVICE = "com.lunhan.water.service"; public static final String Controller = "com.lunhan.water.host.controller"; - public static final String SEARCH = "com.lunhan.water.entity.dto.search"; + public static final String SEARCH = "com.lunhan.water.entity.search"; public static final String Request = "com.lunhan.water.entity.request"; public static final String Response = "com.lunhan.water.entity.response"; } @@ -197,13 +197,11 @@ "/**\n" + " * {#=desc}\n" + " * @author {#=author}\n" + - " * @description {#=desc}\n" + " */"; private static final String SET_METHOD_DESC_TPL = " /**\n" + " * {#=desc}\n" + " * @author {#=author}\n" + - " * @description {#=desc}\n" + " */"; private static final String SET_PRO_DESC_TPL = "\t/**\n" + @@ -1047,6 +1045,7 @@ String modifyDTOName = SuffixSet.Modify + modelName; String responseDTOName = modelName + "VO"; String searchName = "Search" + modelName; + String convertMapperName = modelName + GenCodeGauss.SuffixSet.CONVERT_MAPPER; String tableNamePackage = tableName.toLowerCase().replaceAll("_", ""); StringBuilder content = new StringBuilder(); @@ -1063,30 +1062,13 @@ content.append(ConstantFactory.STR_NEWLINE); } } - content.append("import "); - content.append(PackageSet.DAO); - content.append("."); - content.append(daoName + ";\n"); - content.append("import "); - content.append(PackageSet.PO); - content.append("."); - content.append(poName + ";\n"); - content.append("import "); - content.append(PackageSet.Request); - content.append("." + tableNamePackage + "."); - content.append(createDTOName + ";\n"); - content.append("import "); - content.append(PackageSet.Request); - content.append("." + tableNamePackage + "."); - content.append(modifyDTOName + ";\n"); - content.append("import "); - content.append(PackageSet.SEARCH); - content.append("."); - content.append(searchName + ";\n"); - content.append("import "); - content.append(PackageSet.VO); - content.append("."); - content.append(responseDTOName + ";\n"); + content.append(String.format("import %s.%s;\n", GenCodeGauss.PackageSet.MAPPER_IMPL, daoName)); + content.append(String.format("import %s.%s;\n", GenCodeGauss.PackageSet.PO, poName)); + content.append(String.format("import %s.%s.%s;\n", GenCodeGauss.PackageSet.Request, tableNamePackage, createDTOName)); + content.append(String.format("import %s.%s.%s;\n", GenCodeGauss.PackageSet.Request, tableNamePackage, modifyDTOName)); + content.append(String.format("import %s.%s;\n", GenCodeGauss.PackageSet.SEARCH, searchName)); + content.append(String.format("import %s.%s;\n", GenCodeGauss.PackageSet.VO, responseDTOName)); + content.append(String.format("import %s.%s;\n", GenCodeGauss.PackageSet.CONVERT_MAPPER, convertMapperName)); content.append(ConstantFactory.STR_NEWLINE); content.append(SET_CLASS_DESC_TPL .replaceAll("\\{\\#\\=desc\\}", tableDesc) @@ -1103,7 +1085,7 @@ content.append(ConstantFactory.STR_NEWLINE); content.append(" public ExecutedResult<Long> create(" + createDTOName + " request) {\n" + " // 转换po\n" + - " " + poName + " item = CopierUtil.mapTo(request, " + poName + ".class);\n" + + " " + poName + " item = " + convertMapperName + ".INSTANCE.toCreate(request);\n" + " // 设置主键id\n" + " //item.setId(SnowFlakeUtil.getId());\n" + " // 设置状态\n" + @@ -1127,7 +1109,7 @@ " return ExecutedResult.failed(checkExists.getMsg());\n" + " }\n" + " // 转换po\n" + - " " + poName + " item = CopierUtil.mapTo(request, " + poName + ".class);\n" + + " " + poName + " item = " + convertMapperName + ".INSTANCE.toModify(request);\n" + "\n" + " Boolean result = this.dao.modify(item);\n" + " if (BooleanUtils.isFalse(result)) {\n" + @@ -1141,7 +1123,8 @@ "\n" + " " + poName + " find = dao.getById(id);\n" + " if (null != find) {\n" + - " result = CopierUtil.mapTo(find, " + responseDTOName + ".class);\n" + + " // 转换vo\n" + + " result = " + convertMapperName + ".INSTANCE.toVo(find);\n" + " }\n" + " return ExecutedResult.success(result);\n" + " }\n" + @@ -1218,7 +1201,8 @@ "\n" + " List<" + poName + "> list = this.dao.getListById(listId);\n" + " if (ListUtil.isNotNullOrEmpty(list)) {\n" + - " result = CopierUtil.mapTo(list, " + responseDTOName + ".class);\n" + + " // 转换vo\n" + + " result = " + convertMapperName + ".INSTANCE.toVo(list);\n" + " }\n" + " return ExecutedResult.success(result);\n" + " }\n" + @@ -1239,7 +1223,7 @@ " if (ListUtil.isNotNullOrEmpty(list)) {\n" + " pageList.setLastId(list.get(list.size() - 1).getId());\n" + " // 转换vo\n" + - " listVo = CopierUtil.mapTo(list, " + responseDTOName + ".class);\n" + + " listVo = " + convertMapperName + ".INSTANCE.toVo(list);\n" + " }\n" + " PagerResult<" + responseDTOName + "> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo);\n" + " result.setLastId(pageList.getLastId());\n" + -- Gitblit v1.9.3