| | |
| | | import org.yeshi.utils.generater.util.NameUtil; |
| | | import org.yeshi.utils.generater.vo.ExceptionVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminControllerInfoVO; |
| | | import org.yeshi.utils.generater.vo.admin.controller.AdminVOVO; |
| | | import org.yeshi.utils.generater.vo.dao.MongoDBDaoVO; |
| | | import org.yeshi.utils.generater.vo.dao.MyBatisDBDaoVO; |
| | | import org.yeshi.utils.generater.vo.service.QueryVO; |
| | |
| | | FileUtil.saveAsFileByte(data.getBytes("UTF-8"), path); |
| | | } |
| | | |
| | | public void createException(Class base) throws Exception { |
| | | public void createException(ClassInfo base) throws Exception { |
| | | if (config.getService().getException() == null) { |
| | | throw new Exception("尚未配置异常信息"); |
| | | } |
| | |
| | | String exceptionName = NameUtil.getDefaultExceptionName(config.getEntity()); |
| | | String path = getDirPath(config.getService().getException().getPkg()); |
| | | try { |
| | | ExceptionVO vo = new ExceptionVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getException().getPkg()).setBase(new ClassInfo(base.getSimpleName(), base.getName())).build(); |
| | | ExceptionVO vo = new ExceptionVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getException().getPkg()).setBase(base).build(); |
| | | String result = GeneraterUtil.createException(vo); |
| | | //保存 |
| | | saveFile(result, new File(path, exceptionName + ".java").getAbsolutePath()); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void createAdminVO() throws Exception { |
| | | if (StringUtil.isNullOrEmpty(config.getService().getAdminVOPackage())) { |
| | | throw new Exception("尚未配置AdminVO"); |
| | | } |
| | | |
| | | String name = NameUtil.getDefaultExceptionName(config.getEntity()); |
| | | String path = getDirPath(config.getService().getAdminVOPackage()); |
| | | try { |
| | | AdminVOVO vo = new AdminVOVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getAdminVOPackage()).build(); |
| | | String result = GeneraterUtil.createAdminVO(vo); |
| | | //保存 |
| | | saveFile(result, new File(path, name + ".java").getAbsolutePath()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void createDao() throws Exception { |
| | | |
| | |
| | | } |
| | | |
| | | if (config.getService().getException() != null) { |
| | | createException(Exception.class); |
| | | if (config.getService().getException().getBase() != null) { |
| | | createException(config.getService().getException().getBase()); |
| | | } else { |
| | | createException(ClassInfo.create(Exception.class)); |
| | | } |
| | | } |
| | | |
| | | if (config.getService().getAdminVOPackage() != null) { |
| | | createAdminVO(); |
| | | } |
| | | |
| | | QueryVO queryVO = createQuery(config.getService().getQueryPackage()); |
| | |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.print(getHtmlNameFromEntityName("TTestEEntity")); |
| | | public static void main(String[] args) throws Exception { |
| | | // System.out.print(getHtmlNameFromEntityName("TTestEEntity")); |
| | | // AdminVOVO vo = new AdminVOVO.Builder().setEntity(TestEntity3.class).setPackageName("test.vo.admin").build(); |
| | | // String result = GeneraterUtil.createAdminVO(vo); |
| | | // System.out.println(result); |
| | | |
| | | } |
| | | |
| | | |