mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-11-09 16:57:16 +08:00
chore: continew-starter 2.8.3 => 2.9.0
1.使用 QueryWrapperHelper#sort 优化部分排序
This commit is contained in:
@@ -33,11 +33,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.x-file-storage</groupId>
|
<groupId>org.dromara.x-file-storage</groupId>
|
||||||
<artifactId>x-file-storage-spring</artifactId>
|
<artifactId>x-file-storage-spring</artifactId>
|
||||||
|
<version>2.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Amazon S3(Amazon Simple Storage Service,亚马逊简单存储服务,通用存储协议 S3,兼容主流云厂商对象存储) -->
|
<!-- Amazon S3(Amazon Simple Storage Service,亚马逊简单存储服务,通用存储协议 S3,兼容主流云厂商对象存储) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
|
<version>1.12.780</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- FreeMarker(模板引擎) -->
|
<!-- FreeMarker(模板引擎) -->
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package top.continew.admin.system.service.impl;
|
|||||||
import cn.crane4j.annotation.AutoOperate;
|
import cn.crane4j.annotation.AutoOperate;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -27,7 +26,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import top.continew.admin.common.enums.DisEnableStatusEnum;
|
import top.continew.admin.common.enums.DisEnableStatusEnum;
|
||||||
import top.continew.admin.system.mapper.LogMapper;
|
import top.continew.admin.system.mapper.LogMapper;
|
||||||
@@ -39,6 +37,7 @@ import top.continew.admin.system.model.resp.log.LoginLogExportResp;
|
|||||||
import top.continew.admin.system.model.resp.log.OperationLogExportResp;
|
import top.continew.admin.system.model.resp.log.OperationLogExportResp;
|
||||||
import top.continew.admin.system.service.LogService;
|
import top.continew.admin.system.service.LogService;
|
||||||
import top.continew.starter.core.validation.CheckUtils;
|
import top.continew.starter.core.validation.CheckUtils;
|
||||||
|
import top.continew.starter.data.mp.util.QueryWrapperHelper;
|
||||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||||
@@ -63,7 +62,7 @@ public class LogServiceImpl implements LogService {
|
|||||||
@Override
|
@Override
|
||||||
public PageResp<LogResp> page(LogQuery query, PageQuery pageQuery) {
|
public PageResp<LogResp> page(LogQuery query, PageQuery pageQuery) {
|
||||||
QueryWrapper<LogDO> queryWrapper = this.buildQueryWrapper(query);
|
QueryWrapper<LogDO> queryWrapper = this.buildQueryWrapper(query);
|
||||||
this.sort(queryWrapper, pageQuery);
|
QueryWrapperHelper.sort(queryWrapper, pageQuery.getSort());
|
||||||
IPage<LogResp> page = baseMapper.selectLogPage(new Page<>(pageQuery.getPage(), pageQuery
|
IPage<LogResp> page = baseMapper.selectLogPage(new Page<>(pageQuery.getPage(), pageQuery
|
||||||
.getSize()), queryWrapper);
|
.getSize()), queryWrapper);
|
||||||
return PageResp.build(page);
|
return PageResp.build(page);
|
||||||
@@ -99,26 +98,10 @@ public class LogServiceImpl implements LogService {
|
|||||||
*/
|
*/
|
||||||
private List<LogResp> list(LogQuery query, SortQuery sortQuery) {
|
private List<LogResp> list(LogQuery query, SortQuery sortQuery) {
|
||||||
QueryWrapper<LogDO> queryWrapper = this.buildQueryWrapper(query);
|
QueryWrapper<LogDO> queryWrapper = this.buildQueryWrapper(query);
|
||||||
this.sort(queryWrapper, sortQuery);
|
QueryWrapperHelper.sort(queryWrapper, sortQuery.getSort());
|
||||||
return baseMapper.selectLogList(queryWrapper);
|
return baseMapper.selectLogList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置排序
|
|
||||||
*
|
|
||||||
* @param queryWrapper 查询条件封装对象
|
|
||||||
* @param sortQuery 排序查询条件
|
|
||||||
*/
|
|
||||||
private void sort(QueryWrapper<LogDO> queryWrapper, SortQuery sortQuery) {
|
|
||||||
if (sortQuery == null || sortQuery.getSort().isUnsorted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (Sort.Order order : sortQuery.getSort()) {
|
|
||||||
String property = order.getProperty();
|
|
||||||
queryWrapper.orderBy(true, order.isAscending(), CharSequenceUtil.toUnderlineCase(property));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建 QueryWrapper
|
* 构建 QueryWrapper
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ import cn.crane4j.annotation.AutoOperate;
|
|||||||
import cn.crane4j.annotation.ContainerMethod;
|
import cn.crane4j.annotation.ContainerMethod;
|
||||||
import cn.crane4j.annotation.MappingType;
|
import cn.crane4j.annotation.MappingType;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import top.continew.admin.common.constant.ContainerConstants;
|
import top.continew.admin.common.constant.ContainerConstants;
|
||||||
@@ -37,6 +35,7 @@ import top.continew.admin.system.model.query.RoleUserQuery;
|
|||||||
import top.continew.admin.system.model.resp.role.RoleUserResp;
|
import top.continew.admin.system.model.resp.role.RoleUserResp;
|
||||||
import top.continew.admin.system.service.UserRoleService;
|
import top.continew.admin.system.service.UserRoleService;
|
||||||
import top.continew.starter.core.validation.CheckUtils;
|
import top.continew.starter.core.validation.CheckUtils;
|
||||||
|
import top.continew.starter.data.mp.util.QueryWrapperHelper;
|
||||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||||
|
|
||||||
@@ -64,13 +63,7 @@ public class UserRoleServiceImpl implements UserRoleService {
|
|||||||
.like("t2.nickname", description)
|
.like("t2.nickname", description)
|
||||||
.or()
|
.or()
|
||||||
.like("t2.description", description));
|
.like("t2.description", description));
|
||||||
// 排序
|
QueryWrapperHelper.sort(queryWrapper, pageQuery.getSort());
|
||||||
if (!pageQuery.getSort().isUnsorted()) {
|
|
||||||
for (Sort.Order order : pageQuery.getSort()) {
|
|
||||||
String property = order.getProperty();
|
|
||||||
queryWrapper.orderBy(true, order.isAscending(), CharSequenceUtil.toUnderlineCase(property));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IPage<RoleUserResp> page = baseMapper.selectUserPage(new Page<>(pageQuery.getPage(), pageQuery
|
IPage<RoleUserResp> page = baseMapper.selectUserPage(new Page<>(pageQuery.getPage(), pageQuery
|
||||||
.getSize()), queryWrapper);
|
.getSize()), queryWrapper);
|
||||||
return PageResp.build(page);
|
return PageResp.build(page);
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
||||||
|
|
||||||
:: ${project.name} :: v${project.version}
|
:: ${project.name} :: v${project.version}
|
||||||
:: ContiNew Starter :: v2.8.3
|
:: ContiNew Starter :: v2.9.0
|
||||||
:: Spring Boot :: v${spring-boot.version}
|
:: Spring Boot :: v${spring-boot.version}
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -13,7 +13,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter</artifactId>
|
<artifactId>continew-starter</artifactId>
|
||||||
<version>2.8.3</version>
|
<version>2.9.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
|
|||||||
Reference in New Issue
Block a user