| | |
| | | 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 AdminVOVO createAdminVO() throws Exception { |
| | | if (StringUtil.isNullOrEmpty(config.getAdmin().getController().getAdminVOPackage())) { |
| | | return null; |
| | | } |
| | | |
| | | String name = NameUtil.getDefaultAdminVOName(config.getEntity()); |
| | | String path = getDirPath(config.getAdmin().getController().getAdminVOPackage()); |
| | | try { |
| | | AdminVOVO vo = new AdminVOVO.Builder().setEntity(config.getEntity()).setPackageName(config.getAdmin().getController().getAdminVOPackage()).build(); |
| | | String result = GeneraterUtil.createAdminVO(vo); |
| | | //保存 |
| | | saveFile(result, new File(path, name + ".java").getAbsolutePath()); |
| | | return vo; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | | |
| | | QueryVO queryVO = createQuery(config.getService().getQueryPackage()); |
| | | |
| | |
| | | query = new ClassInfo(queryName, config.getService().getQueryPackage() + "." + queryName); |
| | | } |
| | | |
| | | AdminVOVO adminVOVO = null; |
| | | if (config.getAdmin().getController().getAdminVOPackage() != null) { |
| | | adminVOVO = createAdminVO(); |
| | | } |
| | | |
| | | |
| | | String path = getDirPath(config.getAdmin().getController().getPkg()); |
| | | |
| | | AdminGeneraterInfo generaterInfo = new AdminGeneraterInfo.Builder().setEntityClass(config.getEntity()).setAdminData(config.getAdmin()).build(); |
| | | |
| | | |
| | | AdminControllerInfoVO vo = new AdminControllerInfoVO.Builder().setAdminInfo(generaterInfo).setPackageName(generaterInfo.getControllerData().getPkg()).setQueryVO(query).setService(service).build(); |
| | | AdminControllerInfoVO vo = new AdminControllerInfoVO.Builder().setAdminVO(adminVOVO == null ? null : new ClassInfo(adminVOVO.getName(), adminVOVO.getPackageName() + "." + adminVOVO.getName())).setAdminInfo(generaterInfo).setPackageName(generaterInfo.getControllerData().getPkg()).setQueryVO(query).setService(service).build(); |
| | | String controllerName = vo.getControllerName(); |
| | | //生成controller |
| | | String result = GeneraterUtil.createAdminController(vo); |
| | |
| | | } |
| | | |
| | | |
| | | 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); |
| | | |
| | | } |
| | | |
| | | |