Search in sources :

Example 1 with GenTableColumn

use of com.ruoyi.gen.domain.GenTableColumn in project RuoYi-Cloud by yangzongzhuan.

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.gen.domain.GenTableColumn)

Example 2 with GenTableColumn

use of com.ruoyi.gen.domain.GenTableColumn in project RuoYi-Cloud by yangzongzhuan.

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.gen.domain.GenTable) GenTableColumn(com.ruoyi.gen.domain.GenTableColumn) HashSet(java.util.HashSet)

Example 3 with GenTableColumn

use of com.ruoyi.gen.domain.GenTableColumn in project RuoYi-Cloud by yangzongzhuan.

the class GenController method columnList.

/**
 * 查询数据表字段列表
 */
@GetMapping(value = "/column/{tableId}")
public TableDataInfo columnList(Long tableId) {
    TableDataInfo dataInfo = new TableDataInfo();
    List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
    dataInfo.setRows(list);
    dataInfo.setTotal(list.size());
    return dataInfo;
}
Also used : GenTableColumn(com.ruoyi.gen.domain.GenTableColumn) TableDataInfo(com.ruoyi.common.core.web.page.TableDataInfo) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with GenTableColumn

use of com.ruoyi.gen.domain.GenTableColumn in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class GenController method getInfo.

/**
 * 修改代码生成业务
 */
@RequiresPermissions("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.gen.domain.GenTable) HashMap(java.util.HashMap) GenTableColumn(com.ruoyi.gen.domain.GenTableColumn) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with GenTableColumn

use of com.ruoyi.gen.domain.GenTableColumn in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class GenTableServiceImpl method updateGenTable.

/**
 * 修改业务
 *
 * @param genTable 业务信息
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
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.gen.domain.GenTableColumn) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GenTableColumn (com.ruoyi.gen.domain.GenTableColumn)20 GenTable (com.ruoyi.gen.domain.GenTable)12 ServiceException (com.ruoyi.common.core.exception.ServiceException)6 IOException (java.io.IOException)6 Transactional (org.springframework.transaction.annotation.Transactional)6 JSONObject (com.alibaba.fastjson.JSONObject)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 Constants (com.ruoyi.common.core.constant.Constants)3 GenConstants (com.ruoyi.common.core.constant.GenConstants)3 StringUtils (com.ruoyi.common.core.utils.StringUtils)3 GenTableColumnMapper (com.ruoyi.gen.mapper.GenTableColumnMapper)3 GenTableMapper (com.ruoyi.gen.mapper.GenTableMapper)3 GenUtils (com.ruoyi.gen.util.GenUtils)3 VelocityInitializer (com.ruoyi.gen.util.VelocityInitializer)3 VelocityUtils (com.ruoyi.gen.util.VelocityUtils)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 File (java.io.File)3 StringWriter (java.io.StringWriter)3 HashMap (java.util.HashMap)3 Function (java.util.function.Function)3