package org.yeshi.utils.generater;
|
|
import org.yeshi.utils.FreemarkerUtils;
|
import org.yeshi.utils.generater.entity.ExceptionData;
|
import org.yeshi.utils.generater.entity.MongoDBDaoData;
|
import org.yeshi.utils.generater.vo.ServiceInfoVO;
|
|
import java.io.File;
|
|
public class SpringComponentGenerater {
|
|
/**
|
* 创建mongodb的dao
|
*
|
* @param data
|
* @param targetDir
|
* @throws Exception
|
*/
|
public static void createMongoDao(MongoDBDaoData data, String targetDir) throws Exception {
|
FreemarkerUtils.renderingTemplateAndGenerateFile(SpringComponentGenerater.class.getClassLoader().getResourceAsStream("generater/mongoDBDao.template"), new File(targetDir, data.getDaoName() + ".java").getAbsolutePath(), data);
|
}
|
|
/**
|
* 创建服务
|
*
|
* @param data
|
* @param targetDir
|
* @throws Exception
|
*/
|
public static void createService(ServiceInfoVO data, String targetDir) throws Exception {
|
|
FreemarkerUtils.renderingTemplateAndGenerateFile(SpringComponentGenerater.class.getClassLoader().getResourceAsStream("generater/service/service.template"), new File(targetDir, data.getServiceClassName() + ".java").getAbsolutePath(), data);
|
}
|
|
/**
|
* 创建服务实现
|
*
|
* @param data
|
* @param targetDir
|
* @throws Exception
|
*/
|
public static void createServiceImpl(ServiceInfoVO data, String targetDir) throws Exception {
|
|
FreemarkerUtils.renderingTemplateAndGenerateFile(SpringComponentGenerater.class.getClassLoader().getResourceAsStream("generater/service/serviceImpl.template"), new File(targetDir, data.getServiceClassName() + "Impl.java").getAbsolutePath(), data);
|
}
|
|
|
|
public static void createException(ExceptionData data, String targetDir) throws Exception {
|
|
FreemarkerUtils.renderingTemplateAndGenerateFile(SpringComponentGenerater.class.getClassLoader().getResourceAsStream("exception.template"), new File(targetDir, data.getEntityClassName() + "Exception.java").getAbsolutePath(), data);
|
}
|
|
|
|
}
|