mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
Pre Merge pull request !704 from AprilWind/dev-table
This commit is contained in:
commit
669b725ebe
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.common.mybatis.core.page;
|
package org.dromara.common.mybatis.core.page;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -67,6 +68,21 @@ public class TableDataInfo<T> implements Serializable {
|
|||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分页对象构建表格分页数据对象
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param clazz 目标类型的Class,用于Bean复制
|
||||||
|
*/
|
||||||
|
public static <T, R> TableDataInfo<R> build(IPage<T> page, Class<R> clazz) {
|
||||||
|
TableDataInfo<R> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(BeanUtil.copyToList(page.getRecords(), clazz));
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据数据列表构建表格分页数据对象
|
* 根据数据列表构建表格分页数据对象
|
||||||
*/
|
*/
|
||||||
@ -79,6 +95,21 @@ public class TableDataInfo<T> implements Serializable {
|
|||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数据列表构建表格分页数据对象
|
||||||
|
*
|
||||||
|
* @param list 数据列表
|
||||||
|
* @param clazz 目标类型的Class,用于Bean复制
|
||||||
|
*/
|
||||||
|
public static <T, R> TableDataInfo<R> build(List<T> list, Class<R> clazz) {
|
||||||
|
TableDataInfo<R> rspData = new TableDataInfo<>();
|
||||||
|
rspData.setCode(HttpStatus.HTTP_OK);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(BeanUtil.copyToList(list, clazz));
|
||||||
|
rspData.setTotal(list.size());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建表格分页数据对象
|
* 构建表格分页数据对象
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,21 +3,21 @@ package org.dromara.generator.controller;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
|
||||||
import org.dromara.common.web.core.BaseController;
|
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
||||||
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.log.annotation.Log;
|
||||||
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.generator.domain.GenTable;
|
import org.dromara.generator.domain.GenTable;
|
||||||
import org.dromara.generator.domain.GenTableColumn;
|
import org.dromara.generator.domain.GenTableColumn;
|
||||||
import org.dromara.generator.service.IGenTableService;
|
import org.dromara.generator.service.IGenTableService;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -80,11 +80,8 @@ public class GenController extends BaseController {
|
|||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping(value = "/column/{tableId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
||||||
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
|
||||||
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
||||||
dataInfo.setRows(list);
|
return TableDataInfo.build(list);
|
||||||
dataInfo.setTotal(list.size());
|
|
||||||
return dataInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -78,10 +78,7 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
|
|||||||
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
||||||
wrapper.eq(FlowDefinition::getIsPublish, PublishStatus.PUBLISHED.getKey());
|
wrapper.eq(FlowDefinition::getIsPublish, PublishStatus.PUBLISHED.getKey());
|
||||||
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
||||||
TableDataInfo<FlowDefinitionVo> build = TableDataInfo.build();
|
return TableDataInfo.build(page, FlowDefinitionVo.class);
|
||||||
build.setRows(BeanUtil.copyToList(page.getRecords(), FlowDefinitionVo.class));
|
|
||||||
build.setTotal(page.getTotal());
|
|
||||||
return build;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,10 +93,7 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
|
|||||||
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
||||||
wrapper.in(FlowDefinition::getIsPublish, Arrays.asList(PublishStatus.UNPUBLISHED.getKey(), PublishStatus.EXPIRED.getKey()));
|
wrapper.in(FlowDefinition::getIsPublish, Arrays.asList(PublishStatus.UNPUBLISHED.getKey(), PublishStatus.EXPIRED.getKey()));
|
||||||
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
||||||
TableDataInfo<FlowDefinitionVo> build = TableDataInfo.build();
|
return TableDataInfo.build(page, FlowDefinitionVo.class);
|
||||||
build.setRows(BeanUtil.copyToList(page.getRecords(), FlowDefinitionVo.class));
|
|
||||||
build.setTotal(page.getTotal());
|
|
||||||
return build;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<FlowDefinition> buildQueryWrapper(FlowDefinition flowDefinition) {
|
private LambdaQueryWrapper<FlowDefinition> buildQueryWrapper(FlowDefinition flowDefinition) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user