From 933e4dfb48371e89b2af2c70157f62341adcb185 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Wed, 21 Jun 2023 22:17:26 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20EnjoyTemplate=20?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codegen/template/impl/EnjoyTemplate.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/template/impl/EnjoyTemplate.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/template/impl/EnjoyTemplate.java index cd1b43a8..f752ecc6 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/template/impl/EnjoyTemplate.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/template/impl/EnjoyTemplate.java @@ -1,17 +1,17 @@ -/** - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.mybatisflex.codegen.template.impl; @@ -28,6 +28,9 @@ import java.io.File; import java.io.FileOutputStream; import java.util.Map; +/** + * JFinal Enjoy 模板引擎实现。 + */ public class EnjoyTemplate implements ITemplate { private final Engine engine; @@ -43,17 +46,22 @@ public class EnjoyTemplate implements ITemplate { @Override public void generate(Map params, String templateFilePath, File generateFile) { - if (!generateFile.getParentFile().exists() && !generateFile.getParentFile().mkdirs()){ + if (!generateFile.getParentFile().exists() && !generateFile.getParentFile().mkdirs()) { throw new IllegalStateException("Can not mkdirs by dir: " + generateFile.getParentFile()); } - - try(FileOutputStream fileOutputStream = new FileOutputStream(generateFile)) { + // 开始生成文件 + try (FileOutputStream fileOutputStream = new FileOutputStream(generateFile)) { engine.getTemplate(templateFilePath).render(params, fileOutputStream); } catch (Exception e) { e.printStackTrace(); } } + /** + * 从文件或者类路径读取模板。 + * + * @author 王帅 + */ public static class FileAndClassPathSourceFactory implements ISourceFactory { @Override