优化代码

This commit is contained in:
smallchill 2018-12-30 00:21:02 +08:00
parent d1b750069e
commit 326290e361
3 changed files with 4 additions and 7 deletions

View File

@ -18,6 +18,7 @@ package org.springblade.core.mp.base;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -78,6 +79,7 @@ public class BaseEntity implements Serializable {
/** /**
* 状态[0:未删除,1:删除] * 状态[0:未删除,1:删除]
*/ */
@TableLogic
@ApiModelProperty(value = "是否已删除") @ApiModelProperty(value = "是否已删除")
private Integer isDeleted; private Integer isDeleted;
} }

View File

@ -15,8 +15,8 @@
*/ */
package org.springblade.core.mp.base; 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.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.SecureUtil; import org.springblade.core.secure.utils.SecureUtil;
@ -75,10 +75,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
T entity = BeanUtil.newInstance(modelClass); T entity = BeanUtil.newInstance(modelClass);
entity.setUpdateUser(user.getUserId()); entity.setUpdateUser(user.getUserId());
entity.setUpdateTime(LocalDateTime.now()); entity.setUpdateTime(LocalDateTime.now());
entity.setIsDeleted(BladeConstant.DB_IS_DELETED); return super.update(entity, Wrappers.<T>update().lambda().in(T::getId, ids)) && super.removeByIds(ids);
UpdateWrapper<T> uw = new UpdateWrapper<>();
uw.in(BladeConstant.DB_PRIMARY_KEY, ids);
return super.update(entity, uw);
} }
} }

View File

@ -18,7 +18,6 @@ package org.springblade.core.mp.support;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil; 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; return qw;
} }