| | |
| | | "/**\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" + |
| | |
| | | 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(); |
| | |
| | | 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) |
| | |
| | | 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" + |
| | |
| | | " 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" + |
| | |
| | | "\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" + |
| | |
| | | "\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" + |
| | |
| | | " 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" + |