feat(table): 添加表格排序和选择功能支持
- 在KitPageArgs中新增OrderBy排序参数类,支持字段转下划线和排序绑定 - 修改SystemDictService.searchDict方法,集成排序参数处理逻辑 - 更新CuteDragTable和CuteSimpleTable组件,添加排序和选择功能 - 新增表格上方工具栏插槽和选择计数显示 - 优化前端表格组件的排序事件处理和数据刷新逻辑
This commit is contained in:
+5
-4
@@ -25,6 +25,10 @@ import cn.odboy.system.service.SystemDictService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -34,9 +38,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "系统:字典管理")
|
||||
@@ -67,7 +68,7 @@ public class SystemDictController {
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> pageArgs) {
|
||||
Page<SystemDictTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
|
||||
return ResponseEntity.ok(systemDictService.searchDict(pageArgs.getArgs(), page));
|
||||
return ResponseEntity.ok(systemDictService.searchDict(pageArgs.getArgs(), page, pageArgs.getOrderBy()));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
|
||||
+18
-9
@@ -17,6 +17,7 @@ package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageArgs;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictTb;
|
||||
import cn.odboy.system.dal.model.export.SystemDictExportRowVo;
|
||||
@@ -28,11 +29,12 @@ import cn.odboy.util.KitBeanUtil;
|
||||
import cn.odboy.util.KitPageUtil;
|
||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -85,14 +87,19 @@ public class SystemDictService {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param args 条件
|
||||
* @param page 分页参数
|
||||
* @param args 条件
|
||||
* @param page 分页参数
|
||||
* @param orderBy 排序参数
|
||||
* @return /
|
||||
*/
|
||||
public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page) {
|
||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||
this.injectQueryParams(args, wrapper);
|
||||
Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, wrapper);
|
||||
public KitPageResult<SystemDictTb> searchDict(SystemQueryDictArgs args, Page<SystemDictTb> page, KitPageArgs.OrderBy orderBy) {
|
||||
QueryWrapper<SystemDictTb> wrapper = new QueryWrapper<>();
|
||||
if (orderBy != null) {
|
||||
orderBy.bindWrapper(wrapper);
|
||||
}
|
||||
LambdaQueryWrapper<SystemDictTb> lambda = wrapper.lambda();
|
||||
this.injectQueryParams(args, lambda);
|
||||
Page<SystemDictTb> selectPage = systemDictMapper.selectPage(page, lambda);
|
||||
return KitPageUtil.toPage(selectPage);
|
||||
}
|
||||
|
||||
@@ -150,8 +157,10 @@ public class SystemDictService {
|
||||
*/
|
||||
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
||||
if (args != null) {
|
||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
||||
.like(SystemDictTb::getDescription, args.getBlurry()));
|
||||
wrapper.and(
|
||||
StrUtil.isNotBlank(args.getBlurry()),
|
||||
c -> c.like(SystemDictTb::getName, args.getBlurry()).or().like(SystemDictTb::getDescription, args.getBlurry())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user