mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 优化 使用ObjectUtils新增方法封装代码
This commit is contained in:
@ -11,6 +11,7 @@ import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.ConfigService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@ -72,10 +73,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
public String selectConfigByKey(String configKey) {
|
||||
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, configKey));
|
||||
if (ObjectUtil.isNotNull(retConfig)) {
|
||||
return retConfig.getConfigValue();
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
return ObjectUtils.notNullGetter(retConfig, SysConfig::getConfigValue, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +195,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkConfigKeyUnique(SysConfigBo config) {
|
||||
long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
||||
long configId = ObjectUtils.notNull(config.getConfigId(), -1L);
|
||||
SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
|
||||
if (ObjectUtil.isNotNull(info) && info.getConfigId() != configId) {
|
||||
return false;
|
||||
|
@ -145,7 +145,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
}
|
||||
SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
|
||||
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
|
||||
dept.setParentName(ObjectUtils.notNullGetter(parentDept, SysDeptVo::getDeptName));
|
||||
return dept;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.system.domain.SysDictData;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -144,7 +145,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDictDataUnique(SysDictDataBo dict) {
|
||||
Long dictCode = ObjectUtil.isNull(dict.getDictCode()) ? -1L : dict.getDictCode();
|
||||
Long dictCode = ObjectUtils.notNull(dict.getDictCode(), -1L);
|
||||
SysDictData entity = baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dict.getDictType()).eq(SysDictData::getDictValue, dict.getDictValue()));
|
||||
if (ObjectUtil.isNotNull(entity) && !dictCode.equals(entity.getDictCode())) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
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 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.page.TableDataInfo;
|
||||
@ -70,7 +70,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getNoticeType()), 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, ObjectUtil.isNotNull(sysUser) ? sysUser.getUserId() : null);
|
||||
lqw.eq(SysNotice::getCreateBy, ObjectUtils.notNullGetter(sysUser, SysUserVo::getUserId));
|
||||
}
|
||||
lqw.orderByAsc(SysNotice::getNoticeId);
|
||||
return lqw;
|
||||
|
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
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.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@ -147,7 +148,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
* 判断configKey是否唯一
|
||||
*/
|
||||
private boolean checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
||||
long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
||||
long ossConfigId = ObjectUtils.notNull(sysOssConfig.getOssConfigId(), -1L);
|
||||
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||
|
@ -18,10 +18,7 @@ import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.UserService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
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.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
@ -565,7 +562,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public String selectUserNameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserName).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getUserName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -579,7 +576,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public String selectNicknameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getNickName).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getNickName();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getNickName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -610,7 +607,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public String selectPhonenumberById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getPhonenumber).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getPhonenumber();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getPhonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -623,7 +620,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
public String selectEmailById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getEmail).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getEmail();
|
||||
return ObjectUtils.notNullGetter(sysUser, SysUser::getEmail);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user