admin
2022-04-07 211840b64fa1132d76d6dff6c779e9ba2c0c450f
src/main/java/org/yeshi/utils/generater/GeneraterManagerV2.java
@@ -9,6 +9,7 @@
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;
@@ -82,7 +83,7 @@
        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("尚未配置异常信息");
        }
@@ -90,7 +91,7 @@
        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());
@@ -98,6 +99,25 @@
            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 {
@@ -220,7 +240,15 @@
        }
        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());
@@ -388,8 +416,12 @@
    }
    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);
    }