整理wrapper查询逻辑

pull/3/head
fengshuonan 2021-02-08 10:49:23 +08:00
parent 16b4e825fb
commit 576fa5aeb7
4 changed files with 38 additions and 25 deletions

View File

@ -134,7 +134,15 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
private LambdaQueryWrapper<SysConfig> createWrapper(SysConfigParam sysConfigParam) {
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotNull(sysConfigParam)) {
// 查询未删除的
queryWrapper.ne(SysConfig::getDelFlag, YesOrNotEnum.Y.getCode());
// 按类型升序排列,同类型的排在一起
queryWrapper.orderByDesc(SysConfig::getGroupCode);
if (ObjectUtil.isEmpty(sysConfigParam)) {
return queryWrapper;
}
String configName = sysConfigParam.getConfigName();
String configCode = sysConfigParam.getConfigCode();
@ -148,13 +156,6 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
// 如果分类编码不为空,则带上分类编码
queryWrapper.eq(ObjectUtil.isNotEmpty(groupCode), SysConfig::getGroupCode, groupCode);
}
// 查询未删除的
queryWrapper.ne(SysConfig::getDelFlag, YesOrNotEnum.Y.getCode());
// 按类型升序排列,同类型的排在一起
queryWrapper.orderByDesc(SysConfig::getGroupCode);
return queryWrapper;
}

View File

@ -222,15 +222,19 @@ public class DatabaseInfoServiceImpl extends ServiceImpl<DatabaseInfoMapper, Dat
private LambdaQueryWrapper<DatabaseInfo> createWrapper(DatabaseInfoRequest databaseInfoRequest) {
LambdaQueryWrapper<DatabaseInfo> queryWrapper = new LambdaQueryWrapper<>();
// 查询没被删除的
queryWrapper.eq(DatabaseInfo::getDelFlag, YesOrNotEnum.N.getCode());
if (ObjectUtil.isEmpty(databaseInfoRequest)) {
return queryWrapper;
}
// 根据名称模糊查询
String dbName = databaseInfoRequest.getDbName();
// 拼接sql 条件
queryWrapper.like(ObjectUtil.isNotEmpty(dbName), DatabaseInfo::getDbName, dbName);
// 查询没被删除的
queryWrapper.eq(DatabaseInfo::getDelFlag, YesOrNotEnum.N.getCode());
return queryWrapper;
}

View File

@ -131,6 +131,13 @@ public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Trans
private LambdaQueryWrapper<Translation> createWrapper(TranslationRequest translationRequest) {
LambdaQueryWrapper<Translation> queryWrapper = new LambdaQueryWrapper<>();
// 按翻译编码倒序排列
queryWrapper.orderByDesc(Translation::getTranCode);
if (ObjectUtil.isEmpty(translationRequest)) {
return queryWrapper;
}
Long tranId = translationRequest.getTranId();
String tranCode = translationRequest.getTranCode();
String tranName = translationRequest.getTranName();
@ -142,9 +149,6 @@ public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Trans
queryWrapper.like(ObjectUtil.isNotEmpty(tranName), Translation::getTranName, tranName);
queryWrapper.eq(ObjectUtil.isNotEmpty(tranLanguageCode), Translation::getTranLanguageCode, tranLanguageCode);
// 按翻译编码倒序排列
queryWrapper.orderByDesc(Translation::getTranCode);
return queryWrapper;
}

View File

@ -90,6 +90,13 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
private LambdaQueryWrapper<SysLog> createWrapper(LogManagerRequest logManagerRequest) {
LambdaQueryWrapper<SysLog> queryWrapper = new LambdaQueryWrapper<>();
// 根据时间倒序排序
queryWrapper.orderByDesc(SysLog::getCreateTime);
if (ObjectUtil.isEmpty(logManagerRequest)) {
return queryWrapper;
}
String beginDateTime = logManagerRequest.getBeginDateTime();
String endDateTime = logManagerRequest.getEndDateTime();
@ -109,9 +116,6 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
queryWrapper.eq(StrUtil.isNotEmpty(clientIp), SysLog::getClientIp, clientIp);
queryWrapper.eq(StrUtil.isNotEmpty(url), SysLog::getRequestUrl, url);
// 根据时间倒序排序
queryWrapper.orderByDesc(SysLog::getCreateTime);
return queryWrapper;
}