Exemple #1
0
  public static void makeEntity() throws Exception {
    Configuration cfg = getCfg();
    Template template = cfg.getTemplate("entity.html");

    // 生成文件设置
    String path =
        getJavaFileRoot() + File.separator + PropertyUtil.getValue("code.src.entity.root");
    mkdirs(path);
    path += File.separator + upperKey + "Entity.java";
    FileWriter sw = new FileWriter(new File(path));
    WeakHashMap<String, Object> data = new WeakHashMap<String, Object>();
    data.put("packageName", entityPackagePath);
    data.put("key", key);
    data.put("UpperKey", upperKey);
    data.put("ZhKey", zhKey);
    data.put("author", author);
    data.put("createDate", createDate);

    List<Field> list = MysqlUtil.getInstance().getTableField();
    noCommonFieldList = removeCommonFields(list);
    data.put("fieldList", list);
    data.put("noCommonFieldList", noCommonFieldList);

    primaryKey = MysqlUtil.getInstance().getPrimaryKey(list);
    fieldList = list;

    String level = PropertyUtil.getValue("created.code.level");
    if (!levels.contains(level)) {
      level = "all";
    }
    if ("all".equals(level) || "entity".equals(level)) {
      template.process(data, sw);
    }
  }
Exemple #2
0
  public static void makeAll() throws Exception {
    String level = PropertyUtil.getValue("created.code.level");
    if (!levels.contains(level)) {
      level = "all";
    }

    makeEntity();

    switch (level) {
      case "all":
        makeDao();
        makeService();
        makeController();
        if ("mysql".equalsIgnoreCase(PropertyUtil.getValue("database.type"))) {
          MysqlUtil.makeSqlMap();
        }
        EasyUiUtil.makeJs();
        EasyUiUtil.makePage();
        break;
      case "entity":
        break;
      case "sqlMap":
        if ("mysql".equalsIgnoreCase(PropertyUtil.getValue("database.type"))) {
          MysqlUtil.makeSqlMap();
        }
        break;
      case "dao":
        makeDao();
        break;
      case "service":
        makeService();
        break;
      case "controller":
        makeController();
        break;
      case "page":
        EasyUiUtil.makeJs();
        EasyUiUtil.makePage();
        break;
    }
  }