mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 09:55:16 +08:00
Pre Merge pull request !570 from ZhengJunFeng66/dev
This commit is contained in:
commit
89b861bfc6
@ -1,5 +1,6 @@
|
||||
package org.dromara.generator.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
@ -48,6 +49,7 @@ import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@ -326,6 +328,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
menuIds.add(identifierGenerator.nextId(null).longValue());
|
||||
}
|
||||
//处理图片上传组件回现问题
|
||||
processImageUploadColumns(table);
|
||||
|
||||
table.setMenuIds(menuIds);
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
@ -369,6 +374,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
public void generatorCode(Long tableId) {
|
||||
// 查询表信息
|
||||
GenTable table = baseMapper.selectGenTableById(tableId);
|
||||
//处理图片上传组件回现问题
|
||||
processImageUploadColumns(table);
|
||||
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
|
||||
@ -472,6 +480,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
menuIds.add(identifierGenerator.nextId(null).longValue());
|
||||
}
|
||||
//处理图片上传组件回现问题
|
||||
processImageUploadColumns(table);
|
||||
|
||||
table.setMenuIds(menuIds);
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
@ -574,5 +585,27 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
}
|
||||
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
||||
}
|
||||
/**
|
||||
* 传入数据库行数据,返回添加后数据字段
|
||||
* @param table 表数据
|
||||
*/
|
||||
private void processImageUploadColumns( GenTable table) {
|
||||
List<GenTableColumn> columns = table.getColumns();
|
||||
List<GenTableColumn> newColumns = columns.stream()
|
||||
.filter(column -> GenConstants.HTML_IMAGE_UPLOAD.equals(column.getHtmlType()))
|
||||
.map(column -> {
|
||||
GenTableColumn convert = BeanUtil.copyProperties(column, GenTableColumn.class);
|
||||
convert.setJavaField(column.getJavaField() + "Url");
|
||||
convert.setIsQuery("0");
|
||||
convert.setIsEdit("0");
|
||||
convert.setIsInsert("0");
|
||||
convert.setIsList("1");
|
||||
return convert;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 将新生成的列添加到原始列列表中
|
||||
columns.addAll(newColumns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,9 +40,22 @@ public class ${ClassName} extends ${Entity} {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#set($nonUrlField = "")
|
||||
#if ($column.javaField.endsWith("Url"))
|
||||
#set($nonUrlField = $column.javaField.substring(0, $column.javaField.length() - 3))
|
||||
#foreach ($otherColumn in $columns)
|
||||
#if ($otherColumn.javaField == $nonUrlField)
|
||||
#set($nonUrlField = $nonUrlField)
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if(($column.javaField.endsWith("Url") && $nonUrlField != ""))
|
||||
@TableField("$column.columnName")
|
||||
#end
|
||||
#if($column.javaField=='delFlag')
|
||||
@TableLogic
|
||||
#end
|
||||
|
||||
@ -10,6 +10,8 @@ import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dbn.common.translation.annotation.Translation;
|
||||
import org.dbn.common.translation.constant.TransConstant;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@ -42,6 +44,16 @@ public class ${ClassName}Vo implements Serializable {
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($nonUrlField = "")
|
||||
#if ($column.javaField.endsWith("Url"))
|
||||
#set($nonUrlField = $column.javaField.substring(0, $column.javaField.length() - 3))
|
||||
#foreach ($otherColumn in $columns)
|
||||
#if ($otherColumn.javaField == $nonUrlField)
|
||||
#set($nonUrlField = $nonUrlField)
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "${column.dictType}")
|
||||
@ -51,6 +63,9 @@ public class ${ClassName}Vo implements Serializable {
|
||||
#else
|
||||
@ExcelProperty(value = "${comment}")
|
||||
#end
|
||||
#if(($column.javaField.endsWith("Url") && $nonUrlField != ""))
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL)
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
|
||||
@ -101,11 +101,23 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||
#set($nonUrlField = "")
|
||||
#if ($column.javaField.endsWith("Url"))
|
||||
#set($nonUrlField = $column.javaField.substring(0, $column.javaField.length() - 3))
|
||||
#foreach ($otherColumn in $columns)
|
||||
#if ($otherColumn.javaField == $nonUrlField)
|
||||
#set($nonUrlField = $nonUrlField)
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if(!($column.javaField.endsWith("Url") && $nonUrlField != ""))
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#end
|
||||
#elseif($column.list && $column.dictType && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template #default="scope">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user