Search in sources :

Example 11 with GenTableColumn

use of com.ruoyi.generator.domain.GenTableColumn in project wumei-smart by kerwincui.

the class GenTableServiceImpl method updateGenTable.

/**
 * 修改业务
 *
 * @param genTable 业务信息
 * @return 结果
 */
@Override
@Transactional
public void updateGenTable(GenTable genTable) {
    String options = JSON.toJSONString(genTable.getParams());
    genTable.setOptions(options);
    int row = genTableMapper.updateGenTable(genTable);
    if (row > 0) {
        for (GenTableColumn cenTableColumn : genTable.getColumns()) {
            genTableColumnMapper.updateGenTableColumn(cenTableColumn);
        }
    }
}
Also used : GenTableColumn(com.ruoyi.generator.domain.GenTableColumn) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with GenTableColumn

use of com.ruoyi.generator.domain.GenTableColumn in project wumei-smart by kerwincui.

the class VelocityUtils method getExpandColumn.

/**
 * 获取需要在哪一列上面显示展开按钮
 *
 * @param genTable 业务表对象
 * @return 展开按钮列序号
 */
public static int getExpandColumn(GenTable genTable) {
    String options = genTable.getOptions();
    JSONObject paramsObj = JSONObject.parseObject(options);
    String treeName = paramsObj.getString(GenConstants.TREE_NAME);
    int num = 0;
    for (GenTableColumn column : genTable.getColumns()) {
        if (column.isList()) {
            num++;
            String columnName = column.getColumnName();
            if (columnName.equals(treeName)) {
                break;
            }
        }
    }
    return num;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) GenTableColumn(com.ruoyi.generator.domain.GenTableColumn)

Example 13 with GenTableColumn

use of com.ruoyi.generator.domain.GenTableColumn in project wumei-smart by kerwincui.

the class VelocityUtils method getImportList.

/**
 * 根据列类型获取导入包
 *
 * @param genTable 业务表对象
 * @return 返回需要导入的包列表
 */
public static HashSet<String> getImportList(GenTable genTable) {
    List<GenTableColumn> columns = genTable.getColumns();
    GenTable subGenTable = genTable.getSubTable();
    HashSet<String> importList = new HashSet<String>();
    if (StringUtils.isNotNull(subGenTable)) {
        importList.add("java.util.List");
    }
    for (GenTableColumn column : columns) {
        if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
            importList.add("java.util.Date");
            importList.add("com.fasterxml.jackson.annotation.JsonFormat");
        } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
            importList.add("java.math.BigDecimal");
        }
    }
    return importList;
}
Also used : GenTable(com.ruoyi.generator.domain.GenTable) GenTableColumn(com.ruoyi.generator.domain.GenTableColumn) HashSet(java.util.HashSet)

Example 14 with GenTableColumn

use of com.ruoyi.generator.domain.GenTableColumn in project wumei-smart by kerwincui.

the class VelocityUtils method getDicts.

/**
 * 根据列类型获取字典组
 *
 * @param genTable 业务表对象
 * @return 返回字典组
 */
public static String getDicts(GenTable genTable) {
    List<GenTableColumn> columns = genTable.getColumns();
    List<String> dicts = new ArrayList<String>();
    for (GenTableColumn column : columns) {
        if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(column.getHtmlType(), new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX })) {
            dicts.add("'" + column.getDictType() + "'");
        }
    }
    return StringUtils.join(dicts, ", ");
}
Also used : GenTableColumn(com.ruoyi.generator.domain.GenTableColumn) ArrayList(java.util.ArrayList)

Example 15 with GenTableColumn

use of com.ruoyi.generator.domain.GenTableColumn in project RuoYi-Vue by yangzongzhuan.

the class GenController method getInfo.

/**
 * 修改代码生成业务
 */
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
@GetMapping(value = "/{tableId}")
public AjaxResult getInfo(@PathVariable Long tableId) {
    GenTable table = genTableService.selectGenTableById(tableId);
    List<GenTable> tables = genTableService.selectGenTableAll();
    List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("info", table);
    map.put("rows", list);
    map.put("tables", tables);
    return AjaxResult.success(map);
}
Also used : GenTable(com.ruoyi.generator.domain.GenTable) HashMap(java.util.HashMap) GenTableColumn(com.ruoyi.generator.domain.GenTableColumn) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

GenTableColumn (com.ruoyi.generator.domain.GenTableColumn)34 GenTable (com.ruoyi.generator.domain.GenTable)20 Transactional (org.springframework.transaction.annotation.Transactional)12 IOException (java.io.IOException)10 ServiceException (com.ruoyi.common.exception.ServiceException)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 Constants (com.ruoyi.common.constant.Constants)5 GenConstants (com.ruoyi.common.constant.GenConstants)5 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)5 StringUtils (com.ruoyi.common.utils.StringUtils)5 GenTableColumnMapper (com.ruoyi.generator.mapper.GenTableColumnMapper)5 GenTableMapper (com.ruoyi.generator.mapper.GenTableMapper)5 GenUtils (com.ruoyi.generator.util.GenUtils)5 VelocityInitializer (com.ruoyi.generator.util.VelocityInitializer)5 VelocityUtils (com.ruoyi.generator.util.VelocityUtils)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 File (java.io.File)5 StringWriter (java.io.StringWriter)5 HashMap (java.util.HashMap)5