diff --git a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java index 74d77229..6cb3b652 100644 --- a/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java +++ b/pig-common/pig-common-mybatis/src/main/java/com/pig4cloud/pig/common/mybatis/config/MybatisPlusMetaObjectHandler.java @@ -1,5 +1,6 @@ package com.pig4cloud.pig.common.mybatis.config; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.reflection.MetaObject; @@ -7,6 +8,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.util.ClassUtils; +import java.nio.charset.Charset; import java.time.LocalDateTime; import java.util.Optional; @@ -50,7 +52,8 @@ public class MybatisPlusMetaObjectHandler implements MetaObjectHandler { } // 2. 如果用户有手动设置的值 Object userSetValue = metaObject.getValue(fieldName); - if (userSetValue != null && !isCover) { + String setValueStr = StrUtil.str(userSetValue, Charset.defaultCharset()); + if (StrUtil.isNotBlank(setValueStr) && !isCover) { return; } // 3. field 类型相同时设置 diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java index 721b91e2..2ce74c60 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/support/CodeGenKits.java @@ -147,17 +147,9 @@ public class CodeGenKits { tableEntity.setLowerClassName(StringUtils.uncapitalize(className)); // 获取需要在swagger文档中隐藏的属性字段 List hiddenColumns = config.getList("hiddenColumn"); - // 排除不需要处理的字段 - List excludeColumns = config.getList("excludeColumns"); // 列信息 List columnList = new ArrayList<>(); for (Map column : columns) { - // 判断是否处理 - String columnName = column.get("columnName"); - if (excludeColumns.contains(columnName)) { - continue; - } - ColumnEntity columnEntity = new ColumnEntity(); columnEntity.setColumnName(column.get("columnName")); columnEntity.setDataType(column.get("dataType")); diff --git a/pig-visual/pig-codegen/src/main/resources/generator.properties b/pig-visual/pig-codegen/src/main/resources/generator.properties index 36547b2a..5031d40e 100755 --- a/pig-visual/pig-codegen/src/main/resources/generator.properties +++ b/pig-visual/pig-codegen/src/main/resources/generator.properties @@ -19,16 +19,13 @@ mainPath=com.pig4cloud.pig #\u5305\u540D package=com.pig4cloud.pig -moduleName=generator +moduleName=demo #\u4F5C\u8005 author=pig code generator #\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) tablePrefix=table_ -#\u6392\u9664\u4E0D\u751F\u6210\u7684\u5B57\u6BB5 -excludeColumns=create_time,update_time,create_by,update_by - #\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F tinyint=Integer smallint=Integer diff --git a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm b/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm index d8bb0a0e..c6c14b04 100755 --- a/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/Entity.java.vm @@ -14,7 +14,7 @@ * this software without specific prior written permission. * Author: lengleng (wangiegie@gmail.com) */ - +#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) package ${package}.${moduleName}.entity; import com.baomidou.mybatisplus.annotation.TableId; @@ -27,8 +27,6 @@ import lombok.EqualsAndHashCode; #if(${hasBigDecimal}) import java.math.BigDecimal; #end -import java.io.Serializable; -import java.time.LocalDateTime; /** * ${comments} @@ -41,17 +39,20 @@ import java.time.LocalDateTime; @EqualsAndHashCode(callSuper = true) @ApiModel(value = "${comments}") public class ${className} extends BaseEntity { -private static final long serialVersionUID = 1L; - #foreach ($column in $columns) -/** +#foreach ($column in $columns) +## 排除部分字段 +#if(!$excludeColumns.contains($column.columnName)) + /** * $column.comments */ - #if($column.columnName == $pk.columnName) -@TableId - #end -@ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end) +#if($column.columnName == $pk.columnName) + @TableId +#end + @ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end) private $column.attrType $column.lowerAttrName; - #end + +#end +#end } diff --git a/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm b/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm index 864e3d9e..25c0fa0e 100755 --- a/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/Mapper.xml.vm @@ -24,12 +24,12 @@ - #foreach($column in $columns) - #if($column.lowerAttrName==$pk.lowerAttrName) - - #else - - #end - #end +#foreach($column in $columns) +#if($column.lowerAttrName==$pk.lowerAttrName) + +#else + +#end +#end diff --git a/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm index 39b5d4e3..2d5ce802 100644 --- a/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/avue/crud.js.vm @@ -1,3 +1,5 @@ +#set($excludeColumns = ["create_time","update_time","create_by","update_by"]) + export const tableOption = { "border": true, "index": true, @@ -8,11 +10,22 @@ export const tableOption = { "searchMenuSpan": 6, "column": [ #foreach ($column in $columns) - { +## 当列是主键 或者 列是审计字段时候, 新增不显示,编辑的时候显示单不能编辑 +#if($column.columnName == $pk.columnName || $excludeColumns.contains($column.columnName)) + { + "type": "input", + "label": "$column.comments", + "prop": "$column.lowerAttrName", + "addDisplay": false, + "editDisabled": true + }#if($foreach.hasNext),#end +#else + { "type": "input", "label": "$column.comments", "prop": "$column.lowerAttrName" }#if($foreach.hasNext),#end +#end #end ] } diff --git a/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm b/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm index 928532b0..68767c4b 100755 --- a/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm +++ b/pig-visual/pig-codegen/src/main/resources/template/avue/index.vue.vm @@ -37,8 +37,8 @@