diff --git a/src/main/java/com/example/demo/common/config/orm/listener/FlexListener.java b/src/main/java/com/example/demo/common/config/orm/listener/FlexListener.java index 900bdbf..9df3ff4 100644 --- a/src/main/java/com/example/demo/common/config/orm/listener/FlexListener.java +++ b/src/main/java/com/example/demo/common/config/orm/listener/FlexListener.java @@ -1,6 +1,7 @@ package com.example.demo.common.config.orm.listener; import com.mybatisflex.annotation.InsertListener; +import com.mybatisflex.annotation.SetListener; import com.mybatisflex.annotation.UpdateListener; import com.example.demo.common.domain.BaseEntity; import lombok.extern.slf4j.Slf4j; @@ -15,7 +16,7 @@ import java.util.Date; * @version 1.0.0 */ @Slf4j -public class FlexListener implements InsertListener, UpdateListener { +public class FlexListener implements InsertListener, UpdateListener, SetListener { /** * 插入前监听 @@ -53,4 +54,9 @@ public class FlexListener implements InsertListener, UpdateListener { baseEntity.setUpdatedTime(new Date()); } } + + @Override + public Object onSet(Object entity, String property, Object value) { + return value; + } } \ No newline at end of file diff --git a/src/main/java/com/example/demo/common/domain/BaseEntity.java b/src/main/java/com/example/demo/common/domain/BaseEntity.java index d28aaee..9589305 100644 --- a/src/main/java/com/example/demo/common/domain/BaseEntity.java +++ b/src/main/java/com/example/demo/common/domain/BaseEntity.java @@ -1,6 +1,5 @@ package com.example.demo.common.domain; -import com.example.demo.common.config.orm.handler.SqliteDateTypeHandler; import com.example.demo.common.config.orm.listener.FlexListener; import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; @@ -33,7 +32,13 @@ import java.util.Date; @Accessors(chain=true) @NoArgsConstructor @AllArgsConstructor -@Table(value = "demo", onInsert = FlexListener.class, onUpdate = FlexListener.class) +@Table( + value = "", + comment = "基本类没有对应的表!", + onInsert = FlexListener.class, + onUpdate = FlexListener.class, + onSet = FlexListener.class +) public class BaseEntity implements Serializable { @Serial @@ -81,10 +86,6 @@ public class BaseEntity implements Serializable { * Column(onInsertValue = "datetime('now', 'localtime')") */ // @Column(onInsertValue = "datetime('now', 'localtime')") - /** - * 创建时间 - */ - @com.mybatisflex.annotation.Column(typeHandler = SqliteDateTypeHandler.class) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @Schema(description = "创建时间") @@ -105,10 +106,6 @@ public class BaseEntity implements Serializable { * Column(onUpdateValue = "datetime('now', 'localtime')", onInsertValue = "datetime('now', 'localtime')") */ // @Column(onUpdateValue = "datetime('now', 'localtime')", onInsertValue = "datetime('now', 'localtime')") - /** - * 更新时间 - */ - @com.mybatisflex.annotation.Column(typeHandler = SqliteDateTypeHandler.class) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @Schema(description = "更新时间") diff --git a/src/main/java/com/example/demo/common/domain/BaseVO.java b/src/main/java/com/example/demo/common/domain/BaseVO.java index eb0c4df..0583f14 100644 --- a/src/main/java/com/example/demo/common/domain/BaseVO.java +++ b/src/main/java/com/example/demo/common/domain/BaseVO.java @@ -1,6 +1,6 @@ package com.example.demo.common.domain; -import com.mybatisflex.annotation.Column; +import cn.zhxu.bs.bean.DbIgnore; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import com.fasterxml.jackson.annotation.JsonFormat; @@ -39,13 +39,15 @@ public class BaseVO implements Serializable { /** * 键 */ - @Schema(description = "key") + @DbIgnore + @Schema(description = "键") private String key; /** * 名称 */ - @Schema(description = "name") + @DbIgnore + @Schema(description = "名称") private String name; /** @@ -58,6 +60,7 @@ public class BaseVO implements Serializable { /** * 创建人ID */ + @DbIgnore @Schema(description = "创建人ID") private String createdId; @@ -71,6 +74,7 @@ public class BaseVO implements Serializable { /** * 更新人ID */ + @DbIgnore @Schema(description = "更新人ID") private String updatedId; diff --git a/src/main/java/com/example/demo/parser/entity/FileRecordEntity.java b/src/main/java/com/example/demo/parser/entity/FileRecordEntity.java index d437ed5..6883089 100644 --- a/src/main/java/com/example/demo/parser/entity/FileRecordEntity.java +++ b/src/main/java/com/example/demo/parser/entity/FileRecordEntity.java @@ -26,7 +26,11 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) -@Table(value = "file_record", onInsert = FlexListener.class, onUpdate = FlexListener.class) +@Table(value = "file_record", + onInsert = FlexListener.class, + onUpdate = FlexListener.class, + onSet = FlexListener.class +) public class FileRecordEntity extends BaseEntity { @Serial diff --git a/src/main/java/com/example/demo/parser/entity/MapperRuleEntity.java b/src/main/java/com/example/demo/parser/entity/MapperRuleEntity.java index 4077c5e..16bb503 100644 --- a/src/main/java/com/example/demo/parser/entity/MapperRuleEntity.java +++ b/src/main/java/com/example/demo/parser/entity/MapperRuleEntity.java @@ -25,7 +25,11 @@ import java.io.Serial; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) -@Table(value = "mapper_rule", onInsert = FlexListener.class, onUpdate = FlexListener.class) +@Table(value = "mapper_rule", + onInsert = FlexListener.class, + onUpdate = FlexListener.class, + onSet = FlexListener.class +) public class MapperRuleEntity extends BaseEntity { @Serial diff --git a/src/main/java/com/example/demo/parser/entity/ParseRuleEntity.java b/src/main/java/com/example/demo/parser/entity/ParseRuleEntity.java index 9bdcf26..e63ad5c 100644 --- a/src/main/java/com/example/demo/parser/entity/ParseRuleEntity.java +++ b/src/main/java/com/example/demo/parser/entity/ParseRuleEntity.java @@ -25,7 +25,11 @@ import java.io.Serial; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) -@Table(value = "parse_rule", onInsert = FlexListener.class, onUpdate = FlexListener.class) +@Table(value = "parse_rule", + onInsert = FlexListener.class, + onUpdate = FlexListener.class, + onSet = FlexListener.class +) public class ParseRuleEntity extends BaseEntity { @Serial diff --git a/src/main/java/com/example/demo/parser/model/vo/ParseRuleVO.java b/src/main/java/com/example/demo/parser/model/vo/ParseRuleVO.java index 01b3aa6..338bff1 100644 --- a/src/main/java/com/example/demo/parser/model/vo/ParseRuleVO.java +++ b/src/main/java/com/example/demo/parser/model/vo/ParseRuleVO.java @@ -27,7 +27,7 @@ import java.io.Serializable; @AllArgsConstructor @EqualsAndHashCode(callSuper = true) @SearchBean( - tables = "parse_rule", + tables = "parse_rule a", autoMapTo = "a" ) public class ParseRuleVO extends BaseVO implements TransPojo, Serializable { diff --git a/src/main/resources/application-mysql.yml b/src/main/resources/application-mysql.yml index e69de29..6df0114 100644 --- a/src/main/resources/application-mysql.yml +++ b/src/main/resources/application-mysql.yml @@ -0,0 +1,3 @@ +bean-searcher: + sql: + dialect: mysql diff --git a/src/main/resources/application-orm.yml b/src/main/resources/application-orm.yml index 0effd88..b25f498 100644 --- a/src/main/resources/application-orm.yml +++ b/src/main/resources/application-orm.yml @@ -1,14 +1,22 @@ # Bean-Searcher 配置 bean-searcher: sql: + # dialect: mysql default-mapping: #表名和字段名是否驼峰转小写下划线(since v3.7.0) underline-case: true #表名和字段名是否大写 - upper-case: true + upper-case: false redundant-suffixes: - VO - DTO + params: + pagination: + type: page + # 起始页码 或 起始偏移量 + start: 0 + # 每页最大查询条数(分页保护) + max-allowed-size: 500 # MyBatisFlex公共配置 # https://mybatis-flex.com/zh/base/configuration.html