Commit 963ff10a authored by 赵啸非's avatar 赵啸非

添加blob,clob数据库映射

parent b6c04ef0
...@@ -401,7 +401,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge ...@@ -401,7 +401,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
this.save(table); this.save(table);
//保存列 //保存列
List<GentableColumnEntity> genTableColumns = table.getColumns(); List<GentableColumnEntity> genTableColumns = table.getColumns();
//校验是否有主键列,如果没有,默认第一列为主键 //校验是否有主键列,如果没有,默认第一列为主键
GentableColumnEntity columnEntity = genTableColumns.stream().filter(f -> f.getIsPrimaryKey() != null).filter(f -> f.getIsPrimaryKey() == 1).findFirst().orElseGet(() -> null); GentableColumnEntity columnEntity = genTableColumns.stream().filter(f -> f.getIsPrimaryKey() != null).filter(f -> f.getIsPrimaryKey() == 1).findFirst().orElseGet(() -> null);
if (ObjectUtils.isEmpty(columnEntity)) { if (ObjectUtils.isEmpty(columnEntity)) {
...@@ -411,10 +410,10 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge ...@@ -411,10 +410,10 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
} }
for (GentableColumnEntity column : genTableColumns) { for (GentableColumnEntity column : genTableColumns) {
//初始化列数据
GenUtils.initColumnField(column, table); GenUtils.initColumnField(column, table);
gentableColumnService.save(column); gentableColumnService.save(column);
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -57,6 +57,13 @@ public class GenConstants { ...@@ -57,6 +57,13 @@ public class GenConstants {
*/ */
public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
/**
* 数据库blob类型
*/
public static final String[] COLUMNTYPE_BLOB = {"blob", "clob"};
/** /**
* 数据库数字类型 * 数据库数字类型
*/ */
...@@ -166,6 +173,11 @@ public class GenConstants { ...@@ -166,6 +173,11 @@ public class GenConstants {
*/ */
public static final String TYPE_DATE = "Date"; public static final String TYPE_DATE = "Date";
/**
* byte[]类型
*/
public static final String TYPE_BYTEARRAY = "byte[]";
/** /**
* 模糊查询 * 模糊查询
*/ */
......
...@@ -64,8 +64,8 @@ public class GenUtils { ...@@ -64,8 +64,8 @@ public class GenUtils {
Integer htmlType = columnLength >= 255 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? HtmlTypeEnum.HTML_TEXTAREA.getValue() : HtmlTypeEnum.HTML_INPUT.getValue(); Integer htmlType = columnLength >= 255 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? HtmlTypeEnum.HTML_TEXTAREA.getValue() : HtmlTypeEnum.HTML_INPUT.getValue();
column.setHtmlType(htmlType); column.setHtmlType(htmlType);
} else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) { } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
//时间类型
column.setJavaType(GenConstants.TYPE_DATE); column.setJavaType(GenConstants.TYPE_DATE);
column.setHtmlType(HtmlTypeEnum.HTML_DATETIME.getValue()); column.setHtmlType(HtmlTypeEnum.HTML_DATETIME.getValue());
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
column.setHtmlType(HtmlTypeEnum.HTML_INPUT.getValue()); column.setHtmlType(HtmlTypeEnum.HTML_INPUT.getValue());
...@@ -82,6 +82,10 @@ public class GenUtils { ...@@ -82,6 +82,10 @@ public class GenUtils {
else { else {
column.setJavaType(GenConstants.TYPE_LONG); column.setJavaType(GenConstants.TYPE_LONG);
} }
}else if (arraysContains(GenConstants.COLUMNTYPE_BLOB, dataType)) {
//大数据字段
column.setJavaType(GenConstants.TYPE_BYTEARRAY);
column.setHtmlType(HtmlTypeEnum.HTML_TEXTAREA.getValue());
} }
// 插入字段(默认所有字段都需要插入) // 插入字段(默认所有字段都需要插入)
...@@ -92,7 +96,7 @@ public class GenUtils { ...@@ -92,7 +96,7 @@ public class GenUtils {
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && column.getIsPrimaryKey() != YesNo.YES.getValue()) { if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && column.getIsPrimaryKey() != YesNo.YES.getValue()) {
column.setIsEdit(GenConstants.REQUIRE); column.setIsEdit(GenConstants.REQUIRE);
} else { } else {
column.setIsEdit(GenConstants.NOREQUIRE);
} }
} }
// 列表字段 // 列表字段
...@@ -123,13 +127,11 @@ public class GenUtils { ...@@ -123,13 +127,11 @@ public class GenUtils {
checkDict(column, temp1); checkDict(column, temp1);
//checkDict(column, temp2); //checkDict(column, temp2);
if(!ObjectUtils.isEmpty(column.getDict())){ if(!ObjectUtils.isEmpty(column.getDict())){
if(column.getDict().size()>2){ if(column.getDict().size()>2){
column.setHtmlType(HtmlTypeEnum.HTML_SELECT.getValue()); column.setHtmlType(HtmlTypeEnum.HTML_SELECT.getValue());
}else{ }else{
column.setHtmlType(HtmlTypeEnum.HTML_RADIO.getValue()); column.setHtmlType(HtmlTypeEnum.HTML_RADIO.getValue());
} }
//radio //radio
} }
......
...@@ -10,12 +10,12 @@ package ${packageName}.service.impl; ...@@ -10,12 +10,12 @@ package ${packageName}.service.impl;
</#if> </#if>
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.${Service}; import com.mortals.framework.service.impl.${Service};
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import ${packageName}.dao.${ClassName}Dao; import ${packageName}.dao.${ClassName}Dao;
import ${packageName}.model.${ClassName}Entity; import ${packageName}.model.${ClassName}Entity;
import ${packageName}.service.${ClassName}Service; import ${packageName}.service.${ClassName}Service;
<#if table.tplCategory=="sub" || table.tplCategory=="subone"> <#if table.tplCategory=="sub" || table.tplCategory=="subone">
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import ${subPackageName}.model.${subClassName}Entity; import ${subPackageName}.model.${subClassName}Entity;
import ${subPackageName}.model.${subClassName}Query; import ${subPackageName}.model.${subClassName}Query;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment