update [重大更新]全业务 增加 接口文档注解 格式化代码

This commit is contained in:
疯狂的狮子li
2021-10-15 15:19:42 +08:00
parent bb43b2853d
commit a6fb88d74c
115 changed files with 2600 additions and 2868 deletions

View File

@ -7,67 +7,67 @@ import org.springframework.stereotype.Component;
/**
* 读取代码生成相关配置
*
*
* @author ruoyi
*/
@Component
@ConfigurationProperties(prefix = "gen")
@PropertySource(value = { "classpath:generator.yml" })
public class GenConfig
{
/** 作者 */
@PropertySource(value = {"classpath:generator.yml"})
public class GenConfig {
/**
* 作者
*/
public static String author;
/** 生成包路径 */
/**
* 生成包路径
*/
public static String packageName;
/** 自动去除表前缀默认是false */
/**
* 自动去除表前缀默认是false
*/
public static boolean autoRemovePre;
/** 表前缀(类名不会包含表前缀) */
/**
* 表前缀(类名不会包含表前缀)
*/
public static String tablePrefix;
public static String getAuthor()
{
public static String getAuthor() {
return author;
}
@Value("${author}")
public void setAuthor(String author)
{
public void setAuthor(String author) {
GenConfig.author = author;
}
public static String getPackageName()
{
public static String getPackageName() {
return packageName;
}
@Value("${packageName}")
public void setPackageName(String packageName)
{
public void setPackageName(String packageName) {
GenConfig.packageName = packageName;
}
public static boolean getAutoRemovePre()
{
public static boolean getAutoRemovePre() {
return autoRemovePre;
}
@Value("${autoRemovePre}")
public void setAutoRemovePre(boolean autoRemovePre)
{
public void setAutoRemovePre(boolean autoRemovePre) {
GenConfig.autoRemovePre = autoRemovePre;
}
public static String getTablePrefix()
{
public static String getTablePrefix() {
return tablePrefix;
}
@Value("${tablePrefix}")
public void setTablePrefix(String tablePrefix)
{
public void setTablePrefix(String tablePrefix) {
GenConfig.tablePrefix = tablePrefix;
}
}

View File

@ -10,6 +10,9 @@ import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.service.IGenTableColumnService;
import com.ruoyi.generator.service.IGenTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -24,36 +27,36 @@ import java.util.Map;
/**
* 代码生成 操作处理
*
* @author ruoyi
*
* @author Lion Li
*/
@Validated
@Api(value = "代码生成", tags = {"代码生成管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/tool/gen")
public class GenController extends BaseController
{
@Autowired
private IGenTableService genTableService;
public class GenController extends BaseController {
@Autowired
private IGenTableColumnService genTableColumnService;
private final IGenTableService genTableService;
private final IGenTableColumnService genTableColumnService;
/**
* 查询代码生成列表
*/
@ApiOperation("查询代码生成列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/list")
public TableDataInfo genList(GenTable genTable)
{
public TableDataInfo<GenTable> genList(GenTable genTable) {
return genTableService.selectPageGenTableList(genTable);
}
/**
* 修改代码生成业务
*/
@ApiOperation("修改代码生成业务")
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
@GetMapping(value = "/{talbleId}")
public AjaxResult getInfo(@PathVariable Long talbleId)
{
public AjaxResult<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
GenTable table = genTableService.selectGenTableById(talbleId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
@ -67,21 +70,21 @@ public class GenController extends BaseController
/**
* 查询数据库列表
*/
@ApiOperation("查询数据库列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/db/list")
public TableDataInfo dataList(GenTable genTable)
{
public TableDataInfo<GenTable> dataList(GenTable genTable) {
return genTableService.selectPageDbTableList(genTable);
}
/**
* 查询数据表字段列表
*/
@ApiOperation("查询数据表字段列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping(value = "/column/{talbleId}")
public TableDataInfo columnList(Long tableId)
{
TableDataInfo dataInfo = new TableDataInfo();
public TableDataInfo<GenTableColumn> columnList(Long tableId) {
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
dataInfo.setRows(list);
dataInfo.setTotal(list.size());
@ -91,11 +94,11 @@ public class GenController extends BaseController
/**
* 导入表结构(保存)
*/
@ApiOperation("导入表结构(保存)")
@PreAuthorize("@ss.hasPermi('tool:gen:import')")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
public AjaxResult importTableSave(String tables)
{
public AjaxResult<Void> importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
@ -106,11 +109,11 @@ public class GenController extends BaseController
/**
* 修改保存代码生成业务
*/
@ApiOperation("修改保存代码生成业务")
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
{
public AjaxResult<Void> editSave(@Validated @RequestBody GenTable genTable) {
genTableService.validateEdit(genTable);
genTableService.updateGenTable(genTable);
return AjaxResult.success();
@ -119,11 +122,11 @@ public class GenController extends BaseController
/**
* 删除代码生成
*/
@ApiOperation("删除代码生成")
@PreAuthorize("@ss.hasPermi('tool:gen:remove')")
@Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}")
public AjaxResult remove(@PathVariable Long[] tableIds)
{
public AjaxResult<Void> remove(@PathVariable Long[] tableIds) {
genTableService.deleteGenTableByIds(tableIds);
return AjaxResult.success();
}
@ -131,10 +134,10 @@ public class GenController extends BaseController
/**
* 预览代码
*/
@ApiOperation("预览代码")
@PreAuthorize("@ss.hasPermi('tool:gen:preview')")
@GetMapping("/preview/{tableId}")
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
{
public AjaxResult<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
Map<String, String> dataMap = genTableService.previewCode(tableId);
return AjaxResult.success(dataMap);
}
@ -142,11 +145,11 @@ public class GenController extends BaseController
/**
* 生成代码(下载方式)
*/
@ApiOperation("生成代码(下载方式)")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/download/{tableName}")
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
{
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
byte[] data = genTableService.downloadCode(tableName);
genCode(response, data);
}
@ -154,11 +157,11 @@ public class GenController extends BaseController
/**
* 生成代码(自定义路径)
*/
@ApiOperation("生成代码(自定义路径)")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public AjaxResult genCode(@PathVariable("tableName") String tableName)
{
public AjaxResult<Void> genCode(@PathVariable("tableName") String tableName) {
genTableService.generatorCode(tableName);
return AjaxResult.success();
}
@ -166,11 +169,11 @@ public class GenController extends BaseController
/**
* 同步数据库
*/
@ApiOperation("同步数据库")
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}")
public AjaxResult synchDb(@PathVariable("tableName") String tableName)
{
public AjaxResult<Void> synchDb(@PathVariable("tableName") String tableName) {
genTableService.synchDb(tableName);
return AjaxResult.success();
}
@ -178,11 +181,11 @@ public class GenController extends BaseController
/**
* 批量生成代码
*/
@ApiOperation("批量生成代码")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
public void batchGenCode(HttpServletResponse response, String tables) throws IOException
{
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
String[] tableNames = Convert.toStrArray(tables);
byte[] data = genTableService.downloadCode(tableNames);
genCode(response, data);
@ -191,8 +194,7 @@ public class GenController extends BaseController
/**
* 生成zip文件
*/
private void genCode(HttpServletResponse response, byte[] data) throws IOException
{
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
response.reset();
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");

View File

@ -1,38 +1,36 @@
package com.ruoyi.generator.domain;
import com.ruoyi.common.utils.StringUtils;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.constant.GenConstants;
import lombok.*;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ArrayUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 业务表 gen_table
*
* @author ruoyi
* @author Lion Li
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("gen_table")
public class GenTable implements Serializable {
private static final long serialVersionUID = 1L;
public class GenTable extends BaseEntity {
/**
* 编号
*/
@TableId(value = "table_id", type = IdType.AUTO)
@TableId(value = "table_id")
private Long tableId;
/**
@ -132,43 +130,11 @@ public class GenTable implements Serializable {
*/
private String options;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
/**
* 请求参数
*/
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
/**
* 树编码字段
*/

View File

@ -1,34 +1,33 @@
package com.ruoyi.generator.domain;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 代码生成业务字段表 gen_table_column
*
* @author ruoyi
* @author Lion Li
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("gen_table_column")
public class GenTableColumn implements Serializable {
private static final long serialVersionUID = 1L;
public class GenTableColumn extends BaseEntity {
/**
* 编号
*/
@TableId(value = "column_id", type = IdType.AUTO)
@TableId(value = "column_id")
private Long columnId;
/**
@ -125,38 +124,6 @@ public class GenTableColumn implements Serializable {
*/
private Integer sort;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 请求参数
*/
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
public String getCapJavaField() {
return StringUtils.uncapitalize(javaField);
}
@ -224,9 +191,9 @@ public class GenTableColumn implements Serializable {
public static boolean isSuperColumn(String javaField) {
return StringUtils.equalsAnyIgnoreCase(javaField,
// BaseEntity
"createBy", "createTime", "updateBy", "updateTime", "remark",
"createBy", "createTime", "updateBy", "updateTime",
// TreeEntity
"parentName", "parentId", "orderNum", "ancestors");
"parentName", "parentId", "orderNum");
}
public boolean isUsableColumn() {

View File

@ -8,7 +8,7 @@ import java.util.List;
/**
* 业务字段 数据层
*
* @author ruoyi
* @author Lion Li
*/
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> {
/**
@ -17,6 +17,6 @@ public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> {
* @param tableName 表名称
* @return 列信息
*/
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
List<GenTableColumn> selectDbTableColumnsByName(String tableName);
}

View File

@ -10,7 +10,7 @@ import java.util.List;
/**
* 业务 数据层
*
* @author ruoyi
* @author Lion Li
*/
public interface GenTableMapper extends BaseMapperPlus<GenTable> {
@ -25,7 +25,7 @@ public interface GenTableMapper extends BaseMapperPlus<GenTable> {
* @param genTable 业务信息
* @return 业务集合
*/
public List<GenTable> selectGenTableList(GenTable genTable);
List<GenTable> selectGenTableList(GenTable genTable);
/**
* 查询据库列表
@ -33,7 +33,7 @@ public interface GenTableMapper extends BaseMapperPlus<GenTable> {
* @param genTable 业务信息
* @return 数据库表集合
*/
public List<GenTable> selectDbTableList(GenTable genTable);
List<GenTable> selectDbTableList(GenTable genTable);
/**
* 查询据库列表
@ -41,14 +41,14 @@ public interface GenTableMapper extends BaseMapperPlus<GenTable> {
* @param tableNames 表名称组
* @return 数据库表集合
*/
public List<GenTable> selectDbTableListByNames(String[] tableNames);
List<GenTable> selectDbTableListByNames(String[] tableNames);
/**
* 查询所有表信息
*
* @return 表信息集合
*/
public List<GenTable> selectGenTableAll();
List<GenTable> selectGenTableAll();
/**
* 查询表ID业务信息
@ -56,7 +56,7 @@ public interface GenTableMapper extends BaseMapperPlus<GenTable> {
* @param id 业务ID
* @return 业务信息
*/
public GenTable selectGenTableById(Long id);
GenTable selectGenTableById(Long id);
/**
* 查询表名称业务信息
@ -64,6 +64,6 @@ public interface GenTableMapper extends BaseMapperPlus<GenTable> {
* @param tableName 表名称
* @return 业务信息
*/
public GenTable selectGenTableByName(String tableName);
GenTable selectGenTableByName(String tableName);
}

View File

@ -12,7 +12,7 @@ import java.util.List;
/**
* 业务字段 服务层实现
*
* @author ruoyi
* @author Lion Li
*/
@Service
public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMapper, GenTableColumn, GenTableColumn> implements IGenTableColumnService {
@ -26,7 +26,7 @@ public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMap
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
return list(new LambdaQueryWrapper<GenTableColumn>()
.eq(GenTableColumn::getTableId,tableId)
.eq(GenTableColumn::getTableId, tableId)
.orderByAsc(GenTableColumn::getSort));
}

View File

@ -41,7 +41,7 @@ import java.util.zip.ZipOutputStream;
/**
* 业务 服务层实现
*
* @author ruoyi
* @author Lion Li
*/
@Slf4j
@Service
@ -163,18 +163,18 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
String tableName = table.getTableName();
GenUtils.initTable(table, operName);
int row = baseMapper.insert(table);
if (row > 0) {
// 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
List<GenTableColumn> saveColumns = new ArrayList<>();
for (GenTableColumn column : genTableColumns) {
GenUtils.initColumnField(column, table);
saveColumns.add(column);
}
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
}
}
if (row > 0) {
// 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
List<GenTableColumn> saveColumns = new ArrayList<>();
for (GenTableColumn column : genTableColumns) {
GenUtils.initColumnField(column, table);
saveColumns.add(column);
}
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
}
}
}
} catch (Exception e) {
throw new ServiceException("导入失败:" + e.getMessage());
@ -253,12 +253,12 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw);
try {
String path = getGenPath(table, template);
FileUtils.writeUtf8String(sw.toString(), path);
} catch (Exception e) {
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
}
try {
String path = getGenPath(table, template);
FileUtils.writeUtf8String(sw.toString(), path);
} catch (Exception e) {
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
}
}
}
}
@ -281,16 +281,16 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
}
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
List<GenTableColumn> saveColumns = new ArrayList<>();
dbTableColumns.forEach(column -> {
if (!tableColumnNames.contains(column.getColumnName())) {
GenUtils.initColumnField(column, table);
saveColumns.add(column);
}
});
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
}
List<GenTableColumn> saveColumns = new ArrayList<>();
dbTableColumns.forEach(column -> {
if (!tableColumnNames.contains(column.getColumnName())) {
GenUtils.initColumnField(column, table);
saveColumns.add(column);
}
});
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
}
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(delColumns)) {
@ -359,7 +359,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
@Override
public void validateEdit(GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
Map<String, Object> paramsObj = genTable.getParams();
Map<String, Object> paramsObj = genTable.getParams();
if (StringUtils.isEmpty(paramsObj.get(GenConstants.TREE_CODE))) {
throw new ServiceException("树编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.get(GenConstants.TREE_PARENT_CODE))) {
@ -422,7 +422,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
* @param genTable 设置后的生成对象
*/
public void setTableFromOptions(GenTable genTable) {
Map<String, Object> paramsObj = JsonUtils.parseMap(genTable.getOptions());
Map<String, Object> paramsObj = JsonUtils.parseMap(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj)) {
String treeCode = Convert.toStr(paramsObj.get(GenConstants.TREE_CODE));
String treeParentCode = Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE));
@ -441,7 +441,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
/**
* 获取代码生成地址
*
* @param table 业务表信息
* @param table 业务表信息
* @param template 模板文件路径
* @return 生成地址
*/

View File

@ -8,7 +8,7 @@ import java.util.List;
/**
* 业务字段 服务层
*
* @author ruoyi
* @author Lion Li
*/
public interface IGenTableColumnService extends IService<GenTableColumn> {
/**
@ -17,7 +17,7 @@ public interface IGenTableColumnService extends IService<GenTableColumn> {
* @param tableId 业务字段编号
* @return 业务字段集合
*/
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
* 新增业务字段
@ -25,7 +25,7 @@ public interface IGenTableColumnService extends IService<GenTableColumn> {
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int insertGenTableColumn(GenTableColumn genTableColumn);
int insertGenTableColumn(GenTableColumn genTableColumn);
/**
* 修改业务字段
@ -33,7 +33,7 @@ public interface IGenTableColumnService extends IService<GenTableColumn> {
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int updateGenTableColumn(GenTableColumn genTableColumn);
int updateGenTableColumn(GenTableColumn genTableColumn);
/**
* 删除业务字段信息
@ -41,5 +41,5 @@ public interface IGenTableColumnService extends IService<GenTableColumn> {
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteGenTableColumnByIds(String ids);
int deleteGenTableColumnByIds(String ids);
}

View File

@ -10,7 +10,7 @@ import java.util.Map;
/**
* 业务 服务层
*
* @author ruoyi
* @author Lion Li
*/
public interface IGenTableService extends IService<GenTable> {
@ -26,7 +26,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param genTable 业务信息
* @return 业务集合
*/
public List<GenTable> selectGenTableList(GenTable genTable);
List<GenTable> selectGenTableList(GenTable genTable);
/**
* 查询据库列表
@ -34,7 +34,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param genTable 业务信息
* @return 数据库表集合
*/
public List<GenTable> selectDbTableList(GenTable genTable);
List<GenTable> selectDbTableList(GenTable genTable);
/**
* 查询据库列表
@ -42,14 +42,14 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableNames 表名称组
* @return 数据库表集合
*/
public List<GenTable> selectDbTableListByNames(String[] tableNames);
List<GenTable> selectDbTableListByNames(String[] tableNames);
/**
* 查询所有表信息
*
* @return 表信息集合
*/
public List<GenTable> selectGenTableAll();
List<GenTable> selectGenTableAll();
/**
* 查询业务信息
@ -57,7 +57,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param id 业务ID
* @return 业务信息
*/
public GenTable selectGenTableById(Long id);
GenTable selectGenTableById(Long id);
/**
* 修改业务
@ -65,7 +65,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param genTable 业务信息
* @return 结果
*/
public void updateGenTable(GenTable genTable);
void updateGenTable(GenTable genTable);
/**
* 删除业务信息
@ -73,14 +73,14 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableIds 需要删除的表数据ID
* @return 结果
*/
public void deleteGenTableByIds(Long[] tableIds);
void deleteGenTableByIds(Long[] tableIds);
/**
* 导入表结构
*
* @param tableList 导入表列表
*/
public void importGenTable(List<GenTable> tableList);
void importGenTable(List<GenTable> tableList);
/**
* 预览代码
@ -88,7 +88,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableId 表编号
* @return 预览数据列表
*/
public Map<String, String> previewCode(Long tableId);
Map<String, String> previewCode(Long tableId);
/**
* 生成代码(下载方式)
@ -96,7 +96,7 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableName 表名称
* @return 数据
*/
public byte[] downloadCode(String tableName);
byte[] downloadCode(String tableName);
/**
* 生成代码(自定义路径)
@ -104,14 +104,14 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableName 表名称
* @return 数据
*/
public void generatorCode(String tableName);
void generatorCode(String tableName);
/**
* 同步数据库
*
* @param tableName 表名称
*/
public void synchDb(String tableName);
void synchDb(String tableName);
/**
* 批量生成代码(下载方式)
@ -119,12 +119,12 @@ public interface IGenTableService extends IService<GenTable> {
* @param tableNames 表数组
* @return 数据
*/
public byte[] downloadCode(String[] tableNames);
byte[] downloadCode(String[] tableNames);
/**
* 修改保存参数校验
*
* @param genTable 业务信息
*/
public void validateEdit(GenTable genTable);
void validateEdit(GenTable genTable);
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.generator.util;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.config.GenConfig;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
@ -14,13 +14,12 @@ import java.util.Arrays;
*
* @author ruoyi
*/
public class GenUtils
{
public class GenUtils {
/**
* 初始化表信息
*/
public static void initTable(GenTable genTable, String operName)
{
public static void initTable(GenTable genTable, String operName) {
genTable.setClassName(convertClassName(genTable.getTableName()));
genTable.setPackageName(GenConfig.getPackageName());
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
@ -74,55 +73,45 @@ public class GenUtils
column.setIsInsert(GenConstants.REQUIRE);
}
// BO对象 默认编辑勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName))
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
column.setIsEdit(GenConstants.REQUIRE);
}
// BO对象 默认是否必填勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName))
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
column.setIsRequired(GenConstants.REQUIRE);
}
// VO对象 默认返回勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName))
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) {
column.setIsList(GenConstants.REQUIRE);
}
// BO对象 默认查询勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
{
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
column.setIsQuery(GenConstants.REQUIRE);
}
// 查询字段类型
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
{
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
column.setQueryType(GenConstants.QUERY_LIKE);
}
// 状态字段设置单选框
if (StringUtils.endsWithIgnoreCase(columnName, "status"))
{
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
column.setHtmlType(GenConstants.HTML_RADIO);
}
// 类型&性别字段设置下拉框
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
{
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
column.setHtmlType(GenConstants.HTML_SELECT);
}
// 图片字段设置图片上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
{
else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
}
// 文件字段设置文件上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
{
else if (StringUtils.endsWithIgnoreCase(columnName, "file")) {
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
}
// 内容字段设置富文本控件
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
{
else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
column.setHtmlType(GenConstants.HTML_EDITOR);
}
}
@ -130,12 +119,11 @@ public class GenUtils
/**
* 校验数组是否包含指定值
*
* @param arr 数组
* @param arr 数组
* @param targetValue 值
* @return 是否包含
*/
public static boolean arraysContains(String[] arr, String targetValue)
{
public static boolean arraysContains(String[] arr, String targetValue) {
return Arrays.asList(arr).contains(targetValue);
}
@ -145,8 +133,7 @@ public class GenUtils
* @param packageName 包名
* @return 模块名
*/
public static String getModuleName(String packageName)
{
public static String getModuleName(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length();
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
@ -159,12 +146,11 @@ public class GenUtils
* @param tableName 表名
* @return 业务名
*/
public static String getBusinessName(String tableName)
{
public static String getBusinessName(String tableName) {
int firstIndex = tableName.indexOf("_");
int nameLength = tableName.length();
String businessName = StringUtils.substring(tableName, firstIndex + 1, nameLength);
businessName = StringUtils.toCamelCase(businessName);
businessName = StringUtils.toCamelCase(businessName);
return businessName;
}
@ -174,12 +160,10 @@ public class GenUtils
* @param tableName 表名称
* @return 类名
*/
public static String convertClassName(String tableName)
{
public static String convertClassName(String tableName) {
boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
{
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
String[] searchList = StringUtils.split(tablePrefix, ",");
tableName = replaceFirst(tableName, searchList);
}
@ -190,16 +174,13 @@ public class GenUtils
* 批量替换前缀
*
* @param replacementm 替换值
* @param searchList 替换列表
* @param searchList 替换列表
* @return
*/
public static String replaceFirst(String replacementm, String[] searchList)
{
public static String replaceFirst(String replacementm, String[] searchList) {
String text = replacementm;
for (String searchString : searchList)
{
if (replacementm.startsWith(searchString))
{
for (String searchString : searchList) {
if (replacementm.startsWith(searchString)) {
text = replacementm.replaceFirst(searchString, "");
break;
}
@ -213,8 +194,7 @@ public class GenUtils
* @param text 需要被替换的名字
* @return 替换后的名字
*/
public static String replaceText(String text)
{
public static String replaceText(String text) {
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
}
@ -224,14 +204,10 @@ public class GenUtils
* @param columnType 列类型
* @return 截取后的列类型
*/
public static String getDbType(String columnType)
{
if (StringUtils.indexOf(columnType, '(') > 0)
{
public static String getDbType(String columnType) {
if (StringUtils.indexOf(columnType, '(') > 0) {
return StringUtils.substringBefore(columnType, "(");
}
else
{
} else {
return columnType;
}
}
@ -242,15 +218,11 @@ public class GenUtils
* @param columnType 列类型
* @return 截取后的列类型
*/
public static Integer getColumnLength(String columnType)
{
if (StringUtils.indexOf(columnType, '(') > 0)
{
public static Integer getColumnLength(String columnType) {
if (StringUtils.indexOf(columnType, '(') > 0) {
String length = StringUtils.substringBetween(columnType, "(", ")");
return Integer.valueOf(length);
}
else
{
} else {
return 0;
}
}

View File

@ -1,24 +1,23 @@
package com.ruoyi.generator.util;
import java.util.Properties;
import org.apache.velocity.app.Velocity;
import com.ruoyi.common.constant.Constants;
import org.apache.velocity.app.Velocity;
import java.util.Properties;
/**
* VelocityEngine工厂
*
*
* @author ruoyi
*/
public class VelocityInitializer
{
public class VelocityInitializer {
/**
* 初始化vm方法
*/
public static void initVelocity()
{
public static void initVelocity() {
Properties p = new Properties();
try
{
try {
// 加载classpath目录下的vm文件
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
// 定义字符集
@ -26,10 +25,9 @@ public class VelocityInitializer
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
// 初始化Velocity引擎指定配置Properties
Velocity.init(p);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -16,18 +16,24 @@ import java.util.Map;
/**
* 模板处理工具类
*
*
* @author ruoyi
*/
public class VelocityUtils
{
/** 项目空间路径 */
public class VelocityUtils {
/**
* 项目空间路径
*/
private static final String PROJECT_PATH = "main/java";
/** mybatis空间路径 */
/**
* mybatis空间路径
*/
private static final String MYBATIS_PATH = "main/resources/mapper";
/** 默认上级菜单,系统工具 */
/**
* 默认上级菜单,系统工具
*/
private static final String DEFAULT_PARENT_MENU_ID = "3";
/**
@ -35,8 +41,7 @@ public class VelocityUtils
*
* @return 模板列表
*/
public static VelocityContext prepareContext(GenTable genTable)
{
public static VelocityContext prepareContext(GenTable genTable) {
String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName();
@ -63,29 +68,25 @@ public class VelocityUtils
velocityContext.put("table", genTable);
velocityContext.put("dicts", getDicts(genTable));
setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory))
{
if (GenConstants.TPL_TREE.equals(tplCategory)) {
setTreeVelocityContext(velocityContext, genTable);
}
if (GenConstants.TPL_SUB.equals(tplCategory))
{
if (GenConstants.TPL_SUB.equals(tplCategory)) {
setSubVelocityContext(velocityContext, genTable);
}
return velocityContext;
}
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId);
}
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
String treeCode = getTreecode(paramsObj);
String treeParentCode = getTreeParentCode(paramsObj);
String treeName = getTreeName(paramsObj);
@ -94,18 +95,15 @@ public class VelocityUtils
context.put("treeParentCode", treeParentCode);
context.put("treeName", treeName);
context.put("expandColumn", getExpandColumn(genTable));
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
context.put("tree_parent_code", paramsObj.get(GenConstants.TREE_PARENT_CODE));
}
if (paramsObj.containsKey(GenConstants.TREE_NAME))
{
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
context.put("tree_name", paramsObj.get(GenConstants.TREE_NAME));
}
}
public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName();
@ -127,12 +125,11 @@ public class VelocityUtils
*
* @return 模板列表
*/
public static List<String> getTemplateList(String tplCategory)
{
public static List<String> getTemplateList(String tplCategory) {
List<String> templates = new ArrayList<String>();
templates.add("vm/java/domain.java.vm");
templates.add("vm/java/vo.java.vm");
templates.add("vm/java/bo.java.vm");
templates.add("vm/java/bo.java.vm");
templates.add("vm/java/mapper.java.vm");
templates.add("vm/java/service.java.vm");
templates.add("vm/java/serviceImpl.java.vm");
@ -140,16 +137,11 @@ public class VelocityUtils
templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/sql/sql.vm");
templates.add("vm/js/api.js.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
templates.add("vm/vue/index.vue.vm");
}
else if (GenConstants.TPL_TREE.equals(tplCategory))
{
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
templates.add("vm/vue/index-tree.vue.vm");
}
else if (GenConstants.TPL_SUB.equals(tplCategory))
{
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
templates.add("vm/vue/index.vue.vm");
templates.add("vm/java/sub-domain.java.vm");
}
@ -159,8 +151,7 @@ public class VelocityUtils
/**
* 获取文件名
*/
public static String getFileName(String template, GenTable genTable)
{
public static String getFileName(String template, GenTable genTable) {
// 文件名称
String fileName = "";
// 包路径
@ -176,56 +167,34 @@ public class VelocityUtils
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String vuePath = "vue";
if (template.contains("domain.java.vm"))
{
if (template.contains("domain.java.vm")) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
}
if (template.contains("vo.java.vm"))
{
if (template.contains("vo.java.vm")) {
fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className);
}
if (template.contains("bo.java.vm"))
{
fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className);
}
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
{
if (template.contains("bo.java.vm")) {
fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className);
}
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
}
else if (template.contains("mapper.java.vm"))
{
} else if (template.contains("mapper.java.vm")) {
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
}
else if (template.contains("service.java.vm"))
{
} else if (template.contains("service.java.vm")) {
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
}
else if (template.contains("serviceImpl.java.vm"))
{
} else if (template.contains("serviceImpl.java.vm")) {
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
}
else if (template.contains("controller.java.vm"))
{
} else if (template.contains("controller.java.vm")) {
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
}
else if (template.contains("mapper.xml.vm"))
{
} else if (template.contains("mapper.xml.vm")) {
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
}
else if (template.contains("sql.vm"))
{
} else if (template.contains("sql.vm")) {
fileName = businessName + "Menu.sql";
}
else if (template.contains("api.js.vm"))
{
} else if (template.contains("api.js.vm")) {
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
}
else if (template.contains("index.vue.vm"))
{
} else if (template.contains("index.vue.vm")) {
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
else if (template.contains("index-tree.vue.vm"))
{
} else if (template.contains("index-tree.vue.vm")) {
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
return fileName;
@ -237,8 +206,7 @@ public class VelocityUtils
* @param packageName 包名称
* @return 包前缀名称
*/
public static String getPackagePrefix(String packageName)
{
public static String getPackagePrefix(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
return basePackage;
@ -246,28 +214,22 @@ public class VelocityUtils
/**
* 根据列类型获取导入包
*
*
* @param genTable 业务表对象
* @return 返回需要导入的包列表
*/
public static HashSet<String> getImportList(GenTable genTable)
{
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))
{
if (StringUtils.isNotNull(subGenTable)) {
importList.add("java.util.List");
}
for (GenTableColumn column : columns)
{
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
{
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()))
{
} else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
importList.add("java.math.BigDecimal");
}
}
@ -280,15 +242,12 @@ public class VelocityUtils
* @param genTable 业务表对象
* @return 返回字典组
*/
public static String getDicts(GenTable genTable)
{
public static String getDicts(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns();
List<String> dicts = new ArrayList<String>();
for (GenTableColumn column : columns)
{
for (GenTableColumn column : columns) {
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
column.getHtmlType(), new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO }))
{
column.getHtmlType(), new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO})) {
dicts.add("'" + column.getDictType() + "'");
}
}
@ -298,12 +257,11 @@ public class VelocityUtils
/**
* 获取权限前缀
*
* @param moduleName 模块名称
* @param moduleName 模块名称
* @param businessName 业务名称
* @return 返回权限前缀
*/
public static String getPermissionPrefix(String moduleName, String businessName)
{
public static String getPermissionPrefix(String moduleName, String businessName) {
return StringUtils.format("{}:{}", moduleName, businessName);
}
@ -313,11 +271,9 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @return 上级菜单ID字段
*/
public static String getParentMenuId(Map<String, Object> paramsObj)
{
public static String getParentMenuId(Map<String, Object> paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
&& StringUtils.isNotEmpty(Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID))))
{
&& StringUtils.isNotEmpty(Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)))) {
return Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID));
}
return DEFAULT_PARENT_MENU_ID;
@ -329,10 +285,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @return 树编码
*/
public static String getTreecode(Map<String, Object> paramsObj)
{
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_CODE))
{
public static String getTreecode(Map<String, Object> paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_CODE)) {
return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_CODE)));
}
return StringUtils.EMPTY;
@ -344,10 +298,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @return 树父编码
*/
public static String getTreeParentCode(Map<String, Object> paramsObj)
{
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
public static String getTreeParentCode(Map<String, Object> paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE)));
}
return StringUtils.EMPTY;
@ -359,10 +311,8 @@ public class VelocityUtils
* @param paramsObj 生成其他选项
* @return 树名称
*/
public static String getTreeName(Map<String, Object> paramsObj)
{
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME))
{
public static String getTreeName(Map<String, Object> paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME)) {
return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_NAME)));
}
return StringUtils.EMPTY;
@ -374,20 +324,16 @@ public class VelocityUtils
* @param genTable 业务表对象
* @return 展开按钮列序号
*/
public static int getExpandColumn(GenTable genTable)
{
public static int getExpandColumn(GenTable genTable) {
String options = genTable.getOptions();
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
String treeName = Convert.toStr(paramsObj.get(GenConstants.TREE_NAME));
int num = 0;
for (GenTableColumn column : genTable.getColumns())
{
if (column.isList())
{
for (GenTableColumn column : genTable.getColumns()) {
if (column.isList()) {
num++;
String columnName = column.getColumnName();
if (columnName.equals(treeName))
{
if (columnName.equals(treeName)) {
break;
}
}