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 { 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 + 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; + /** * 客户名称 */