From ec6624171bae9e4e05341a9f9a41b6db5c6e4d76 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 27 Dec 2021 11:05:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8D=87=E7=BA=A7mybatis=20plus=203.4.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-commons/epmet-commons-mybatis/pom.xml | 2 +- .../commons/mybatis/config/MybatisPlusConfig.java | 10 +++++++--- .../commons/mybatis/entity/BaseEpmetEntity.java | 2 +- .../mybatis/service/impl/BaseServiceImpl.java | 14 +++++++------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/epmet-commons/epmet-commons-mybatis/pom.xml b/epmet-commons/epmet-commons-mybatis/pom.xml index 502ef21e81..db396c4042 100644 --- a/epmet-commons/epmet-commons-mybatis/pom.xml +++ b/epmet-commons/epmet-commons-mybatis/pom.xml @@ -13,7 +13,7 @@ jar - 3.2.0 + 3.4.2 1.1.14 4.0 11.2.0.3 diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java index 4eef291b8b..8ef978f3c3 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java @@ -8,7 +8,9 @@ package com.epmet.commons.mybatis.config; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,8 +39,10 @@ public class MybatisPlusConfig { */ @Bean @Order(0) - public PaginationInterceptor paginationInterceptor() { - return new PaginationInterceptor(); + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; } } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/BaseEpmetEntity.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/BaseEpmetEntity.java index 9a70d44c39..52071d79e2 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/BaseEpmetEntity.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/BaseEpmetEntity.java @@ -26,7 +26,7 @@ public abstract class BaseEpmetEntity implements Serializable { /** * id */ - @TableId(type = IdType.UUID) + @TableId(type = IdType.ASSIGN_ID) private String id; /** diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java index 445f5a6e40..8d7327cfa0 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/service/impl/BaseServiceImpl.java @@ -57,7 +57,7 @@ public abstract class BaseServiceImpl, T> implements Bas Page page = initPage(params); //默认排序 - if (StringUtils.isNotEmpty(defaultOrderField)) { + if (StringUtils.isNotBlank(defaultOrderField)) { if (isAsc) { page.addOrder(OrderItem.asc(defaultOrderField)); } else { @@ -111,7 +111,7 @@ public abstract class BaseServiceImpl, T> implements Bas String order = (String) params.get(Constant.ORDER); //前端字段排序 - if (StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)) { + if (StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)) { if (Constant.ASC.equalsIgnoreCase(order)) { return page.addOrder(OrderItem.asc(orderField)); } else { @@ -135,7 +135,7 @@ public abstract class BaseServiceImpl, T> implements Bas protected Map paramsToLike(Map params, String... likes) { for (String like : likes) { String val = (String) params.get(like); - if (StringUtils.isNotEmpty(val)) { + if (StringUtils.isNotBlank(val)) { params.put(like, "%" + val + "%"); } else { params.put(like, null); @@ -294,12 +294,12 @@ public abstract class BaseServiceImpl, T> implements Bas @Override public boolean deleteById(Serializable id) { - return SqlHelper.delBool(baseDao.deleteById(id)); + return SqlHelper.retBool(baseDao.deleteById(id)); } @Override public boolean deleteBatchIds(Collection idList) { - return SqlHelper.delBool(baseDao.deleteBatchIds(idList)); + return SqlHelper.retBool(baseDao.deleteBatchIds(idList)); } @Transactional(rollbackFor = Exception.class) @@ -311,7 +311,7 @@ public abstract class BaseServiceImpl, T> implements Bas Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); String keyProperty = tableInfo.getKeyProperty(); Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); - Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty()); + Object idVal = ReflectionKit.getFieldValue( entity, tableInfo.getKeyProperty()); return StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal)) ? insert(entity) : updateById(entity); } return false; @@ -335,7 +335,7 @@ public abstract class BaseServiceImpl, T> implements Bas try (SqlSession batchSqlSession = sqlSessionBatch()) { int i = 0; for (T entity : entityList) { - Object idVal = ReflectionKit.getMethodValue(cls, entity, keyProperty); + Object idVal = ReflectionKit.getFieldValue(entity, keyProperty); if (StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal))) { batchSqlSession.insert(sqlStatement(SqlMethod.INSERT_ONE), entity); } else { From 732c429759e32c90df7d0271c4f1d93e350a1b45 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 27 Dec 2021 14:06:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8D=87=E7=BA=A7mybatis=20plus=203.4.2=20?= =?UTF-8?q?=E5=AE=A2=E6=88=B7id=E8=BF=98=E6=98=AFuuid=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/entity/crm/CustomerEntity.java | 10 ++++++++-- .../main/java/com/epmet/entity/CustomerEntity.java | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java index c6dc6dba64..af4cb6844e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/crm/CustomerEntity.java @@ -17,9 +17,10 @@ package com.epmet.entity.crm; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -27,7 +28,7 @@ import lombok.EqualsAndHashCode; import java.util.Date; /** - * 客户表 + * 客户表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-11 @@ -39,6 +40,11 @@ public class CustomerEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; /** * 客户名称 */ diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java index 6e56fbee35..fe23757571 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java @@ -17,8 +17,9 @@ package com.epmet.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -26,7 +27,7 @@ import lombok.EqualsAndHashCode; import java.util.Date; /** - * 客户表 + * 客户表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-11 @@ -38,6 +39,12 @@ public class CustomerEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; + /** + * id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + /** * 客户名称 */ From c8135d7a9cac247459b724fdeb9800f1e08136e3 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 29 Dec 2021 11:06:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8D=87=E7=BA=A7=20plus?= =?UTF-8?q?-annotation=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-module/data-aggregator/data-aggregator-client/pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-client/pom.xml b/epmet-module/data-aggregator/data-aggregator-client/pom.xml index 7f6f4cd2ff..6248b5536f 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/pom.xml +++ b/epmet-module/data-aggregator/data-aggregator-client/pom.xml @@ -20,9 +20,8 @@ com.baomidou mybatis-plus-annotation - 3.2.0 - compile + 3.4.2 - \ No newline at end of file +