Search in sources :

Example 11 with GenTableColumn

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

the class GenController method columnList.

/**
 * 查询数据表字段列表
 */
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@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.project.tool.gen.domain.GenTableColumn) TableDataInfo(com.ruoyi.framework.web.page.TableDataInfo) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 12 with GenTableColumn

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

the class GenTableServiceImpl method importGenTable.

/**
 * 导入表结构
 *
 * @param tableList 导入表列表
 */
@Override
@Transactional
public void importGenTable(List<GenTable> tableList) {
    String operName = SecurityUtils.getUsername();
    try {
        for (GenTable table : tableList) {
            String tableName = table.getTableName();
            GenUtils.initTable(table, operName);
            int row = genTableMapper.insertGenTable(table);
            if (row > 0) {
                // 保存列信息
                List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
                for (GenTableColumn column : genTableColumns) {
                    GenUtils.initColumnField(column, table);
                    genTableColumnMapper.insertGenTableColumn(column);
                }
            }
        }
    } catch (Exception e) {
        throw new ServiceException("导入失败:" + e.getMessage());
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) GenTable(com.ruoyi.project.tool.gen.domain.GenTable) GenTableColumn(com.ruoyi.project.tool.gen.domain.GenTableColumn) ServiceException(com.ruoyi.common.exception.ServiceException) IOException(java.io.IOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with GenTableColumn

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

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.project.tool.gen.domain.GenTableColumn) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with GenTableColumn

use of com.ruoyi.project.tool.gen.domain.GenTableColumn in project RuoYi-Vue-Oracle 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.project.tool.gen.domain.GenTable) GenTableColumn(com.ruoyi.project.tool.gen.domain.GenTableColumn) HashSet(java.util.HashSet)

Aggregations

GenTableColumn (com.ruoyi.project.tool.gen.domain.GenTableColumn)14 GenTable (com.ruoyi.project.tool.gen.domain.GenTable)8 Transactional (org.springframework.transaction.annotation.Transactional)6 JSONObject (com.alibaba.fastjson.JSONObject)4 ServiceException (com.ruoyi.common.exception.ServiceException)4 IOException (java.io.IOException)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 JSON (com.alibaba.fastjson.JSON)2 Constants (com.ruoyi.common.constant.Constants)2 GenConstants (com.ruoyi.common.constant.GenConstants)2 CharsetKit (com.ruoyi.common.core.text.CharsetKit)2 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)2 StringUtils (com.ruoyi.common.utils.StringUtils)2 TableDataInfo (com.ruoyi.framework.web.page.TableDataInfo)2 GenTableColumnMapper (com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper)2 GenTableMapper (com.ruoyi.project.tool.gen.mapper.GenTableMapper)2 GenUtils (com.ruoyi.project.tool.gen.util.GenUtils)2 VelocityInitializer (com.ruoyi.project.tool.gen.util.VelocityInitializer)2 VelocityUtils (com.ruoyi.project.tool.gen.util.VelocityUtils)2