Java Code Examples for com.ruoyi.generator.util.GenUtils#getParam()
The following examples show how to use
com.ruoyi.generator.util.GenUtils#getParam() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenServiceImpl.java From ruoyiplus with MIT License | 5 votes |
private Map generatorAdvCodeOnlyWeb( String tmplName, TableInfo table, List<ColumnInfo> columns, Map<String, String[]> params) { Map retMap = new HashMap(); // 设置主键 table.setPrimaryKey(table.getColumnsLast()); // 设置表格的访问地址 table.setUri(Convert.toStr(GenUtils.getParam(params, "uri"), "system/unknown")); VelocityInitializer.initVelocity(); String packageName = GenUtils.getParam(params, "package"); String moduleName = GenUtils.getParam(params, "module"); table.setModule(moduleName); String genJava = Convert.toStr(GenUtils.getParam(params, "gen-java"), "0"); String genHtml = Convert.toStr(GenUtils.getParam(params, "gen-html"), "0"); TableInfo.GenStyle genStyle = TableInfo.GenStyle.All; if (genJava.equals("1") && genHtml.equals("0")) { genStyle = TableInfo.GenStyle.Java; } else if (genHtml.equals("1") && genJava.equals("0")) { genStyle = TableInfo.GenStyle.Web; } VelocityContext context = GenUtils.getVelocityContext(table, packageName); // 获取模板列表 List<String> templates = GenUtils.getTemplatesWeb(genStyle, tmplName); return putIntoMap(retMap, context, templates); }
Example 2
Source File: GenServiceImpl.java From ruoyiplus with MIT License | 5 votes |
@Override public Map previewCode( TableInfo.GenStyle codeStyle, String tableName, Map<String, String[]> params) { String prefix = GenUtils.getParam(params, "prefix"); TableInfo table = getTableInfo(tableName, prefix, params); if (codeStyle == TableInfo.GenStyle.Web) { return generatorAdvCodeOnlyWeb( GenUtils.getParam(params, "tmpl"), table, table.getColumns(), params); } return null; }
Example 3
Source File: GenServiceImpl.java From ruoyiplus with MIT License | 4 votes |
@Override public byte[] generatorCode( TableInfo.GenStyle codeStyle, String tableName, Map<String, String[]> params) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); // 查询表信息 String prefix = GenUtils.getParam(params, "prefix"); TableInfo table = getTableInfo(tableName, prefix, params); // 查询列信息 List<ColumnInfo> columns = table.getColumns(); // 列的额外信息处理 for (ColumnInfo c : columns) { String[] ss = params.get(c.getAttrname()); if (ss != null && ss.length == 1) { JSONObject _json = JSONUtil.parseObj(ss[0]); c.setWidth(Convert.toInt(_json.get("width"), 150)); c.setVisible(Convert.toBool(_json.get("visible"), true)); c.setEditField(Convert.toBool(_json.get("editable"), true)); c.setSearchField(Convert.toBool(_json.get("searchable"), false)); List<Verify> verifyList = Lists.newArrayList(); if (_json.containsKey("verify")) { String vvs = Convert.toStr(_json.get("verify")); if (vvs.length() > 0) { String[] vvArray = StrUtil.splitToArray(vvs, ','); for (String _v : vvArray) { verifyList.add(new Verify(_v)); } } c.setVerifyList(verifyList); } else { c.setVerifyList(verifyList); } } } // 生成代码 String tmpl = GenUtils.getParam(params, "tmpl"); if (StrUtil.isEmpty(tmpl)) { generatorCode(table, zip); } else { generatorAdvCodeOnlyWeb(tmpl, table, columns, params, zip); } IOUtils.closeQuietly(zip); return outputStream.toByteArray(); }