From 326290e361436ff2512a255889b264f114994848 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 30 Dec 2018 00:21:02 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/springblade/core/mp/base/BaseEntity.java | 2 ++ .../java/org/springblade/core/mp/base/BaseServiceImpl.java | 7 ++----- .../java/org/springblade/core/mp/support/Condition.java | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java index a4843ac..88d3787 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java @@ -18,6 +18,7 @@ package org.springblade.core.mp.base; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -78,6 +79,7 @@ public class BaseEntity implements Serializable { /** * 状态[0:未删除,1:删除] */ + @TableLogic @ApiModelProperty(value = "是否已删除") private Integer isDeleted; } diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java index 5073f05..9c93ecc 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java @@ -15,8 +15,8 @@ */ package org.springblade.core.mp.base; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.SecureUtil; @@ -75,10 +75,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte T entity = BeanUtil.newInstance(modelClass); entity.setUpdateUser(user.getUserId()); entity.setUpdateTime(LocalDateTime.now()); - entity.setIsDeleted(BladeConstant.DB_IS_DELETED); - UpdateWrapper uw = new UpdateWrapper<>(); - uw.in(BladeConstant.DB_PRIMARY_KEY, ids); - return super.update(entity, uw); + return super.update(entity, Wrappers.update().lambda().in(T::getId, ids)) && super.removeByIds(ids); } } diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java index 7128a63..c4ed0c0 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java @@ -18,7 +18,6 @@ package org.springblade.core.mp.support; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; @@ -76,7 +75,6 @@ public class Condition { } }); } - qw.eq(BladeConstant.IS_DELETED_FIELD, BladeConstant.DB_NOT_DELETED); return qw; }