mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2026-07-14 08:36:11 +00:00
[重大更新] 增加mybatis-plus扩展工具 大幅简化整体业务代码写法 优雅舒适
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package org.dromara.web.service;
|
||||
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
@@ -58,8 +57,9 @@ public class SysRegisterService {
|
||||
sysUser.setPassword(BCrypt.hashpw(password));
|
||||
sysUser.setUserType(userType);
|
||||
|
||||
boolean exist = userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getUserName, sysUser.getUserName()));
|
||||
boolean exist = userMapper.lambda()
|
||||
.eq(SysUser::getUserName, sysUser.getUserName())
|
||||
.exists();
|
||||
if (exist) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.dromara.web.service.impl;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
@@ -95,7 +94,9 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
* @return 用户信息
|
||||
*/
|
||||
private SysUserVo loadUserByEmail(String email) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getEmail, email));
|
||||
SysUserVo user = userMapper.lambda()
|
||||
.eq(SysUser::getEmail, email)
|
||||
.voOne();
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", email);
|
||||
throw new UserException("user.not.exists", email);
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
@@ -112,7 +111,9 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
* @return 用户信息
|
||||
*/
|
||||
private SysUserVo loadUserByUsername(String username) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
SysUserVo user = userMapper.lambda()
|
||||
.eq(SysUser::getUserName, username)
|
||||
.voOne();
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.dromara.web.service.impl;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
@@ -95,7 +94,9 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
* @return 用户信息
|
||||
*/
|
||||
private SysUserVo loadUserByPhoneNumber(String phoneNumber) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phoneNumber));
|
||||
SysUserVo user = userMapper.lambda()
|
||||
.eq(SysUser::getPhoneNumber, phoneNumber)
|
||||
.voOne();
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phoneNumber);
|
||||
throw new UserException("user.not.exists", phoneNumber);
|
||||
|
||||
+20
@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.ChainWrappers;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
import org.apache.ibatis.logging.LogFactory;
|
||||
@@ -60,6 +62,24 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
||||
return this.selectList(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建当前 Mapper 绑定的 Lambda CRUD 链式操作。
|
||||
*
|
||||
* @return Lambda CRUD 链式包装器
|
||||
*/
|
||||
default LambdaCrudChainWrapper<T, V> lambda() {
|
||||
return new LambdaCrudChainWrapper<>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建当前 Mapper 绑定的 Lambda 链式更新。
|
||||
*
|
||||
* @return Lambda 链式更新包装器
|
||||
*/
|
||||
default LambdaUpdateChainWrapper<T> lambdaUpdate() {
|
||||
return ChainWrappers.lambdaUpdateChain(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量插入实体对象集合
|
||||
*
|
||||
|
||||
+399
@@ -0,0 +1,399 @@
|
||||
package org.dromara.common.mybatis.core.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.AbstractLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.SharedString;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.Query;
|
||||
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.Update;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.dromara.common.mybatis.core.query.LambdaQueryCondition;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Mapper 级 Lambda CRUD 链式包装器。
|
||||
*
|
||||
* @param <T> table 泛型
|
||||
* @param <V> vo 泛型
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class LambdaCrudChainWrapper<T, V> extends AbstractLambdaWrapper<T, LambdaCrudChainWrapper<T, V>>
|
||||
implements Query<LambdaCrudChainWrapper<T, V>, T, SFunction<T, ?>>,
|
||||
Update<LambdaCrudChainWrapper<T, V>, SFunction<T, ?>>,
|
||||
LambdaQueryCondition<T, LambdaCrudChainWrapper<T, V>> {
|
||||
|
||||
private final BaseMapperPlus<T, V> baseMapper;
|
||||
private final List<String> sqlSet;
|
||||
private SharedString sqlSelect = new SharedString();
|
||||
|
||||
public LambdaCrudChainWrapper(BaseMapperPlus<T, V> baseMapper) {
|
||||
this.baseMapper = baseMapper;
|
||||
super.setEntityClass(baseMapper.currentModelClass());
|
||||
super.initNeed();
|
||||
this.sqlSet = new ArrayList<>();
|
||||
}
|
||||
|
||||
LambdaCrudChainWrapper(BaseMapperPlus<T, V> baseMapper, T entity, Class<T> entityClass, SharedString sqlSelect,
|
||||
List<String> sqlSet, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs,
|
||||
MergeSegments mergeSegments, SharedString paramAlias, SharedString lastSql,
|
||||
SharedString sqlComment, SharedString sqlFirst) {
|
||||
this.baseMapper = baseMapper;
|
||||
super.setEntity(entity);
|
||||
super.setEntityClass(entityClass);
|
||||
this.sqlSelect = sqlSelect == null ? new SharedString() : sqlSelect;
|
||||
this.sqlSet = sqlSet == null ? new ArrayList<>() : sqlSet;
|
||||
this.paramNameSeq = paramNameSeq;
|
||||
this.paramNameValuePairs = paramNameValuePairs;
|
||||
this.expression = mergeSegments;
|
||||
this.paramAlias = paramAlias;
|
||||
this.lastSql = lastSql;
|
||||
this.sqlComment = sqlComment;
|
||||
this.sqlFirst = sqlFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> select(boolean condition, List<SFunction<T, ?>> columns) {
|
||||
if (condition && CollectionUtils.isNotEmpty(columns)) {
|
||||
this.sqlSelect.setStringValue(columnsToString(false, columns));
|
||||
}
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaCrudChainWrapper<T, V> select(SFunction<T, ?>... columns) {
|
||||
return select(true, CollectionUtils.toList(columns));
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaCrudChainWrapper<T, V> select(boolean condition, SFunction<T, ?>... columns) {
|
||||
return select(condition, CollectionUtils.toList(columns));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> select(Class<T> entityClass, Predicate<TableFieldInfo> predicate) {
|
||||
if (entityClass == null) {
|
||||
entityClass = getEntityClass();
|
||||
} else {
|
||||
setEntityClass(entityClass);
|
||||
}
|
||||
Assert.notNull(entityClass, "entityClass can not be null");
|
||||
this.sqlSelect.setStringValue(TableInfoHelper.getTableInfo(entityClass).chooseSelect(predicate));
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlSelect() {
|
||||
return sqlSelect.getStringValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> set(boolean condition, SFunction<T, ?> column, Object val, String mapping) {
|
||||
return maybeDo(condition, () -> {
|
||||
String sql = formatParam(mapping, val);
|
||||
sqlSet.add(columnToString(column) + Constants.EQUALS + sql);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 值不为 null 时设置更新字段。
|
||||
*
|
||||
* @param column 字段
|
||||
* @param value 值
|
||||
* @return this
|
||||
*/
|
||||
public LambdaCrudChainWrapper<T, V> setIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return set(value != null, column, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本不为空时设置更新字段。
|
||||
*
|
||||
* @param column 字段
|
||||
* @param value 值
|
||||
* @return this
|
||||
*/
|
||||
public LambdaCrudChainWrapper<T, V> setIfText(SFunction<T, ?> column, String value) {
|
||||
return set(org.dromara.common.core.utils.StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> setSql(boolean condition, String setSql, Object... params) {
|
||||
return maybeDo(condition && StringUtils.isNotBlank(setSql), () -> sqlSet.add(formatSqlMaybeWithParam(setSql, params)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> setIncrBy(boolean condition, SFunction<T, ?> column, Number val) {
|
||||
return maybeDo(condition, () -> {
|
||||
String realColumn = columnToString(column);
|
||||
String realVal = val instanceof BigDecimal ? ((BigDecimal) val).toPlainString() : String.valueOf(val);
|
||||
sqlSet.add(String.format("%s=%s + %s", realColumn, realColumn, realVal));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaCrudChainWrapper<T, V> setDecrBy(boolean condition, SFunction<T, ?> column, Number val) {
|
||||
return maybeDo(condition, () -> {
|
||||
String realColumn = columnToString(column);
|
||||
String realVal = val instanceof BigDecimal ? ((BigDecimal) val).toPlainString() : String.valueOf(val);
|
||||
sqlSet.add(String.format("%s=%s - %s", realColumn, realColumn, realVal));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSqlSet() {
|
||||
if (CollectionUtils.isEmpty(sqlSet)) {
|
||||
return null;
|
||||
}
|
||||
return String.join(Constants.COMMA, sqlSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询条件 Wrapper。
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public LambdaCrudChainWrapper<T, V> getWrapper() {
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
public LambdaCrudChainWrapper<T, V> findInSet(Object value, SFunction<T, ?> column) {
|
||||
return findInSet(true, value, column);
|
||||
}
|
||||
|
||||
public LambdaCrudChainWrapper<T, V> findInSet(boolean condition, Object value, SFunction<T, ?> column) {
|
||||
return findInSet(condition, value, columnToString(column));
|
||||
}
|
||||
|
||||
public LambdaCrudChainWrapper<T, V> findInSetIfPresent(Object value, SFunction<T, ?> column) {
|
||||
return findInSet(value != null, value, column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Wrapper。
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public LambdaCrudChainWrapper<T, V> build() {
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体列表。
|
||||
*
|
||||
* @return 实体列表
|
||||
*/
|
||||
public List<T> list() {
|
||||
return baseMapper.selectList(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体分页记录。
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @return 实体分页记录
|
||||
*/
|
||||
public List<T> list(IPage<T> page) {
|
||||
return baseMapper.selectList(page, typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 VO 列表。
|
||||
*
|
||||
* @return VO 列表
|
||||
*/
|
||||
public List<V> voList() {
|
||||
return baseMapper.selectVoList(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单列对象列表。
|
||||
*
|
||||
* @return 单列对象列表
|
||||
*/
|
||||
public List<Object> objs() {
|
||||
return baseMapper.selectObjs(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单列对象列表并转换类型。
|
||||
*
|
||||
* @param mapper 转换函数
|
||||
* @param <C> 转换后的类型
|
||||
* @return 单列对象列表
|
||||
*/
|
||||
public <C> List<C> objs(Function<? super Object, C> mapper) {
|
||||
return baseMapper.selectObjs(typedThis, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个实体。
|
||||
*
|
||||
* @return 实体
|
||||
*/
|
||||
public T one() {
|
||||
return baseMapper.selectOne(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个实体。
|
||||
*
|
||||
* @param throwEx 查询到多条时是否抛异常
|
||||
* @return 实体
|
||||
*/
|
||||
public T one(boolean throwEx) {
|
||||
return baseMapper.selectOne(typedThis, throwEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个实体 Optional。
|
||||
*
|
||||
* @return Optional 实体
|
||||
*/
|
||||
public Optional<T> oneOpt() {
|
||||
return Optional.ofNullable(one());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个 VO。
|
||||
*
|
||||
* @return VO
|
||||
*/
|
||||
public V voOne() {
|
||||
return baseMapper.selectVoOne(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个 VO。
|
||||
*
|
||||
* @param throwEx 查询到多条时是否抛异常
|
||||
* @return VO
|
||||
*/
|
||||
public V voOne(boolean throwEx) {
|
||||
return baseMapper.selectVoOne(typedThis, throwEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数量。
|
||||
*
|
||||
* @return 数量
|
||||
*/
|
||||
public Long count() {
|
||||
return baseMapper.selectCount(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否存在。
|
||||
*
|
||||
* @return 是否存在
|
||||
*/
|
||||
public boolean exists() {
|
||||
return baseMapper.exists(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体分页。
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param <P> 分页类型
|
||||
* @return 实体分页
|
||||
*/
|
||||
public <P extends IPage<T>> P page(P page) {
|
||||
return baseMapper.selectPage(page, typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 VO 分页。
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param <P> 分页类型
|
||||
* @return VO 分页
|
||||
*/
|
||||
public <P extends IPage<V>> P voPage(IPage<T> page) {
|
||||
return baseMapper.selectVoPage(page, typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据。
|
||||
*
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
public boolean delete() {
|
||||
return deleteCount() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据。
|
||||
*
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int deleteCount() {
|
||||
return baseMapper.delete(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 set 片段更新数据。
|
||||
*
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public boolean update() {
|
||||
return updateCount() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用实体和查询条件更新数据。
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public boolean update(T entity) {
|
||||
return updateCount(entity) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 set 片段更新数据。
|
||||
*
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int updateCount() {
|
||||
return baseMapper.update(typedThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用实体和查询条件更新数据。
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int updateCount(T entity) {
|
||||
return baseMapper.update(entity, typedThis);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LambdaCrudChainWrapper<T, V> instance() {
|
||||
return new LambdaCrudChainWrapper<>(baseMapper, getEntity(), getEntityClass(), null, null, paramNameSeq,
|
||||
paramNameValuePairs, new MergeSegments(), paramAlias, SharedString.emptyString(), SharedString.emptyString(),
|
||||
SharedString.emptyString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
sqlSelect.toNull();
|
||||
sqlSet.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
package org.dromara.common.mybatis.core.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* LambdaQueryWrapper 条件构造辅助类。
|
||||
*
|
||||
* @param <T> 实体类型
|
||||
* @author Lion Li
|
||||
*/
|
||||
public final class LambdaQueryBuilder<T> implements LambdaQueryCondition<T, LambdaQueryBuilder<T>> {
|
||||
|
||||
private final LambdaQueryWrapper<T> wrapper;
|
||||
|
||||
LambdaQueryBuilder(LambdaQueryWrapper<T> wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> select(SFunction<T, ?>... columns) {
|
||||
wrapper.select(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> eq(SFunction<T, ?> column, Object value) {
|
||||
wrapper.eq(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> eq(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.eq(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> ne(SFunction<T, ?> column, Object value) {
|
||||
wrapper.ne(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> ne(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.ne(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> gt(SFunction<T, ?> column, Object value) {
|
||||
wrapper.gt(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> gt(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.gt(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> ge(SFunction<T, ?> column, Object value) {
|
||||
wrapper.ge(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> ge(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.ge(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> lt(SFunction<T, ?> column, Object value) {
|
||||
wrapper.lt(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> lt(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.lt(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> le(SFunction<T, ?> column, Object value) {
|
||||
wrapper.le(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> le(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.le(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> like(SFunction<T, ?> column, Object value) {
|
||||
wrapper.like(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> like(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.like(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notLike(SFunction<T, ?> column, Object value) {
|
||||
wrapper.notLike(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notLike(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.notLike(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> likeLeft(SFunction<T, ?> column, Object value) {
|
||||
wrapper.likeLeft(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> likeLeft(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.likeLeft(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> likeRight(SFunction<T, ?> column, Object value) {
|
||||
wrapper.likeRight(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> likeRight(boolean condition, SFunction<T, ?> column, Object value) {
|
||||
wrapper.likeRight(condition, column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> between(SFunction<T, ?> column, Object begin, Object end) {
|
||||
wrapper.between(column, begin, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> between(boolean condition, SFunction<T, ?> column, Object begin, Object end) {
|
||||
wrapper.between(condition, column, begin, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notBetween(SFunction<T, ?> column, Object begin, Object end) {
|
||||
wrapper.notBetween(column, begin, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notBetween(boolean condition, SFunction<T, ?> column, Object begin, Object end) {
|
||||
wrapper.notBetween(condition, column, begin, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> allEq(Map<?, ?> params, boolean null2IsNull) {
|
||||
wrapper.allEq(true, (Map) params, null2IsNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> allEq(boolean condition, Map<?, ?> params, boolean null2IsNull) {
|
||||
wrapper.allEq(condition, (Map) params, null2IsNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> allEq(BiPredicate<SFunction<T, ?>, Object> filter, Map<?, ?> params, boolean null2IsNull) {
|
||||
wrapper.allEq(true, (BiPredicate) filter, (Map) params, null2IsNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> allEq(boolean condition, BiPredicate<SFunction<T, ?>, Object> filter, Map<?, ?> params, boolean null2IsNull) {
|
||||
wrapper.allEq(condition, (BiPredicate) filter, (Map) params, null2IsNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> isNull(SFunction<T, ?> column) {
|
||||
wrapper.isNull(column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> isNull(boolean condition, SFunction<T, ?> column) {
|
||||
wrapper.isNull(condition, column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> isNotNull(SFunction<T, ?> column) {
|
||||
wrapper.isNotNull(column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> isNotNull(boolean condition, SFunction<T, ?> column) {
|
||||
wrapper.isNotNull(condition, column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> in(SFunction<T, ?> column, Collection<?> values) {
|
||||
wrapper.in(column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> in(boolean condition, SFunction<T, ?> column, Collection<?> values) {
|
||||
wrapper.in(condition, column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> in(SFunction<T, ?> column, Object... values) {
|
||||
wrapper.in(column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> in(boolean condition, SFunction<T, ?> column, Object... values) {
|
||||
wrapper.in(condition, column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notIn(SFunction<T, ?> column, Collection<?> values) {
|
||||
wrapper.notIn(column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notIn(boolean condition, SFunction<T, ?> column, Collection<?> values) {
|
||||
wrapper.notIn(condition, column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notIn(SFunction<T, ?> column, Object... values) {
|
||||
wrapper.notIn(column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notIn(boolean condition, SFunction<T, ?> column, Object... values) {
|
||||
wrapper.notIn(condition, column, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> groupBy(SFunction<T, ?>... columns) {
|
||||
wrapper.groupBy(Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> groupBy(boolean condition, SFunction<T, ?>... columns) {
|
||||
wrapper.groupBy(condition, Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> orderBy(boolean condition, boolean isAsc, SFunction<T, ?> column) {
|
||||
wrapper.orderBy(condition, isAsc, column);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> orderByAsc(SFunction<T, ?>... columns) {
|
||||
wrapper.orderByAsc(Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> orderByAsc(boolean condition, SFunction<T, ?>... columns) {
|
||||
wrapper.orderByAsc(condition, Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> orderByDesc(SFunction<T, ?>... columns) {
|
||||
wrapper.orderByDesc(Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final LambdaQueryBuilder<T> orderByDesc(boolean condition, SFunction<T, ?>... columns) {
|
||||
wrapper.orderByDesc(condition, Arrays.asList(columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> having(String sqlHaving, Object... params) {
|
||||
wrapper.having(sqlHaving, params);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> having(boolean condition, String sqlHaving, Object... params) {
|
||||
wrapper.having(condition, sqlHaving, params);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> and(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.and(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> and(boolean condition, Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.and(condition, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> or() {
|
||||
wrapper.or();
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> or(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.or(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> or(boolean condition, Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.or(condition, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> nested(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.nested(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> nested(boolean condition, Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.nested(condition, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> exists(String existsSql, Object... values) {
|
||||
wrapper.exists(existsSql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> exists(boolean condition, String existsSql, Object... values) {
|
||||
wrapper.exists(condition, existsSql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> eqSql(SFunction<T, ?> column, String inValue) {
|
||||
wrapper.eqSql(true, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> eqSql(boolean condition, SFunction<T, ?> column, String inValue) {
|
||||
wrapper.eqSql(condition, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> inSql(SFunction<T, ?> column, String inValue) {
|
||||
wrapper.inSql(true, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> inSql(boolean condition, SFunction<T, ?> column, String inValue) {
|
||||
wrapper.inSql(condition, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notInSql(SFunction<T, ?> column, String inValue) {
|
||||
wrapper.notInSql(true, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notInSql(boolean condition, SFunction<T, ?> column, String inValue) {
|
||||
wrapper.notInSql(condition, column, inValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notExists(String existsSql, Object... values) {
|
||||
wrapper.notExists(existsSql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> notExists(boolean condition, String existsSql, Object... values) {
|
||||
wrapper.notExists(condition, existsSql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> apply(String applySql, Object... values) {
|
||||
wrapper.apply(applySql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> apply(boolean condition, String applySql, Object... values) {
|
||||
wrapper.apply(condition, applySql, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> apply(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
consumer.accept(wrapper);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> func(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.func(true, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> func(boolean condition, Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.func(condition, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> not(Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.not(true, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> not(boolean condition, Consumer<LambdaQueryWrapper<T>> consumer) {
|
||||
wrapper.not(condition, consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> comment(String comment) {
|
||||
wrapper.comment(true, comment);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> comment(boolean condition, String comment) {
|
||||
wrapper.comment(condition, comment);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryBuilder<T> last(String lastSql) {
|
||||
wrapper.last(lastSql);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapper<T> build() {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
package org.dromara.common.mybatis.core.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Lambda 查询常用条件扩展。
|
||||
*
|
||||
* @param <T> 实体类型
|
||||
* @param <Children> 链式返回类型
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface LambdaQueryCondition<T, Children> {
|
||||
|
||||
Children eq(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children ne(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children gt(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children ge(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children lt(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children le(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children like(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children notLike(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children likeLeft(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children likeRight(boolean condition, SFunction<T, ?> column, Object value);
|
||||
|
||||
Children between(boolean condition, SFunction<T, ?> column, Object begin, Object end);
|
||||
|
||||
Children notBetween(boolean condition, SFunction<T, ?> column, Object begin, Object end);
|
||||
|
||||
Children in(boolean condition, SFunction<T, ?> column, Collection<?> values);
|
||||
|
||||
Children in(boolean condition, SFunction<T, ?> column, Object... values);
|
||||
|
||||
Children notIn(boolean condition, SFunction<T, ?> column, Collection<?> values);
|
||||
|
||||
Children notIn(boolean condition, SFunction<T, ?> column, Object... values);
|
||||
|
||||
Children apply(boolean condition, String applySql, Object... values);
|
||||
|
||||
default Children eqIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return eq(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children eqIfText(SFunction<T, ?> column, String value) {
|
||||
return eq(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children neIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return ne(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children neIfText(SFunction<T, ?> column, String value) {
|
||||
return ne(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children gtIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return gt(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children geIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return ge(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children ltIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return lt(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children leIfPresent(SFunction<T, ?> column, Object value) {
|
||||
return le(value != null, column, value);
|
||||
}
|
||||
|
||||
default Children likeIfText(SFunction<T, ?> column, String value) {
|
||||
return like(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children notLikeIfText(SFunction<T, ?> column, String value) {
|
||||
return notLike(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children likeLeftIfText(SFunction<T, ?> column, String value) {
|
||||
return likeLeft(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children likeRightIfText(SFunction<T, ?> column, String value) {
|
||||
return likeRight(StringUtils.isNotBlank(value), column, value);
|
||||
}
|
||||
|
||||
default Children betweenIfPresent(SFunction<T, ?> column, Object begin, Object end) {
|
||||
return between(begin != null && end != null, column, begin, end);
|
||||
}
|
||||
|
||||
default Children betweenParams(SFunction<T, ?> column, Map<String, Object> params, String beginKey, String endKey) {
|
||||
if (params == null) {
|
||||
return between(false, column, null, null);
|
||||
}
|
||||
Object begin = params.get(beginKey);
|
||||
Object end = params.get(endKey);
|
||||
return between(begin != null && end != null, column, begin, end);
|
||||
}
|
||||
|
||||
default Children notBetweenIfPresent(SFunction<T, ?> column, Object begin, Object end) {
|
||||
return notBetween(begin != null && end != null, column, begin, end);
|
||||
}
|
||||
|
||||
default Children inIfNotEmpty(SFunction<T, ?> column, Collection<?> values) {
|
||||
return in(values != null && !values.isEmpty(), column, values);
|
||||
}
|
||||
|
||||
default Children inIfNotEmpty(SFunction<T, ?> column, Object... values) {
|
||||
return in(values != null && values.length > 0, column, values);
|
||||
}
|
||||
|
||||
default Children notInIfNotEmpty(SFunction<T, ?> column, Collection<?> values) {
|
||||
return notIn(values != null && !values.isEmpty(), column, values);
|
||||
}
|
||||
|
||||
default Children notInIfNotEmpty(SFunction<T, ?> column, Object... values) {
|
||||
return notIn(values != null && values.length > 0, column, values);
|
||||
}
|
||||
|
||||
default Children findInSet(Object value, String column) {
|
||||
return findInSet(true, value, column);
|
||||
}
|
||||
|
||||
default Children findInSet(boolean condition, Object value, String column) {
|
||||
return apply(condition, DataBaseHelper.findInSet(value, column));
|
||||
}
|
||||
|
||||
default Children findInSetIfPresent(Object value, String column) {
|
||||
return findInSet(value != null, value, column);
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.dromara.common.mybatis.core.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
/**
|
||||
* MyBatis-Plus 查询构造器入口。
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public final class QueryBuilder {
|
||||
|
||||
private QueryBuilder() {
|
||||
}
|
||||
|
||||
public static <T> LambdaQueryBuilder<T> lambda(Class<T> entityClass) {
|
||||
return new LambdaQueryBuilder<>(Wrappers.lambdaQuery(entityClass));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,11 +1,10 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.mapper.TestDemoMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -83,8 +82,9 @@ public class TestBatchController extends BaseController {
|
||||
@DeleteMapping()
|
||||
// @DS("slave")
|
||||
public R<Void> remove() {
|
||||
return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>()
|
||||
.eq(TestDemo::getOrderNum, -1L)));
|
||||
return toAjax(testDemoMapper.lambda()
|
||||
.eq(TestDemo::getOrderNum, -1L)
|
||||
.deleteCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-6
@@ -8,7 +8,6 @@ import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -66,9 +65,10 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
*/
|
||||
@Override
|
||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
||||
return genTableColumnMapper.selectList(new LambdaQueryWrapper<GenTableColumn>()
|
||||
return genTableColumnMapper.lambda()
|
||||
.eq(GenTableColumn::getTableId, tableId)
|
||||
.orderByAsc(GenTableColumn::getSort));
|
||||
.orderByAsc(GenTableColumn::getSort)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
public void deleteGenTableByIds(Long[] tableIds) {
|
||||
List<Long> ids = Arrays.asList(tableIds);
|
||||
baseMapper.deleteByIds(ids);
|
||||
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids));
|
||||
genTableColumnMapper.lambda()
|
||||
.in(GenTableColumn::getTableId, ids)
|
||||
.deleteCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -551,10 +553,11 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
return tables;
|
||||
}
|
||||
List<Long> tableIds = StreamUtils.toList(tables, GenTable::getTableId);
|
||||
List<GenTableColumn> columns = genTableColumnMapper.selectList(new LambdaQueryWrapper<GenTableColumn>()
|
||||
List<GenTableColumn> columns = genTableColumnMapper.lambda()
|
||||
.in(GenTableColumn::getTableId, tableIds)
|
||||
.orderByAsc(GenTableColumn::getTableId)
|
||||
.orderByAsc(GenTableColumn::getSort));
|
||||
.orderByAsc(GenTableColumn::getSort)
|
||||
.list();
|
||||
Map<Long, List<GenTableColumn>> columnMap = StreamUtils.groupByKey(columns, GenTableColumn::getTableId);
|
||||
tables.forEach(table -> table.setColumns(columnMap.getOrDefault(table.getTableId(), new ArrayList<>())));
|
||||
return tables;
|
||||
|
||||
@@ -8,11 +8,11 @@ import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
#end
|
||||
#if($enableStatus || $enableSort)
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
#end
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
#if($enableUnique)
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
#end
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -134,7 +134,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
#if($hasBetween)
|
||||
Map<String, Object> params = bo.getParams();
|
||||
#end
|
||||
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
||||
return QueryBuilder.lambda(${ClassName}.class)
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($queryType=$column.queryType)
|
||||
@@ -144,29 +144,47 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
#if($queryType != 'BETWEEN')
|
||||
#if($javaType == 'String')
|
||||
#set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())')
|
||||
#if($queryType == 'LIKE')
|
||||
.likeIfText(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#elseif($queryType == 'EQ')
|
||||
.eqIfText(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#elseif($queryType == 'NE')
|
||||
.neIfText(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#else
|
||||
.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#end
|
||||
#else
|
||||
#set($condition='bo.get'+$AttrName+'() != null')
|
||||
#end
|
||||
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
|
||||
#if($queryType == 'EQ')
|
||||
.eqIfPresent(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#elseif($queryType == 'NE')
|
||||
.neIfPresent(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#elseif($queryType == 'GT')
|
||||
.gtIfPresent(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#elseif($queryType == 'LT')
|
||||
.ltIfPresent(${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#else
|
||||
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
|
||||
${ClassName}::get$AttrName, params.get("begin$AttrName"), params.get("end$AttrName"));
|
||||
.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName())
|
||||
#end
|
||||
#end
|
||||
#else
|
||||
.betweenParams(${ClassName}::get$AttrName, params, "begin$AttrName", "end$AttrName")
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if($table.tree && "" != $treeAncestorsField)
|
||||
lqw.orderByAsc(${ClassName}::get${TreeAncestorsCap});
|
||||
.orderByAsc(${ClassName}::get${TreeAncestorsCap})
|
||||
#end
|
||||
#if($table.tree && "" != $treeParentCode)
|
||||
lqw.orderByAsc(${ClassName}::get${TreeParentCap});
|
||||
.orderByAsc(${ClassName}::get${TreeParentCap})
|
||||
#end
|
||||
#if($table.tree && "" != $treeOrderField)
|
||||
lqw.orderByAsc(${ClassName}::get${TreeOrderCap});
|
||||
.orderByAsc(${ClassName}::get${TreeOrderCap})
|
||||
#elseif($enableSort)
|
||||
lqw.orderByAsc(${ClassName}::get${sortColumn.capJavaField});
|
||||
.orderByAsc(${ClassName}::get${sortColumn.capJavaField})
|
||||
#end
|
||||
lqw.orderByAsc(${ClassName}::get${pkColumn.capJavaField});
|
||||
return lqw;
|
||||
.orderByAsc(${ClassName}::get${pkColumn.capJavaField})
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,9 +233,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateStatus(${pkColumn.javaType} ${pkColumn.javaField}, ${statusColumn.javaType} status) {
|
||||
return baseMapper.update(null, new LambdaUpdateWrapper<${ClassName}>()
|
||||
return baseMapper.lambda()
|
||||
.set(${ClassName}::get${statusColumn.capJavaField}, status)
|
||||
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})) > 0;
|
||||
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})
|
||||
.update();
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -231,9 +250,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateSort(${pkColumn.javaType} ${pkColumn.javaField}, ${sortColumn.javaType} sortValue) {
|
||||
return baseMapper.update(null, new LambdaUpdateWrapper<${ClassName}>()
|
||||
return baseMapper.lambda()
|
||||
.set(${ClassName}::get${sortColumn.capJavaField}, sortValue)
|
||||
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})) > 0;
|
||||
.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField})
|
||||
.update();
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -296,12 +316,14 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
}
|
||||
|
||||
private void updateChildrenAncestors(${pkColumn.javaType} currentId, String newAncestors, String oldAncestors) {
|
||||
List<${ClassName}> children = baseMapper.selectList(new LambdaQueryWrapper<${ClassName}>()
|
||||
.select(${ClassName}::get${pkColumn.capJavaField}, ${ClassName}::get${TreeAncestorsCap}()));
|
||||
List<${ClassName}> children = baseMapper.lambda()
|
||||
.select(${ClassName}::get${pkColumn.capJavaField}, ${ClassName}::get${TreeAncestorsCap})
|
||||
.findInSet(currentId, ${ClassName}::get${TreeAncestorsCap})
|
||||
.list();
|
||||
List<${ClassName}> updateList = new ArrayList<>();
|
||||
for (${ClassName} child : children) {
|
||||
String ancestors = child.get${TreeAncestorsCap}();
|
||||
if (StringUtils.isBlank(ancestors) || !containsAncestor(ancestors, currentId)) {
|
||||
if (StringUtils.isBlank(ancestors)) {
|
||||
continue;
|
||||
}
|
||||
${ClassName} update = new ${ClassName}();
|
||||
|
||||
+4
-5
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
@@ -9,7 +8,6 @@ import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRole;
|
||||
import org.dromara.system.domain.SysRoleDept;
|
||||
@@ -66,7 +64,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo>, MPJBa
|
||||
@DataColumn(key = "deptName", value = "dept_id")
|
||||
})
|
||||
default long countDeptById(Long deptId) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysDept>().eq(SysDept::getDeptId, deptId));
|
||||
return this.lambda().eq(SysDept::getDeptId, deptId).count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,9 +74,10 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo>, MPJBa
|
||||
* @return 包含子部门的列表
|
||||
*/
|
||||
default List<SysDept> selectListByParentId(Long parentId) {
|
||||
return this.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
return this.lambda()
|
||||
.select(SysDept::getDeptId)
|
||||
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
||||
.findInSet(parentId, SysDept::getAncestors)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysDictData;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
@@ -21,9 +20,9 @@ public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDa
|
||||
* @return 符合条件的字典数据列表
|
||||
*/
|
||||
default List<SysDictDataVo> selectDictDataByType(String dictType) {
|
||||
return selectVoList(
|
||||
new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
return this.lambda()
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.orderByAsc(SysDictData::getDictSort)
|
||||
.voList();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
@@ -97,12 +96,12 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo>, MPJBa
|
||||
* @return 菜单列表
|
||||
*/
|
||||
default List<SysMenu> selectMenuTreeAll() {
|
||||
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>()
|
||||
return this.lambda()
|
||||
.in(SysMenu::getMenuType, SystemConstants.TYPE_DIR, SystemConstants.TYPE_MENU)
|
||||
.eq(SysMenu::getStatus, SystemConstants.NORMAL)
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum);
|
||||
return this.selectList(lqw);
|
||||
.orderByAsc(SysMenu::getOrderNum)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
@@ -62,7 +61,7 @@ public interface SysPostMapper extends BaseMapperPlus<SysPost, SysPostVo>, MPJBa
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long selectPostCount(Collection<Long> postIds) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysPost>().in(SysPost::getPostId, postIds));
|
||||
return this.lambda().in(SysPost::getPostId, postIds).count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
@@ -64,7 +63,7 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo>, MPJBa
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long selectRoleCount(Collection<Long> roleIds) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysRole>().in(SysRole::getRoleId, roleIds));
|
||||
return this.lambda().in(SysRole::getRoleId, roleIds).count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysRoleMenu;
|
||||
|
||||
@@ -20,7 +19,7 @@ public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu, SysRoleMe
|
||||
* @return 结果
|
||||
*/
|
||||
default int deleteByMenuIds(Collection<Long> menuIds) {
|
||||
return this.delete(new LambdaUpdateWrapper<SysRoleMenu>().in(SysRoleMenu::getMenuId, menuIds));
|
||||
return this.lambda().in(SysRoleMenu::getMenuId, menuIds).deleteCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
@@ -136,7 +135,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo>, MPJBa
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long countUserById(Long userId) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, userId));
|
||||
return lambda().eq(SysUser::getUserId, userId).count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
|
||||
@@ -20,9 +20,10 @@ public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole, SysUserRo
|
||||
* @return 关联到指定角色的用户ID列表
|
||||
*/
|
||||
default List<Long> selectUserIdsByRoleId(Long roleId) {
|
||||
return this.selectObjs(new LambdaQueryWrapper<SysUserRole>()
|
||||
.select(SysUserRole::getUserId).eq(SysUserRole::getRoleId, roleId)
|
||||
);
|
||||
return this.lambda()
|
||||
.select(SysUserRole::getUserId)
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.objs(Convert::toLong);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -4,8 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -14,6 +12,7 @@ import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.system.domain.SysClient;
|
||||
import org.dromara.system.domain.bo.SysClientBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
@@ -64,7 +63,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
@Cacheable(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
||||
@Override
|
||||
public SysClientVo queryByClientId(String clientId) {
|
||||
SysClientVo vo = baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId));
|
||||
SysClientVo vo = baseMapper.lambda().eq(SysClient::getClientId, clientId).voOne();
|
||||
fillClientRuleFields(vo);
|
||||
return vo;
|
||||
}
|
||||
@@ -105,13 +104,13 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
* @return 包含 clientId、clientKey、状态等条件的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysClient> buildQueryWrapper(SysClientBo bo) {
|
||||
LambdaQueryWrapper<SysClient> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getClientId()), SysClient::getClientId, bo.getClientId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getClientKey()), SysClient::getClientKey, bo.getClientKey());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getClientSecret()), SysClient::getClientSecret, bo.getClientSecret());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysClient::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(SysClient::getId);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysClient.class)
|
||||
.eqIfText(SysClient::getClientId, bo.getClientId())
|
||||
.eqIfText(SysClient::getClientKey, bo.getClientKey())
|
||||
.eqIfText(SysClient::getClientSecret, bo.getClientSecret())
|
||||
.eqIfText(SysClient::getStatus, bo.getStatus())
|
||||
.orderByAsc(SysClient::getId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,10 +162,10 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
||||
@Override
|
||||
public int updateClientStatus(String clientId, String status) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysClient>()
|
||||
.set(SysClient::getStatus, status)
|
||||
.eq(SysClient::getClientId, clientId));
|
||||
return baseMapper.lambda()
|
||||
.set(SysClient::getStatus, status)
|
||||
.eq(SysClient::getClientId, clientId)
|
||||
.updateCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,9 +189,10 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkClickKeyUnique(SysClientBo client) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysClient>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysClient::getClientKey, client.getClientKey())
|
||||
.ne(ObjectUtil.isNotNull(client.getId()), SysClient::getId, client.getId()));
|
||||
.neIfPresent(SysClient::getId, client.getId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -4,7 +4,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
@@ -17,6 +16,7 @@ import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
import org.dromara.system.api.ConfigService;
|
||||
import org.dromara.system.domain.SysConfig;
|
||||
@@ -77,8 +77,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
@Cacheable(cacheNames = CacheNames.SYS_CONFIG, key = "#configKey")
|
||||
@Override
|
||||
public String selectConfigByKey(String configKey) {
|
||||
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, configKey));
|
||||
SysConfig retConfig = baseMapper.lambda().eq(SysConfig::getConfigKey, configKey).one();
|
||||
return ObjectUtils.notNullGetter(retConfig, SysConfig::getConfigValue, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
@@ -112,14 +111,13 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
*/
|
||||
private LambdaQueryWrapper<SysConfig> buildQueryWrapper(SysConfigBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysConfig> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getConfigName()), SysConfig::getConfigName, bo.getConfigName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigType()), SysConfig::getConfigType, bo.getConfigType());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getConfigKey()), SysConfig::getConfigKey, bo.getConfigKey());
|
||||
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
lqw.orderByAsc(SysConfig::getConfigId);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysConfig.class)
|
||||
.likeIfText(SysConfig::getConfigName, bo.getConfigName())
|
||||
.eqIfText(SysConfig::getConfigType, bo.getConfigType())
|
||||
.likeIfText(SysConfig::getConfigKey, bo.getConfigKey())
|
||||
.betweenParams(SysConfig::getCreateTime, params, "beginTime", "endTime")
|
||||
.orderByAsc(SysConfig::getConfigId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,8 +156,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
row = baseMapper.updateById(config);
|
||||
} else {
|
||||
CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey());
|
||||
row = baseMapper.update(config, new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, config.getConfigKey()));
|
||||
row = baseMapper.lambda()
|
||||
.eq(SysConfig::getConfigKey, config.getConfigKey())
|
||||
.updateCount(config);
|
||||
}
|
||||
if (row > 0) {
|
||||
return config.getConfigValue();
|
||||
@@ -200,9 +199,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkConfigKeyUnique(SysConfigBo config) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysConfig>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysConfig::getConfigKey, config.getConfigKey())
|
||||
.ne(ObjectUtil.isNotNull(config.getConfigId()), SysConfig::getConfigId, config.getConfigId()));
|
||||
.neIfPresent(SysConfig::getConfigId, config.getConfigId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -3,7 +3,6 @@ package org.dromara.system.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
@@ -44,10 +43,10 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
if (ObjectUtil.isNull(roleId)) {
|
||||
return "-1";
|
||||
}
|
||||
List<SysRoleDept> list = roleDeptMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRoleDept>()
|
||||
.select(SysRoleDept::getDeptId)
|
||||
.eq(SysRoleDept::getRoleId, roleId));
|
||||
List<SysRoleDept> list = roleDeptMapper.lambda()
|
||||
.select(SysRoleDept::getDeptId)
|
||||
.eq(SysRoleDept::getRoleId, roleId)
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
return StreamUtils.join(list, rd -> Convert.toStr(rd.getDeptId()));
|
||||
}
|
||||
|
||||
+39
-41
@@ -6,8 +6,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
@@ -16,7 +14,8 @@ import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.common.mybatis.core.query.LambdaQueryBuilder;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.DeptService;
|
||||
@@ -97,27 +96,23 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
private LambdaQueryWrapper<SysDept> buildQueryWrapper(SysDeptBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysDept> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SysDept::getDelFlag, SystemConstants.NORMAL);
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId());
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDeptCategory()), SysDept::getDeptCategory, bo.getDeptCategory());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
|
||||
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysDept::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
lqw.orderByAsc(SysDept::getAncestors);
|
||||
lqw.orderByAsc(SysDept::getParentId);
|
||||
lqw.orderByAsc(SysDept::getOrderNum);
|
||||
lqw.orderByAsc(SysDept::getDeptId);
|
||||
LambdaQueryBuilder<SysDept> builder = QueryBuilder.lambda(SysDept.class)
|
||||
.eq(SysDept::getDelFlag, SystemConstants.NORMAL)
|
||||
.eqIfPresent(SysDept::getDeptId, bo.getDeptId())
|
||||
.eqIfPresent(SysDept::getParentId, bo.getParentId())
|
||||
.likeIfText(SysDept::getDeptName, bo.getDeptName())
|
||||
.likeIfText(SysDept::getDeptCategory, bo.getDeptCategory())
|
||||
.eqIfText(SysDept::getStatus, bo.getStatus())
|
||||
.betweenParams(SysDept::getCreateTime, params, "beginTime", "endTime")
|
||||
.orderByAsc(SysDept::getAncestors, SysDept::getParentId, SysDept::getOrderNum, SysDept::getDeptId);
|
||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
lqw.and(x -> {
|
||||
builder.and(x -> {
|
||||
List<Long> deptIds = baseMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysDept::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
return lqw;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,8 +164,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
if (ObjectUtil.isNull(dept)) {
|
||||
return null;
|
||||
}
|
||||
SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
|
||||
SysDeptVo parentDept = baseMapper.lambda()
|
||||
.select(SysDept::getDeptName)
|
||||
.eq(SysDept::getDeptId, dept.getParentId())
|
||||
.voOne();
|
||||
dept.setParentName(ObjectUtils.notNullGetter(parentDept, SysDeptVo::getDeptName));
|
||||
return dept;
|
||||
}
|
||||
@@ -183,10 +180,11 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysDeptVo> selectDeptByIds(Collection<Long> deptIds) {
|
||||
return baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
|
||||
return baseMapper.selectDeptList(baseMapper.lambda()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getLeader)
|
||||
.eq(SysDept::getStatus, SystemConstants.NORMAL)
|
||||
.in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds));
|
||||
.in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,9 +224,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public List<DeptDTO> selectDeptsByList() {
|
||||
List<SysDeptVo> list = baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
|
||||
List<SysDeptVo> list = baseMapper.selectDeptList(baseMapper.lambda()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId)
|
||||
.eq(SysDept::getStatus, SystemConstants.NORMAL));
|
||||
.eq(SysDept::getStatus, SystemConstants.NORMAL)
|
||||
.build());
|
||||
return BeanUtil.copyToList(list, DeptDTO.class);
|
||||
}
|
||||
|
||||
@@ -240,9 +239,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public long selectNormalChildrenDeptById(Long deptId) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
||||
return baseMapper.lambda()
|
||||
.eq(SysDept::getStatus, SystemConstants.NORMAL)
|
||||
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
||||
.findInSet(deptId, SysDept::getAncestors)
|
||||
.count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,8 +253,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByDeptId(Long deptId) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getParentId, deptId));
|
||||
return baseMapper.lambda().eq(SysDept::getParentId, deptId).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,8 +264,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId) {
|
||||
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getDeptId, deptId));
|
||||
return userMapper.lambda().eq(SysUser::getDeptId, deptId).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,10 +275,11 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptNameUnique(SysDeptBo dept) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysDept::getDeptName, dept.getDeptName())
|
||||
.eq(SysDept::getParentId, dept.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
||||
.neIfPresent(SysDept::getDeptId, dept.getDeptId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -374,9 +373,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
private void updateParentDeptStatusNormal(SysDept dept) {
|
||||
String ancestors = dept.getAncestors();
|
||||
Long[] deptIds = Convert.toLongArray(ancestors);
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
|
||||
baseMapper.lambda()
|
||||
.set(SysDept::getStatus, SystemConstants.NORMAL)
|
||||
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
||||
.in(SysDept::getDeptId, Arrays.asList(deptIds))
|
||||
.update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,8 +387,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
* @param oldAncestors 旧的父ID集合
|
||||
*/
|
||||
private void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
||||
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
||||
List<SysDept> children = baseMapper.lambda().findInSet(deptId, SysDept::getAncestors).list();
|
||||
List<SysDept> list = new ArrayList<>();
|
||||
for (SysDept child : children) {
|
||||
SysDept dept = new SysDept();
|
||||
@@ -430,11 +429,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysDept> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
);
|
||||
List<SysDept> list = baseMapper.lambda()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -1,16 +1,14 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
import org.dromara.system.domain.SysDictData;
|
||||
import org.dromara.system.domain.bo.SysDictDataBo;
|
||||
@@ -67,12 +65,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
* @return 包含排序号、标签和字典类型条件的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysDictData> buildQueryWrapper(SysDictDataBo bo) {
|
||||
LambdaQueryWrapper<SysDictData> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getDictSort() != null, SysDictData::getDictSort, bo.getDictSort());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDictLabel()), SysDictData::getDictLabel, bo.getDictLabel());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDictType()), SysDictData::getDictType, bo.getDictType());
|
||||
lqw.orderByAsc(SysDictData::getDictSort, SysDictData::getDictCode);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysDictData.class)
|
||||
.eqIfPresent(SysDictData::getDictSort, bo.getDictSort())
|
||||
.likeIfText(SysDictData::getDictLabel, bo.getDictLabel())
|
||||
.eqIfText(SysDictData::getDictType, bo.getDictType())
|
||||
.orderByAsc(SysDictData::getDictSort, SysDictData::getDictCode)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,10 +82,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
*/
|
||||
@Override
|
||||
public String selectDictLabel(String dictType, String dictValue) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||
.select(SysDictData::getDictLabel)
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.eq(SysDictData::getDictValue, dictValue))
|
||||
return baseMapper.lambda()
|
||||
.select(SysDictData::getDictLabel)
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.eq(SysDictData::getDictValue, dictValue)
|
||||
.one()
|
||||
.getDictLabel();
|
||||
}
|
||||
|
||||
@@ -156,10 +155,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDictDataUnique(SysDictDataBo dict) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictData>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysDictData::getDictType, dict.getDictType())
|
||||
.eq(SysDictData::getDictValue, dict.getDictValue())
|
||||
.ne(ObjectUtil.isNotNull(dict.getDictCode()), SysDictData::getDictCode, dict.getDictCode()));
|
||||
.neIfPresent(SysDictData::getDictCode, dict.getDictCode())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
@@ -19,6 +17,7 @@ import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
import org.dromara.system.domain.SysDictData;
|
||||
import org.dromara.system.domain.SysDictType;
|
||||
@@ -81,11 +80,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
* @return 包含名称、类型与创建时间区间的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysDictType> buildQueryWrapper(SysDictTypeBo bo) {
|
||||
LambdaQueryWrapper<SysDictType> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDictName()), SysDictType::getDictName, bo.getDictName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SysDictType::getDictType, bo.getDictType());
|
||||
lqw.orderByAsc(SysDictType::getDictId);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysDictType.class)
|
||||
.likeIfText(SysDictType::getDictName, bo.getDictName())
|
||||
.likeIfText(SysDictType::getDictType, bo.getDictType())
|
||||
.orderByAsc(SysDictType::getDictId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +130,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType")
|
||||
@Override
|
||||
public SysDictTypeVo selectDictTypeByType(String dictType) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||
return baseMapper.lambda().eq(SysDictType::getDictType, dictType).voOne();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,8 +142,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
public void deleteDictTypeByIds(Collection<Long> dictIds) {
|
||||
List<SysDictType> list = baseMapper.selectByIds(dictIds);
|
||||
list.forEach(x -> {
|
||||
boolean assigned = dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, x.getDictType()));
|
||||
boolean assigned = dictDataMapper.lambda().eq(SysDictData::getDictType, x.getDictType()).exists();
|
||||
if (assigned) {
|
||||
throw new ServiceException("{}已分配,不能删除", x.getDictName());
|
||||
}
|
||||
@@ -195,9 +193,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
public List<SysDictDataVo> updateDictType(SysDictTypeBo bo) {
|
||||
SysDictType dict = MapstructUtils.convert(bo, SysDictType.class);
|
||||
SysDictType oldDict = baseMapper.selectById(dict.getDictId());
|
||||
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
|
||||
dictDataMapper.lambda()
|
||||
.set(SysDictData::getDictType, dict.getDictType())
|
||||
.eq(SysDictData::getDictType, oldDict.getDictType()));
|
||||
.eq(SysDictData::getDictType, oldDict.getDictType())
|
||||
.update();
|
||||
int row = baseMapper.updateById(dict);
|
||||
if (row > 0) {
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
|
||||
@@ -215,9 +214,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDictTypeUnique(SysDictTypeBo dictType) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysDictType::getDictType, dictType.getDictType())
|
||||
.ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId()));
|
||||
.neIfPresent(SysDictType::getDictId, dictType.getDictId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
|
||||
+19
-16
@@ -3,7 +3,6 @@ package org.dromara.system.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -16,6 +15,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
||||
import org.dromara.common.log.event.LoginInfoEvent;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.mapper.LambdaCrudChainWrapper;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.SysLoginInfo;
|
||||
import org.dromara.system.domain.bo.SysLoginInfoBo;
|
||||
@@ -122,13 +122,7 @@ public class SysLoginInfoServiceImpl implements ISysLoginInfoService {
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SysLoginInfoVo> selectPageLoginInfoList(SysLoginInfoBo loginInfo, PageQuery pageQuery) {
|
||||
Map<String, Object> params = loginInfo.getParams();
|
||||
LambdaQueryWrapper<SysLoginInfo> lqw = new LambdaQueryWrapper<SysLoginInfo>()
|
||||
.like(StringUtils.isNotBlank(loginInfo.getIpaddr()), SysLoginInfo::getIpaddr, loginInfo.getIpaddr())
|
||||
.eq(StringUtils.isNotBlank(loginInfo.getStatus()), SysLoginInfo::getStatus, loginInfo.getStatus())
|
||||
.like(StringUtils.isNotBlank(loginInfo.getUserName()), SysLoginInfo::getUserName, loginInfo.getUserName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysLoginInfo::getLoginTime, params.get("beginTime"), params.get("endTime"));
|
||||
LambdaCrudChainWrapper<SysLoginInfo, SysLoginInfoVo> lqw = buildQueryWrapper(loginInfo);
|
||||
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
lqw.orderByDesc(SysLoginInfo::getInfoId);
|
||||
}
|
||||
@@ -156,16 +150,25 @@ public class SysLoginInfoServiceImpl implements ISysLoginInfoService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysLoginInfoVo> selectLoginInfoList(SysLoginInfoBo loginInfo) {
|
||||
Map<String, Object> params = loginInfo.getParams();
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysLoginInfo>()
|
||||
.like(StringUtils.isNotBlank(loginInfo.getIpaddr()), SysLoginInfo::getIpaddr, loginInfo.getIpaddr())
|
||||
.eq(StringUtils.isNotBlank(loginInfo.getStatus()), SysLoginInfo::getStatus, loginInfo.getStatus())
|
||||
.like(StringUtils.isNotBlank(loginInfo.getUserName()), SysLoginInfo::getUserName, loginInfo.getUserName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysLoginInfo::getLoginTime, params.get("beginTime"), params.get("endTime"))
|
||||
return baseMapper.selectVoList(buildQueryWrapper(loginInfo)
|
||||
.orderByDesc(SysLoginInfo::getInfoId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造登录日志列表查询条件。
|
||||
*
|
||||
* @param loginInfo 登录日志筛选条件
|
||||
* @return 登录日志查询包装器
|
||||
*/
|
||||
private LambdaCrudChainWrapper<SysLoginInfo, SysLoginInfoVo> buildQueryWrapper(SysLoginInfoBo loginInfo) {
|
||||
Map<String, Object> params = loginInfo.getParams();
|
||||
return baseMapper.lambda()
|
||||
.likeIfText(SysLoginInfo::getIpaddr, loginInfo.getIpaddr())
|
||||
.eqIfText(SysLoginInfo::getStatus, loginInfo.getStatus())
|
||||
.likeIfText(SysLoginInfo::getUserName, loginInfo.getUserName())
|
||||
.betweenParams(SysLoginInfo::getLoginTime, params, "beginTime", "endTime");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
@@ -182,6 +185,6 @@ public class SysLoginInfoServiceImpl implements ISysLoginInfoService {
|
||||
*/
|
||||
@Override
|
||||
public void cleanLoginInfo() {
|
||||
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||
baseMapper.lambda().delete();
|
||||
}
|
||||
}
|
||||
|
||||
+23
-21
@@ -3,7 +3,6 @@ package org.dromara.system.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
@@ -64,15 +63,15 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
public List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId) {
|
||||
// 管理员显示所有菜单信息 不是管理员 按用户id过滤菜单
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
return baseMapper.selectVoList(
|
||||
new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.eq(StringUtils.isNotBlank(menu.getMenuType()), SysMenu::getMenuType, menu.getMenuType())
|
||||
.eq(ObjectUtil.isNotNull(menu.getParentId()), SysMenu::getParentId, menu.getParentId())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
return baseMapper.lambda()
|
||||
.likeIfText(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eqIfText(SysMenu::getVisible, menu.getVisible())
|
||||
.eqIfText(SysMenu::getStatus, menu.getStatus())
|
||||
.eqIfText(SysMenu::getMenuType, menu.getMenuType())
|
||||
.eqIfPresent(SysMenu::getParentId, menu.getParentId())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum)
|
||||
.voList();
|
||||
}
|
||||
return baseMapper.selectMenuListByUserId(menu, userId);
|
||||
}
|
||||
@@ -246,7 +245,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
||||
return baseMapper.lambda().eq(SysMenu::getParentId, menuId).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +256,10 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Collection<Long> menuIds) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().in(SysMenu::getParentId, menuIds).notIn(SysMenu::getMenuId, menuIds));
|
||||
return baseMapper.lambda()
|
||||
.in(SysMenu::getParentId, menuIds)
|
||||
.notIn(SysMenu::getMenuId, menuIds)
|
||||
.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +270,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
||||
return roleMenuMapper.lambda().eq(SysRoleMenu::getMenuId, menuId).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,10 +328,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuNameUnique(SysMenuBo menu) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
|
||||
.neIfPresent(SysMenu::getMenuId, menu.getMenuId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -349,12 +352,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
Long parentId = menu.getParentId();
|
||||
String path = menu.getPath();
|
||||
String routeName = StringUtils.isEmpty(menu.getRouteName()) ? path : menu.getRouteName();
|
||||
List<SysMenu> sysMenuList = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysMenu>()
|
||||
.in(SysMenu::getMenuType, SystemConstants.TYPE_DIR, SystemConstants.TYPE_MENU)
|
||||
.and(w ->
|
||||
w.eq(SysMenu::getPath, path).or().eq(SysMenu::getPath, routeName)
|
||||
));
|
||||
List<SysMenu> sysMenuList = baseMapper.lambda()
|
||||
.in(SysMenu::getMenuType, SystemConstants.TYPE_DIR, SystemConstants.TYPE_MENU)
|
||||
.and(w -> {
|
||||
w.eq(SysMenu::getPath, path).or().eq(SysMenu::getPath, routeName);
|
||||
}).list();
|
||||
for (SysMenu sysMenu : sysMenuList) {
|
||||
if (!sysMenu.getMenuId().equals(menuId)) {
|
||||
Long dbParentId = sysMenu.getParentId();
|
||||
|
||||
+13
-17
@@ -2,8 +2,6 @@ package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.enums.PushSourceEnum;
|
||||
@@ -11,7 +9,6 @@ import org.dromara.common.core.enums.PushTypeEnum;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.common.mybatis.utils.IdGeneratorUtil;
|
||||
import org.dromara.common.push.helper.PushHelper;
|
||||
import org.dromara.system.api.MessageService;
|
||||
@@ -207,20 +204,19 @@ public class SysMessageServiceImpl implements ISysMessageService, MessageService
|
||||
* @return 消息VO列表
|
||||
*/
|
||||
private List<SysMessageVo> selectMessageList(String category, Long userId) {
|
||||
LambdaQueryWrapper<SysMessage> lqw = Wrappers.lambdaQuery();
|
||||
// 分类匹配
|
||||
lqw.eq(SysMessage::getCategory, category);
|
||||
// 仅查询30天内消息
|
||||
lqw.ge(SysMessage::getCreateTime, LocalDateTime.now().minusDays(BOX_DAYS));
|
||||
// 全局消息 或 当前用户在接收人范围内
|
||||
lqw.and(wrapper -> wrapper.eq(SysMessage::getSendUserIds, GLOBAL_USER_IDS)
|
||||
.or()
|
||||
.apply(DataBaseHelper.findInSet(userId, "send_user_ids")));
|
||||
// 按创建时间+消息ID倒序
|
||||
lqw.orderByDesc(SysMessage::getCreateTime, SysMessage::getMessageId);
|
||||
// 分页查询(只查第一页,最多100条)
|
||||
List<SysMessage> list = baseMapper.selectList(new Page<>(1, BOX_LIMIT, false), lqw);
|
||||
// 转换为VO并返回
|
||||
List<SysMessage> list = baseMapper.lambda()
|
||||
.eq(SysMessage::getCategory, category)
|
||||
// 仅查询30天内消息
|
||||
.ge(SysMessage::getCreateTime, LocalDateTime.now().minusDays(BOX_DAYS))
|
||||
// 全局消息 或 当前用户在接收人范围内
|
||||
.and(wrapper -> {
|
||||
wrapper.eq(SysMessage::getSendUserIds, GLOBAL_USER_IDS)
|
||||
.or()
|
||||
.findInSet(userId, SysMessage::getSendUserIds);
|
||||
})
|
||||
.orderByDesc(SysMessage::getCreateTime, SysMessage::getMessageId)
|
||||
// 分页查询(只查第一页,最多100条)
|
||||
.list(new Page<>(1, BOX_LIMIT, false));
|
||||
return list.stream().map(this::buildVo).toList();
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -1,7 +1,6 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
@@ -9,6 +8,8 @@ import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.LambdaQueryBuilder;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.system.domain.SysNotice;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.bo.SysNoticeBo;
|
||||
@@ -78,15 +79,14 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
* @return 包含标题、类型、创建人和排序条件的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysNotice> buildQueryWrapper(SysNoticeBo bo) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getNoticeTitle()), SysNotice::getNoticeTitle, bo.getNoticeTitle());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getNoticeType()), SysNotice::getNoticeType, bo.getNoticeType());
|
||||
LambdaQueryBuilder<SysNotice> builder = QueryBuilder.lambda(SysNotice.class)
|
||||
.likeIfText(SysNotice::getNoticeTitle, bo.getNoticeTitle())
|
||||
.eqIfText(SysNotice::getNoticeType, bo.getNoticeType());
|
||||
if (StringUtils.isNotBlank(bo.getCreateByName())) {
|
||||
SysUserVo sysUser = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, bo.getCreateByName()));
|
||||
lqw.eq(SysNotice::getCreateBy, ObjectUtils.notNullGetter(sysUser, SysUserVo::getUserId));
|
||||
SysUserVo sysUser = userMapper.lambda().eq(SysUser::getUserName, bo.getCreateByName()).voOne();
|
||||
builder.eq(SysNotice::getCreateBy, ObjectUtils.notNullGetter(sysUser, SysUserVo::getUserId));
|
||||
}
|
||||
lqw.orderByAsc(SysNotice::getNoticeId);
|
||||
return lqw;
|
||||
return builder.orderByAsc(SysNotice::getNoticeId).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+15
-15
@@ -10,6 +10,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
||||
import org.dromara.common.log.event.OperLogEvent;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.system.domain.SysOperLog;
|
||||
import org.dromara.system.domain.bo.SysOperLogBo;
|
||||
import org.dromara.system.domain.vo.SysOperLogVo;
|
||||
@@ -74,9 +75,9 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
||||
*/
|
||||
private LambdaQueryWrapper<SysOperLog> buildQueryWrapper(SysOperLogBo operLog) {
|
||||
Map<String, Object> params = operLog.getParams();
|
||||
return new LambdaQueryWrapper<SysOperLog>()
|
||||
.like(StringUtils.isNotBlank(operLog.getOperIp()), SysOperLog::getOperIp, operLog.getOperIp())
|
||||
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
||||
return QueryBuilder.lambda(SysOperLog.class)
|
||||
.likeIfText(SysOperLog::getOperIp, operLog.getOperIp())
|
||||
.likeIfText(SysOperLog::getTitle, operLog.getTitle())
|
||||
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
||||
SysOperLog::getBusinessType, operLog.getBusinessType())
|
||||
.func(f -> {
|
||||
@@ -84,17 +85,16 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
||||
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
|
||||
}
|
||||
})
|
||||
.eq(operLog.getStatus() != null,
|
||||
SysOperLog::getStatus, operLog.getStatus())
|
||||
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
|
||||
.eq(operLog.getUserId() != null, SysOperLog::getUserId, operLog.getUserId())
|
||||
.eq(operLog.getDeptId() != null, SysOperLog::getDeptId, operLog.getDeptId())
|
||||
.eq(StringUtils.isNotBlank(operLog.getClientKey()), SysOperLog::getClientKey, operLog.getClientKey())
|
||||
.eq(StringUtils.isNotBlank(operLog.getDeviceType()), SysOperLog::getDeviceType, operLog.getDeviceType())
|
||||
.like(StringUtils.isNotBlank(operLog.getBrowser()), SysOperLog::getBrowser, operLog.getBrowser())
|
||||
.like(StringUtils.isNotBlank(operLog.getOs()), SysOperLog::getOs, operLog.getOs())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
|
||||
.eqIfPresent(SysOperLog::getStatus, operLog.getStatus())
|
||||
.likeIfText(SysOperLog::getOperName, operLog.getOperName())
|
||||
.eqIfPresent(SysOperLog::getUserId, operLog.getUserId())
|
||||
.eqIfPresent(SysOperLog::getDeptId, operLog.getDeptId())
|
||||
.eqIfText(SysOperLog::getClientKey, operLog.getClientKey())
|
||||
.eqIfText(SysOperLog::getDeviceType, operLog.getDeviceType())
|
||||
.likeIfText(SysOperLog::getBrowser, operLog.getBrowser())
|
||||
.likeIfText(SysOperLog::getOs, operLog.getOs())
|
||||
.betweenParams(SysOperLog::getOperTime, params, "beginTime", "endTime")
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,6 +148,6 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
||||
*/
|
||||
@Override
|
||||
public void cleanOperLog() {
|
||||
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||
baseMapper.lambda().delete();
|
||||
}
|
||||
}
|
||||
|
||||
+18
-19
@@ -3,8 +3,6 @@ package org.dromara.system.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -17,6 +15,7 @@ import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.oss.constant.OssConstant;
|
||||
import org.dromara.common.redis.utils.CacheUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
@@ -94,12 +93,12 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
* @return 包含配置标识、桶名称和状态条件的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysOssConfig> buildQueryWrapper(SysOssConfigBo bo) {
|
||||
LambdaQueryWrapper<SysOssConfig> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigKey()), SysOssConfig::getConfigKey, bo.getConfigKey());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getBucketName()), SysOssConfig::getBucketName, bo.getBucketName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysOssConfig::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(SysOssConfig::getOssConfigId);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysOssConfig.class)
|
||||
.eqIfText(SysOssConfig::getConfigKey, bo.getConfigKey())
|
||||
.likeIfText(SysOssConfig::getBucketName, bo.getBucketName())
|
||||
.eqIfText(SysOssConfig::getStatus, bo.getStatus())
|
||||
.orderByAsc(SysOssConfig::getOssConfigId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,13 +130,13 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
public Boolean updateByBo(SysOssConfigBo bo) {
|
||||
SysOssConfig config = MapstructUtils.convert(bo, SysOssConfig.class);
|
||||
validEntityBeforeSave(config);
|
||||
LambdaUpdateWrapper<SysOssConfig> luw = new LambdaUpdateWrapper<>();
|
||||
luw.set(ObjectUtil.isNull(config.getPrefix()), SysOssConfig::getPrefix, "");
|
||||
luw.set(ObjectUtil.isNull(config.getRegion()), SysOssConfig::getRegion, "");
|
||||
luw.set(ObjectUtil.isNull(config.getExt1()), SysOssConfig::getExt1, "");
|
||||
luw.set(ObjectUtil.isNull(config.getRemark()), SysOssConfig::getRemark, "");
|
||||
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
|
||||
boolean flag = baseMapper.update(config, luw) > 0;
|
||||
boolean flag = baseMapper.lambda()
|
||||
.set(ObjectUtil.isNull(config.getPrefix()), SysOssConfig::getPrefix, "")
|
||||
.set(ObjectUtil.isNull(config.getRegion()), SysOssConfig::getRegion, "")
|
||||
.set(ObjectUtil.isNull(config.getExt1()), SysOssConfig::getExt1, "")
|
||||
.set(ObjectUtil.isNull(config.getRemark()), SysOssConfig::getRemark, "")
|
||||
.eq(SysOssConfig::getOssConfigId, config.getOssConfigId())
|
||||
.update(config);
|
||||
if (flag) {
|
||||
// 从数据库查询完整的数据做缓存
|
||||
config = baseMapper.selectById(config.getOssConfigId());
|
||||
@@ -193,9 +192,10 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
*/
|
||||
private boolean checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
||||
long ossConfigId = ObjectUtils.notNull(sysOssConfig.getOssConfigId(), -1L);
|
||||
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||
SysOssConfig info = baseMapper.lambda()
|
||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())
|
||||
.one();
|
||||
if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
||||
return false;
|
||||
}
|
||||
@@ -212,8 +212,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateOssConfigStatus(SysOssConfigBo bo) {
|
||||
SysOssConfig sysOssConfig = MapstructUtils.convert(bo, SysOssConfig.class);
|
||||
int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>()
|
||||
.set(SysOssConfig::getStatus, SystemConstants.NO));
|
||||
int row = baseMapper.lambda().set(SysOssConfig::getStatus, SystemConstants.NO).updateCount();
|
||||
row += baseMapper.updateById(sysOssConfig);
|
||||
if (row > 0) {
|
||||
RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, sysOssConfig.getConfigKey());
|
||||
|
||||
+11
-12
@@ -5,7 +5,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,6 +18,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.oss.client.OssClient;
|
||||
import org.dromara.common.oss.enums.AccessPolicy;
|
||||
import org.dromara.common.oss.factory.OssFactory;
|
||||
@@ -157,17 +157,16 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
*/
|
||||
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName, bo.getOriginalName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
|
||||
lqw.orderByAsc(SysOss::getOssId);
|
||||
return lqw;
|
||||
return QueryBuilder.lambda(SysOss.class)
|
||||
.likeIfText(SysOss::getFileName, bo.getFileName())
|
||||
.likeIfText(SysOss::getOriginalName, bo.getOriginalName())
|
||||
.eqIfText(SysOss::getFileSuffix, bo.getFileSuffix())
|
||||
.eqIfText(SysOss::getUrl, bo.getUrl())
|
||||
.betweenParams(SysOss::getCreateTime, params, "beginCreateTime", "endCreateTime")
|
||||
.eqIfPresent(SysOss::getCreateBy, bo.getCreateBy())
|
||||
.eqIfText(SysOss::getService, bo.getService())
|
||||
.orderByAsc(SysOss::getOssId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+24
-25
@@ -2,8 +2,7 @@ package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
@@ -11,7 +10,6 @@ import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.system.api.PostService;
|
||||
import org.dromara.system.domain.SysPost;
|
||||
@@ -83,15 +81,14 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
* @param bo 查询条件对象
|
||||
* @return 构建好的查询包装器
|
||||
*/
|
||||
private LambdaQueryWrapper<SysPost> buildQueryWrapper(SysPostBo bo) {
|
||||
private Wrapper<SysPost> buildQueryWrapper(SysPostBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysPost> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StringUtils.isNotBlank(bo.getPostCode()), SysPost::getPostCode, bo.getPostCode())
|
||||
.like(StringUtils.isNotBlank(bo.getPostCategory()), SysPost::getPostCategory, bo.getPostCategory())
|
||||
.like(StringUtils.isNotBlank(bo.getPostName()), SysPost::getPostName, bo.getPostName())
|
||||
.eq(StringUtils.isNotBlank(bo.getStatus()), SysPost::getStatus, bo.getStatus())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysPost::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
var wrapper = baseMapper.lambda()
|
||||
.likeIfText(SysPost::getPostCode, bo.getPostCode())
|
||||
.likeIfText(SysPost::getPostCategory, bo.getPostCategory())
|
||||
.likeIfText(SysPost::getPostName, bo.getPostName())
|
||||
.eqIfText(SysPost::getStatus, bo.getStatus())
|
||||
.betweenParams(SysPost::getCreateTime, params, "beginTime", "endTime")
|
||||
.orderByAsc(SysPost::getPostSort);
|
||||
if (ObjectUtil.isNotNull(bo.getDeptId())) {
|
||||
//优先单部门搜索
|
||||
@@ -113,7 +110,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysPostVo> selectPostAll() {
|
||||
return baseMapper.selectVoList(new QueryWrapper<>());
|
||||
return baseMapper.lambda().voList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,10 +144,11 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysPostVo> selectPostByIds(Collection<Long> postIds) {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysPost>()
|
||||
return baseMapper.lambda()
|
||||
.select(SysPost::getPostId, SysPost::getPostName, SysPost::getPostCode)
|
||||
.eq(SysPost::getStatus, SystemConstants.NORMAL)
|
||||
.in(CollUtil.isNotEmpty(postIds), SysPost::getPostId, postIds));
|
||||
.in(CollUtil.isNotEmpty(postIds), SysPost::getPostId, postIds)
|
||||
.voList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,10 +159,11 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPostNameUnique(SysPostBo post) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysPost::getPostName, post.getPostName())
|
||||
.eq(SysPost::getDeptId, post.getDeptId())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
.neIfPresent(SysPost::getPostId, post.getPostId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -176,9 +175,10 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPostCodeUnique(SysPostBo post) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysPost::getPostCode, post.getPostCode())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
.neIfPresent(SysPost::getPostId, post.getPostId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public long countUserPostById(Long postId) {
|
||||
return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId));
|
||||
return userPostMapper.lambda().eq(SysUserPost::getPostId, postId).count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
*/
|
||||
@Override
|
||||
public long countPostByDeptId(Long deptId) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<SysPost>().eq(SysPost::getDeptId, deptId));
|
||||
return baseMapper.lambda().eq(SysPost::getDeptId, deptId).count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,11 +267,10 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysPost> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysPost>()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
);
|
||||
List<SysPost> list = baseMapper.lambda()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, SysPost::getPostId, SysPost::getPostName);
|
||||
}
|
||||
|
||||
|
||||
+40
-39
@@ -6,9 +6,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
@@ -19,6 +16,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.RoleService;
|
||||
import org.dromara.system.api.model.LoginUser;
|
||||
@@ -85,15 +83,14 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
private Wrapper<SysRole> buildQueryWrapper(SysRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysRole> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ObjectUtil.isNotNull(bo.getRoleId()), SysRole::getRoleId, bo.getRoleId())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleName()), SysRole::getRoleName, bo.getRoleName())
|
||||
.eq(StringUtils.isNotBlank(bo.getStatus()), SysRole::getStatus, bo.getStatus())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleKey()), SysRole::getRoleKey, bo.getRoleKey())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysRole::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.orderByAsc(SysRole::getRoleSort).orderByAsc(SysRole::getCreateTime);
|
||||
return wrapper;
|
||||
return QueryBuilder.lambda(SysRole.class)
|
||||
.eqIfPresent(SysRole::getRoleId, bo.getRoleId())
|
||||
.likeIfText(SysRole::getRoleName, bo.getRoleName())
|
||||
.eqIfText(SysRole::getStatus, bo.getStatus())
|
||||
.likeIfText(SysRole::getRoleKey, bo.getRoleKey())
|
||||
.betweenParams(SysRole::getCreateTime, params, "beginTime", "endTime")
|
||||
.orderByAsc(SysRole::getRoleSort, SysRole::getCreateTime)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,9 +183,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysRoleVo> selectRoleByIds(Collection<Long> roleIds) {
|
||||
return baseMapper.selectRoleList(new LambdaQueryWrapper<SysRole>()
|
||||
return baseMapper.selectRoleList(baseMapper.lambda()
|
||||
.eq(SysRole::getStatus, SystemConstants.NORMAL)
|
||||
.in(CollUtil.isNotEmpty(roleIds), SysRole::getRoleId, roleIds));
|
||||
.inIfNotEmpty(SysRole::getRoleId, roleIds)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,9 +197,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleNameUnique(SysRoleBo role) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysRole::getRoleName, role.getRoleName())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
.neIfPresent(SysRole::getRoleId, role.getRoleId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -213,9 +212,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleKeyUnique(SysRoleBo role) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
.neIfPresent(SysRole::getRoleId, role.getRoleId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public long countUserRoleByRoleId(Long roleId) {
|
||||
return userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId));
|
||||
return userRoleMapper.lambda().eq(SysUserRole::getRoleId, roleId).count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,10 +337,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
// 更新权限相关配置字段(数据范围、树联动)。
|
||||
baseMapper.updateById(role);
|
||||
// 先清理旧菜单权限,再重建。
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, role.getRoleId()));
|
||||
roleMenuMapper.lambda().eq(SysRoleMenu::getRoleId, role.getRoleId()).delete();
|
||||
insertRoleMenu(bo);
|
||||
// 先清理旧数据权限,再按当前配置重建。
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, role.getRoleId()));
|
||||
roleDeptMapper.lambda().eq(SysRoleDept::getRoleId, role.getRoleId()).delete();
|
||||
return insertRoleDept(bo);
|
||||
}
|
||||
|
||||
@@ -356,10 +356,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
if (SystemConstants.DISABLE.equals(status) && this.countUserRoleByRoleId(roleId) > 0) {
|
||||
throw new ServiceException("角色已分配,不能禁用!");
|
||||
}
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysRole>()
|
||||
.set(SysRole::getStatus, status)
|
||||
.eq(SysRole::getRoleId, roleId));
|
||||
return baseMapper.lambda()
|
||||
.set(SysRole::getStatus, status)
|
||||
.eq(SysRole::getRoleId, roleId)
|
||||
.updateCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -417,9 +417,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleById(Long roleId) {
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
|
||||
roleMenuMapper.lambda().eq(SysRoleMenu::getRoleId, roleId).delete();
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, roleId));
|
||||
roleDeptMapper.lambda().eq(SysRoleDept::getRoleId, roleId).delete();
|
||||
return baseMapper.deleteById(roleId);
|
||||
}
|
||||
|
||||
@@ -442,9 +442,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds));
|
||||
roleMenuMapper.lambda().in(SysRoleMenu::getRoleId, roleIds).delete();
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, roleIds));
|
||||
roleDeptMapper.lambda().in(SysRoleDept::getRoleId, roleIds).delete();
|
||||
return baseMapper.deleteByIds(roleIds);
|
||||
}
|
||||
|
||||
@@ -459,9 +459,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
if (LoginHelper.getUserId().equals(userRole.getUserId())) {
|
||||
throw new ServiceException("不允许修改当前用户角色!");
|
||||
}
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
int rows = userRoleMapper.lambda()
|
||||
.eq(SysUserRole::getRoleId, userRole.getRoleId())
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId()));
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId())
|
||||
.deleteCount();
|
||||
if (rows > 0) {
|
||||
cleanOnlineUser(List.of(userRole.getUserId()));
|
||||
}
|
||||
@@ -480,9 +481,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
if (userIds.contains(LoginHelper.getUserId())) {
|
||||
throw new ServiceException("不允许修改当前用户角色!");
|
||||
}
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
int rows = userRoleMapper.lambda()
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.in(SysUserRole::getUserId, userIds));
|
||||
.in(SysUserRole::getUserId, userIds)
|
||||
.deleteCount();
|
||||
if (rows > 0) {
|
||||
cleanOnlineUser(userIds);
|
||||
}
|
||||
@@ -532,7 +534,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
@Override
|
||||
public void cleanOnlineUserByRole(Long roleId) {
|
||||
// 如果角色未绑定用户 直接返回
|
||||
Long num = userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId));
|
||||
Long num = userRoleMapper.lambda().eq(SysUserRole::getRoleId, roleId).count();
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -607,11 +609,10 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysRole> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
);
|
||||
List<SysRole> list = baseMapper.lambda()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, SysRole::getRoleId, SysRole::getRoleName);
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -1,10 +1,7 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.system.domain.SysSocial;
|
||||
import org.dromara.system.domain.bo.SysSocialBo;
|
||||
import org.dromara.system.domain.vo.SysSocialVo;
|
||||
@@ -46,11 +43,11 @@ public class SysSocialServiceImpl implements ISysSocialService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysSocialVo> queryList(SysSocialBo bo) {
|
||||
LambdaQueryWrapper<SysSocial> lqw = new LambdaQueryWrapper<SysSocial>()
|
||||
.eq(ObjectUtil.isNotNull(bo.getUserId()), SysSocial::getUserId, bo.getUserId())
|
||||
.eq(StringUtils.isNotBlank(bo.getAuthId()), SysSocial::getAuthId, bo.getAuthId())
|
||||
.eq(StringUtils.isNotBlank(bo.getSource()), SysSocial::getSource, bo.getSource());
|
||||
return baseMapper.selectVoList(lqw);
|
||||
return baseMapper.lambda()
|
||||
.eqIfPresent(SysSocial::getUserId, bo.getUserId())
|
||||
.eqIfText(SysSocial::getAuthId, bo.getAuthId())
|
||||
.eqIfText(SysSocial::getSource, bo.getSource())
|
||||
.voList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +58,7 @@ public class SysSocialServiceImpl implements ISysSocialService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysSocialVo> queryListByUserId(Long userId) {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getUserId, userId));
|
||||
return baseMapper.lambda().eq(SysSocial::getUserId, userId).voList();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +126,7 @@ public class SysSocialServiceImpl implements ISysSocialService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysSocialVo> selectByAuthId(String authId) {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId));
|
||||
return baseMapper.lambda().eq(SysSocial::getAuthId, authId).voList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+88
-77
@@ -7,8 +7,6 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,6 +16,7 @@ import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.UserService;
|
||||
import org.dromara.system.api.domain.UserDTO;
|
||||
@@ -88,20 +87,21 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
private Wrapper<SysUser> buildQueryWrapper(SysUserBo user) {
|
||||
Map<String, Object> params = user.getParams();
|
||||
LambdaQueryWrapper<SysUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(SysUser::getDelFlag, SystemConstants.NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())
|
||||
LambdaQueryWrapper<SysUser> wrapper = QueryBuilder.lambda(SysUser.class)
|
||||
.eq(SysUser::getDelFlag, SystemConstants.NORMAL)
|
||||
.eqIfPresent(SysUser::getUserId, user.getUserId())
|
||||
.in(StringUtils.isNotBlank(user.getUserIds()), SysUser::getUserId, StringUtils.splitTo(user.getUserIds(), Convert::toLong))
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), SysUser::getUserName, user.getUserName())
|
||||
.like(StringUtils.isNotBlank(user.getNickName()), SysUser::getNickName, user.getNickName())
|
||||
.eq(StringUtils.isNotBlank(user.getStatus()), SysUser::getStatus, user.getStatus())
|
||||
.like(StringUtils.isNotBlank(user.getPhoneNumber()), SysUser::getPhoneNumber, user.getPhoneNumber())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.likeIfText(SysUser::getUserName, user.getUserName())
|
||||
.likeIfText(SysUser::getNickName, user.getNickName())
|
||||
.eqIfText(SysUser::getStatus, user.getStatus())
|
||||
.likeIfText(SysUser::getPhoneNumber, user.getPhoneNumber())
|
||||
.betweenParams(SysUser::getCreateTime, params, "beginTime", "endTime")
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<Long> ids = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in(SysUser::getDeptId, ids);
|
||||
}).orderByAsc(SysUser::getUserId);
|
||||
})
|
||||
.orderByAsc(SysUser::getUserId)
|
||||
.build();
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
wrapper.notIn(SysUser::getUserId, StringUtils.splitTo(user.getExcludeUserIds(), Convert::toLong));
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public SysUserVo selectUserByUserName(String userName) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||
return baseMapper.lambda().eq(SysUser::getUserName, userName).voOne();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public SysUserVo selectUserByPhoneNumber(String phoneNumber) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phoneNumber));
|
||||
return baseMapper.lambda().eq(SysUser::getPhoneNumber, phoneNumber).voOne();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,11 +180,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> selectUserByIds(Collection<Long> userIds, Long deptId) {
|
||||
return baseMapper.selectUserList(new LambdaQueryWrapper<SysUser>()
|
||||
return baseMapper.selectUserList(baseMapper.lambda()
|
||||
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName)
|
||||
.eq(SysUser::getStatus, SystemConstants.NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId)
|
||||
.in(CollUtil.isNotEmpty(userIds), SysUser::getUserId, userIds));
|
||||
.eqIfPresent(SysUser::getDeptId, deptId)
|
||||
.inIfNotEmpty(SysUser::getUserId, userIds)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,9 +226,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUserNameUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysUser::getUserName, user.getUserName())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
.neIfPresent(SysUser::getUserId, user.getUserId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -238,9 +240,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPhoneUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysUser::getPhoneNumber, user.getPhoneNumber())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
.neIfPresent(SysUser::getUserId, user.getUserId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -251,9 +254,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(SysUser::getEmail, user.getEmail())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
.neIfPresent(SysUser::getUserId, user.getUserId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -365,10 +369,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(Long userId, String status) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getStatus, status)
|
||||
.eq(SysUser::getUserId, userId));
|
||||
return baseMapper.lambda()
|
||||
.set(SysUser::getStatus, status)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.updateCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,13 +384,13 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_NICKNAME, key = "#user.userId")
|
||||
@Override
|
||||
public int updateUserProfile(SysUserBo user) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(ObjectUtil.isNotNull(user.getNickName()), SysUser::getNickName, user.getNickName())
|
||||
.set(SysUser::getPhoneNumber, user.getPhoneNumber())
|
||||
.set(SysUser::getEmail, user.getEmail())
|
||||
.set(SysUser::getGender, user.getGender())
|
||||
.eq(SysUser::getUserId, user.getUserId()));
|
||||
return baseMapper.lambda()
|
||||
.setIfPresent(SysUser::getNickName, user.getNickName())
|
||||
.set(SysUser::getPhoneNumber, user.getPhoneNumber())
|
||||
.set(SysUser::getEmail, user.getEmail())
|
||||
.set(SysUser::getGender, user.getGender())
|
||||
.eq(SysUser::getUserId, user.getUserId())
|
||||
.updateCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,10 +402,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(Long userId, Long avatar) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getAvatar, avatar)
|
||||
.eq(SysUser::getUserId, userId)) > 0;
|
||||
return baseMapper.lambda()
|
||||
.set(SysUser::getAvatar, avatar)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,10 +417,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(Long userId, String password) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserId, userId));
|
||||
return baseMapper.lambda()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.updateCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +453,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
// 是否清除旧的用户岗位绑定
|
||||
if (clear) {
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, user.getUserId()));
|
||||
userPostMapper.lambda().eq(SysUserPost::getUserId, user.getUserId()).delete();
|
||||
}
|
||||
|
||||
// 构建用户岗位关联列表并批量插入
|
||||
@@ -494,7 +498,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
// 是否清除原有绑定
|
||||
if (clear) {
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
userRoleMapper.lambda().eq(SysUserRole::getUserId, userId).delete();
|
||||
}
|
||||
|
||||
// 批量插入用户-角色关联
|
||||
@@ -518,9 +522,9 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteUserById(Long userId) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
userRoleMapper.lambda().eq(SysUserRole::getUserId, userId).delete();
|
||||
// 删除用户与岗位表
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, userId));
|
||||
userPostMapper.lambda().eq(SysUserPost::getUserId, userId).delete();
|
||||
// 防止更新失败导致的数据删除
|
||||
int flag = baseMapper.deleteById(userId);
|
||||
if (flag < 1) {
|
||||
@@ -544,9 +548,9 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
}
|
||||
List<Long> ids = List.of(userIds);
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
|
||||
userRoleMapper.lambda().in(SysUserRole::getUserId, ids).delete();
|
||||
// 删除用户与岗位表
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
|
||||
userPostMapper.lambda().in(SysUserPost::getUserId, ids).delete();
|
||||
// 防止更新失败导致的数据删除
|
||||
int flag = baseMapper.deleteByIds(ids);
|
||||
if (flag < 1) {
|
||||
@@ -563,10 +567,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> selectUserListByDept(Long deptId) {
|
||||
LambdaQueryWrapper<SysUser> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SysUser::getDeptId, deptId);
|
||||
lqw.orderByAsc(SysUser::getUserId);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
return baseMapper.lambda()
|
||||
.eq(SysUser::getDeptId, deptId)
|
||||
.orderByAsc(SysUser::getUserId)
|
||||
.voList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,8 +582,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserName).eq(SysUser::getUserId, userId));
|
||||
SysUser sysUser = baseMapper.lambda()
|
||||
.select(SysUser::getUserName)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.one();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getUserName);
|
||||
}
|
||||
|
||||
@@ -592,8 +598,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
@Override
|
||||
@Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId")
|
||||
public String selectNicknameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getNickName).eq(SysUser::getUserId, userId));
|
||||
SysUser sysUser = baseMapper.lambda()
|
||||
.select(SysUser::getNickName)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.one();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getNickName);
|
||||
}
|
||||
|
||||
@@ -623,8 +631,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public String selectPhonenumberById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getPhoneNumber).eq(SysUser::getUserId, userId));
|
||||
SysUser sysUser = baseMapper.lambda()
|
||||
.select(SysUser::getPhoneNumber)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.one();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getPhoneNumber);
|
||||
}
|
||||
|
||||
@@ -636,8 +646,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public String selectEmailById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getEmail).eq(SysUser::getUserId, userId));
|
||||
SysUser sysUser = baseMapper.lambda()
|
||||
.select(SysUser::getEmail)
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.one();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getEmail);
|
||||
}
|
||||
|
||||
@@ -649,13 +661,14 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
@Override
|
||||
public UserDTO selectById(Long userId) {
|
||||
SysUserVo vo = baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>()
|
||||
SysUserVo vo = baseMapper.lambda()
|
||||
.select(SysUser::getUserId, SysUser::getDeptId, SysUser::getUserName,
|
||||
SysUser::getNickName, SysUser::getUserType, SysUser::getEmail,
|
||||
SysUser::getPhoneNumber, SysUser::getGender, SysUser::getStatus,
|
||||
SysUser::getCreateTime)
|
||||
.eq(SysUser::getStatus, SystemConstants.NORMAL)
|
||||
.eq(SysUser::getUserId, userId));
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.voOne();
|
||||
return BeanUtil.copyProperties(vo, UserDTO.class);
|
||||
}
|
||||
|
||||
@@ -670,13 +683,14 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return List.of();
|
||||
}
|
||||
List<SysUserVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
|
||||
List<SysUserVo> list = baseMapper.lambda()
|
||||
.select(SysUser::getUserId, SysUser::getDeptId, SysUser::getUserName,
|
||||
SysUser::getNickName, SysUser::getUserType, SysUser::getEmail,
|
||||
SysUser::getPhoneNumber, SysUser::getGender, SysUser::getStatus,
|
||||
SysUser::getCreateTime)
|
||||
.eq(SysUser::getStatus, SystemConstants.NORMAL)
|
||||
.in(SysUser::getUserId, userIds));
|
||||
.in(SysUser::getUserId, userIds)
|
||||
.voList();
|
||||
return BeanUtil.copyToList(list, UserDTO.class);
|
||||
}
|
||||
|
||||
@@ -691,8 +705,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return List.of();
|
||||
}
|
||||
List<SysUserRole> userRoles = userRoleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getRoleId, roleIds));
|
||||
List<SysUserRole> userRoles = userRoleMapper.lambda().in(SysUserRole::getRoleId, roleIds).list();
|
||||
return StreamUtils.toList(userRoles, SysUserRole::getUserId);
|
||||
}
|
||||
|
||||
@@ -709,8 +722,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
}
|
||||
|
||||
// 通过角色ID获取用户角色信息
|
||||
List<SysUserRole> userRoles = userRoleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getRoleId, roleIds));
|
||||
List<SysUserRole> userRoles = userRoleMapper.lambda().in(SysUserRole::getRoleId, roleIds).list();
|
||||
|
||||
// 获取用户ID列表
|
||||
Set<Long> userIds = StreamUtils.toSet(userRoles, SysUserRole::getUserId);
|
||||
@@ -729,10 +741,11 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return List.of();
|
||||
}
|
||||
List<SysUserVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
|
||||
List<SysUserVo> list = baseMapper.lambda()
|
||||
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName, SysUser::getEmail, SysUser::getPhoneNumber)
|
||||
.eq(SysUser::getStatus, SystemConstants.NORMAL)
|
||||
.in(SysUser::getDeptId, deptIds));
|
||||
.in(SysUser::getDeptId, deptIds)
|
||||
.voList();
|
||||
return BeanUtil.copyToList(list, UserDTO.class);
|
||||
}
|
||||
|
||||
@@ -749,8 +762,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
}
|
||||
|
||||
// 通过岗位ID获取用户岗位信息
|
||||
List<SysUserPost> userPosts = userPostMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getPostId, postIds));
|
||||
List<SysUserPost> userPosts = userPostMapper.lambda().in(SysUserPost::getPostId, postIds).list();
|
||||
|
||||
// 获取用户ID列表
|
||||
Set<Long> userIds = StreamUtils.toSet(userPosts, SysUserPost::getUserId);
|
||||
@@ -769,11 +781,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysUser> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
);
|
||||
List<SysUser> list = baseMapper.lambda()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, SysUser::getUserId, SysUser::getNickName);
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -1,8 +1,6 @@
|
||||
package org.dromara.workflow.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.workflow.domain.FlowCategory;
|
||||
import org.dromara.workflow.domain.vo.FlowCategoryVo;
|
||||
|
||||
@@ -25,9 +23,10 @@ public interface FlwCategoryMapper extends BaseMapperPlus<FlowCategory, FlowCate
|
||||
* @return 包含子流程分类的列表
|
||||
*/
|
||||
default List<FlowCategory> selectListByParentId(Long parentId) {
|
||||
return this.selectList(new LambdaQueryWrapper<FlowCategory>()
|
||||
return this.lambda()
|
||||
.select(FlowCategory::getCategoryId)
|
||||
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
||||
.findInSet(parentId, FlowCategory::getAncestors)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-7
@@ -1,7 +1,6 @@
|
||||
package org.dromara.workflow.mapper;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
|
||||
@@ -23,8 +22,9 @@ public interface FlwInstanceBizExtMapper extends BaseMapperPlus<FlowInstanceBizE
|
||||
*/
|
||||
default int saveOrUpdateByInstanceId(FlowInstanceBizExt entity) {
|
||||
// 查询是否存在
|
||||
FlowInstanceBizExt exist = this.selectOne(new LambdaQueryWrapper<FlowInstanceBizExt>()
|
||||
.eq(FlowInstanceBizExt::getInstanceId, entity.getInstanceId()));
|
||||
FlowInstanceBizExt exist = this.lambda()
|
||||
.eq(FlowInstanceBizExt::getInstanceId, entity.getInstanceId())
|
||||
.one();
|
||||
|
||||
if (ObjectUtil.isNotNull(exist)) {
|
||||
// 存在就带上主键更新
|
||||
@@ -43,8 +43,7 @@ public interface FlwInstanceBizExtMapper extends BaseMapperPlus<FlowInstanceBizE
|
||||
* @return 删除的行数
|
||||
*/
|
||||
default int deleteByInstId(Long instanceId) {
|
||||
return this.delete(new LambdaQueryWrapper<FlowInstanceBizExt>()
|
||||
.eq(FlowInstanceBizExt::getInstanceId, instanceId));
|
||||
return this.lambda().eq(FlowInstanceBizExt::getInstanceId, instanceId).deleteCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +53,7 @@ public interface FlwInstanceBizExtMapper extends BaseMapperPlus<FlowInstanceBizE
|
||||
* @return 删除的行数
|
||||
*/
|
||||
default int deleteByInstIds(Collection<Long> instanceIds) {
|
||||
return this.delete(new LambdaQueryWrapper<FlowInstanceBizExt>()
|
||||
.in(FlowInstanceBizExt::getInstanceId, instanceIds));
|
||||
return this.lambda().in(FlowInstanceBizExt::getInstanceId, instanceIds).deleteCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-11
@@ -10,7 +10,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.warm.flow.core.service.DefService;
|
||||
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
||||
import org.dromara.warm.flow.ui.service.CategoryService;
|
||||
@@ -64,8 +63,10 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
|
||||
if (ObjectUtil.isNull(categoryId)) {
|
||||
return null;
|
||||
}
|
||||
FlowCategory category = baseMapper.selectOne(new LambdaQueryWrapper<FlowCategory>()
|
||||
.select(FlowCategory::getCategoryName).eq(FlowCategory::getCategoryId, categoryId));
|
||||
FlowCategory category = baseMapper.lambda()
|
||||
.select(FlowCategory::getCategoryName)
|
||||
.eq(FlowCategory::getCategoryId, categoryId)
|
||||
.one();
|
||||
return ObjectUtils.notNullGetter(category, FlowCategory::getCategoryName);
|
||||
}
|
||||
|
||||
@@ -80,9 +81,10 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
|
||||
if (CollUtil.isEmpty(categoryIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<FlowCategory> list = baseMapper.selectList(new LambdaQueryWrapper<FlowCategory>()
|
||||
List<FlowCategory> list = baseMapper.lambda()
|
||||
.select(FlowCategory::getCategoryId, FlowCategory::getCategoryName)
|
||||
.in(FlowCategory::getCategoryId, categoryIds));
|
||||
.in(FlowCategory::getCategoryId, categoryIds)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, FlowCategory::getCategoryId, FlowCategory::getCategoryName);
|
||||
}
|
||||
|
||||
@@ -145,10 +147,11 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
|
||||
*/
|
||||
@Override
|
||||
public boolean checkCategoryNameUnique(FlowCategoryBo category) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<FlowCategory>()
|
||||
boolean exist = baseMapper.lambda()
|
||||
.eq(FlowCategory::getCategoryName, category.getCategoryName())
|
||||
.eq(FlowCategory::getParentId, category.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(category.getCategoryId()), FlowCategory::getCategoryId, category.getCategoryId()));
|
||||
.neIfPresent(FlowCategory::getCategoryId, category.getCategoryId())
|
||||
.exists();
|
||||
return !exist;
|
||||
}
|
||||
|
||||
@@ -173,8 +176,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByCategoryId(Long categoryId) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<FlowCategory>()
|
||||
.eq(FlowCategory::getParentId, categoryId));
|
||||
return baseMapper.lambda().eq(FlowCategory::getParentId, categoryId).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,8 +257,9 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService, CategoryServ
|
||||
* @param oldAncestors 旧的父ID集合
|
||||
*/
|
||||
private void updateCategoryChildren(Long categoryId, String newAncestors, String oldAncestors) {
|
||||
List<FlowCategory> children = baseMapper.selectList(new LambdaQueryWrapper<FlowCategory>()
|
||||
.apply(DataBaseHelper.findInSet(categoryId, "ancestors")));
|
||||
List<FlowCategory> children = baseMapper.lambda()
|
||||
.findInSet(categoryId, FlowCategory::getAncestors)
|
||||
.list();
|
||||
List<FlowCategory> list = new ArrayList<>();
|
||||
for (FlowCategory child : children) {
|
||||
FlowCategory category = new FlowCategory();
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@ import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.warm.flow.core.dto.DefJson;
|
||||
import org.dromara.warm.flow.core.enums.NodeType;
|
||||
import org.dromara.warm.flow.core.enums.PublishStatus;
|
||||
@@ -121,7 +122,8 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean publish(Long id) {
|
||||
List<FlowNode> flowNodes = flowNodeMapper.selectList(new LambdaQueryWrapper<FlowNode>().eq(FlowNode::getDefinitionId, id));
|
||||
List<FlowNode> flowNodes = flowNodeMapper.selectList(
|
||||
QueryBuilder.lambda(FlowNode.class).eq(FlowNode::getDefinitionId, id).build());
|
||||
List<String> errorMsg = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(flowNodes)) {
|
||||
String applyNodeCode = flwCommonService.applyNodeCode(id);
|
||||
|
||||
+15
-9
@@ -4,8 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -17,6 +16,7 @@ import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.constant.ExceptionCons;
|
||||
@@ -185,7 +185,10 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
*/
|
||||
@Override
|
||||
public FlowInstance selectInstByBusinessId(String businessId) {
|
||||
return flowInstanceMapper.selectOne(new LambdaQueryWrapper<FlowInstance>().eq(FlowInstance::getBusinessId, businessId));
|
||||
return flowInstanceMapper.selectOne(
|
||||
QueryBuilder.lambda(FlowInstance.class)
|
||||
.eq(FlowInstance::getBusinessId, businessId)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +222,10 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteByBusinessIds(List<String> businessIds) {
|
||||
List<FlowInstance> flowInstances = flowInstanceMapper.selectList(new LambdaQueryWrapper<FlowInstance>().in(FlowInstance::getBusinessId, businessIds));
|
||||
List<FlowInstance> flowInstances = flowInstanceMapper.selectList(
|
||||
QueryBuilder.lambda(FlowInstance.class)
|
||||
.in(FlowInstance::getBusinessId, businessIds)
|
||||
.build());
|
||||
if (CollUtil.isEmpty(flowInstances)) {
|
||||
log.warn("未找到对应的流程实例信息,无法执行删除操作。");
|
||||
return false;
|
||||
@@ -393,10 +399,11 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
// 再组装历史任务(已处理任务)
|
||||
List<FlowHisTaskVo> hisTaskVos = new ArrayList<>();
|
||||
List<FlowHisTask> hisTasks = flowHisTaskMapper.selectList(
|
||||
new LambdaQueryWrapper<FlowHisTask>()
|
||||
QueryBuilder.lambda(FlowHisTask.class)
|
||||
.eq(FlowHisTask::getInstanceId, instanceId)
|
||||
.eq(FlowHisTask::getNodeType, NodeType.BETWEEN.getKey())
|
||||
.orderByDesc(FlowHisTask::getUpdateTime)
|
||||
.build()
|
||||
);
|
||||
if (CollUtil.isNotEmpty(hisTasks)) {
|
||||
hisTaskVos = BeanUtil.copyToList(hisTasks, FlowHisTaskVo.class);
|
||||
@@ -418,10 +425,9 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
*/
|
||||
@Override
|
||||
public void updateStatus(Long instanceId, String status) {
|
||||
LambdaUpdateWrapper<FlowInstance> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.set(FlowInstance::getFlowStatus, status);
|
||||
wrapper.eq(FlowInstance::getId, instanceId);
|
||||
flowInstanceMapper.update(wrapper);
|
||||
flowInstanceMapper.update(Wrappers.lambdaUpdate(FlowInstance.class)
|
||||
.set(FlowInstance::getFlowStatus, status)
|
||||
.eq(FlowInstance::getId, instanceId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-8
@@ -1,7 +1,6 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -135,9 +134,10 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
*/
|
||||
private void validEntityBeforeSave(FlowSpel entity){
|
||||
if (StringUtils.isNotBlank(entity.getViewSpel())) {
|
||||
boolean exists = baseMapper.exists(new LambdaQueryWrapper<FlowSpel>()
|
||||
boolean exists = baseMapper.lambda()
|
||||
.eq(FlowSpel::getViewSpel, entity.getViewSpel())
|
||||
.ne(ObjectUtil.isNotNull(entity.getId()), FlowSpel::getId, entity.getId()));
|
||||
.neIfPresent(FlowSpel::getId, entity.getId())
|
||||
.exists();
|
||||
if (exists) {
|
||||
throw new ServiceException("SpEL表达式已存在,请勿重复添加");
|
||||
}
|
||||
@@ -193,11 +193,10 @@ public class FlwSpelServiceImpl implements IFlwSpelService {
|
||||
if (CollUtil.isEmpty(viewSpels)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<FlowSpel> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<FlowSpel>()
|
||||
.select(FlowSpel::getViewSpel, FlowSpel::getRemark)
|
||||
.in(FlowSpel::getViewSpel, viewSpels)
|
||||
);
|
||||
List<FlowSpel> list = baseMapper.lambda()
|
||||
.select(FlowSpel::getViewSpel, FlowSpel::getRemark)
|
||||
.in(FlowSpel::getViewSpel, viewSpels)
|
||||
.list();
|
||||
return StreamUtils.toMap(list, FlowSpel::getViewSpel, x ->
|
||||
StringUtils.isEmpty(x.getRemark()) ? "" : x.getRemark()
|
||||
);
|
||||
|
||||
+25
-12
@@ -7,7 +7,6 @@ import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -21,6 +20,7 @@ import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.query.QueryBuilder;
|
||||
import org.dromara.common.mybatis.utils.IdGeneratorUtil;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.api.domain.UserDTO;
|
||||
@@ -121,8 +121,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
FlowInstanceBizExt bizExt = startProcessBo.getBizExt();
|
||||
|
||||
// 获取已有流程实例
|
||||
FlowInstance flowInstance = flowInstanceMapper.selectOne(new LambdaQueryWrapper<>(FlowInstance.class)
|
||||
.eq(FlowInstance::getBusinessId, businessId));
|
||||
FlowInstance flowInstance = flowInstanceMapper.selectOne(QueryBuilder.lambda(FlowInstance.class)
|
||||
.eq(FlowInstance::getBusinessId, businessId)
|
||||
.build());
|
||||
|
||||
if (ObjectUtil.isNotNull(flowInstance)) {
|
||||
// 已存在流程
|
||||
@@ -339,8 +340,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
// 添加抄送人记录
|
||||
FlowHisTask flowHisTask = flowHisTaskMapper.selectList(
|
||||
new LambdaQueryWrapper<>(FlowHisTask.class)
|
||||
.eq(FlowHisTask::getTaskId, task.getId())).get(0);
|
||||
QueryBuilder.lambda(FlowHisTask.class)
|
||||
.eq(FlowHisTask::getTaskId, task.getId())
|
||||
.build()).get(0);
|
||||
FlowNode flowNode = new FlowNode();
|
||||
flowNode.setNodeCode(flowHisTask.getTargetNodeCode());
|
||||
flowNode.setNodeName(flowHisTask.getTargetNodeName());
|
||||
@@ -599,7 +601,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public List<FlowTask> selectByIdList(Collection<Long> taskIdList) {
|
||||
return flowTaskMapper.selectList(new LambdaQueryWrapper<>(FlowTask.class).in(FlowTask::getId, taskIdList));
|
||||
return flowTaskMapper.selectList(QueryBuilder.lambda(FlowTask.class)
|
||||
.in(FlowTask::getId, taskIdList)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,7 +717,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public FlowHisTask selectHisTaskById(Long taskId) {
|
||||
return flowHisTaskMapper.selectOne(new LambdaQueryWrapper<>(FlowHisTask.class).eq(FlowHisTask::getId, taskId));
|
||||
return flowHisTaskMapper.selectOne(QueryBuilder.lambda(FlowHisTask.class)
|
||||
.eq(FlowHisTask::getId, taskId)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,7 +730,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public List<FlowTask> selectByInstId(Long instanceId) {
|
||||
return flowTaskMapper.selectList(new LambdaQueryWrapper<>(FlowTask.class).eq(FlowTask::getInstanceId, instanceId));
|
||||
return flowTaskMapper.selectList(QueryBuilder.lambda(FlowTask.class)
|
||||
.eq(FlowTask::getInstanceId, instanceId)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -735,7 +743,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public List<FlowTask> selectByInstIds(Collection<Long> instanceIds) {
|
||||
return flowTaskMapper.selectList(new LambdaQueryWrapper<>(FlowTask.class).in(FlowTask::getInstanceId, instanceIds));
|
||||
return flowTaskMapper.selectList(QueryBuilder.lambda(FlowTask.class)
|
||||
.in(FlowTask::getInstanceId, instanceIds)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -746,7 +756,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public boolean isTaskEnd(Long instanceId) {
|
||||
boolean exists = flowTaskMapper.exists(new LambdaQueryWrapper<FlowTask>().eq(FlowTask::getInstanceId, instanceId));
|
||||
boolean exists = flowTaskMapper.exists(QueryBuilder.lambda(FlowTask.class)
|
||||
.eq(FlowTask::getInstanceId, instanceId)
|
||||
.build());
|
||||
return !exists;
|
||||
}
|
||||
|
||||
@@ -897,9 +909,10 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
*/
|
||||
@Override
|
||||
public FlowNode getByNodeCode(String nodeCode, Long definitionId) {
|
||||
return flowNodeMapper.selectOne(new LambdaQueryWrapper<FlowNode>()
|
||||
return flowNodeMapper.selectOne(QueryBuilder.lambda(FlowNode.class)
|
||||
.eq(FlowNode::getNodeCode, nodeCode)
|
||||
.eq(FlowNode::getDefinitionId, definitionId));
|
||||
.eq(FlowNode::getDefinitionId, definitionId)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user