From 691bee4229856f8bf81c2720092ecee1c9f21509 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 09 四月 2026 19:18:12 +0800
Subject: [PATCH] #getter$摘出entity
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java | 77 +++++++++++++++++++++++++++++++++-----
1 files changed, 66 insertions(+), 11 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java
index 0f52118..1602116 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java
@@ -1,28 +1,34 @@
package com.vincent.rsf.server.manager.controller;
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 com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
-import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.server.common.annotation.OperationLog;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.KeyValVo;
import com.vincent.rsf.server.common.domain.PageParam;
+import com.vincent.rsf.server.common.service.ListExportHandler;
+import com.vincent.rsf.server.common.service.ListExportService;
+import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.server.manager.controller.params.WarehouseAreaParam;
import com.vincent.rsf.server.manager.entity.Loc;
import com.vincent.rsf.server.manager.entity.WarehouseAreas;
import com.vincent.rsf.server.manager.service.LocService;
import com.vincent.rsf.server.manager.service.WarehouseAreasService;
+import com.vincent.rsf.server.manager.utils.buildPageRowsUtils;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
@Api(tags = "浠撳簱搴撳尯")
@@ -35,30 +41,74 @@
@Autowired
private LocService locService;
+ @Autowired
+ private ListExportService listExportService;
+
+ private final ListExportHandler<WarehouseAreas, BaseParam> warehouseAreasExportHandler = new ListExportHandler<>() {
+ @Override
+ public List<WarehouseAreas> listByIds(List<Long> ids) {
+ List<WarehouseAreas> records = warehouseAreasService.listByIds(ids);
+ return records;
+ }
+
+ @Override
+ public List<WarehouseAreas> listByFilter(Map<String, Object> sanitizedMap, BaseParam baseParam) {
+ PageParam<WarehouseAreas, BaseParam> pageParam = new PageParam<>(baseParam, WarehouseAreas.class);
+ QueryWrapper<WarehouseAreas> queryWrapper = pageParam.buildWrapper(true);
+ List<WarehouseAreas> records = warehouseAreasService.list(queryWrapper);
+ return records;
+ }
+
+ @Override
+ public Map<String, Object> toExportRow(WarehouseAreas record, List<ExcelUtil.ExportColumn> columns) {
+ BeanWrapper beanWrapper = new BeanWrapperImpl(record);
+ Map<String, Object> row = new LinkedHashMap<>();
+
+ for (ExcelUtil.ExportColumn column : columns) {
+ if (beanWrapper.isReadableProperty(column.getSource())) {
+ row.put(column.getSource(), beanWrapper.getPropertyValue(column.getSource()));
+ }
+ }
+
+ return row;
+ }
+
+ @Override
+ public String defaultReportTitle() {
+ return "浠撳簱搴撳尯鎶ヨ〃";
+ }
+ };
+
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@PostMapping("/warehouseAreas/page")
public R page(@RequestBody Map<String, Object> map) {
BaseParam baseParam = buildParam(map, BaseParam.class);
PageParam<WarehouseAreas, BaseParam> pageParam = new PageParam<>(baseParam, WarehouseAreas.class);
- return R.ok().add(warehouseAreasService.page(pageParam, pageParam.buildWrapper(true)));
+ PageParam<WarehouseAreas, BaseParam> page = warehouseAreasService.page(pageParam, pageParam.buildWrapper(true));
+ return R.ok().add(buildPageRowsUtils.rowsMap(page));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@PostMapping("/warehouseAreas/list")
public R list(@RequestBody Map<String, Object> map) {
- return R.ok().add(warehouseAreasService.list());
+ List<WarehouseAreas> records = warehouseAreasService.list();
+ return R.ok().add(buildPageRowsUtils.rowsMap(records));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@PostMapping({"/warehouseAreas/many/{ids}", "/warehouseAreass/many/{ids}"})
public R many(@PathVariable Long[] ids) {
- return R.ok().add(warehouseAreasService.listByIds(Arrays.asList(ids)));
+ List<WarehouseAreas> records = warehouseAreasService.listByIds(Arrays.asList(ids));
+ return R.ok().add(buildPageRowsUtils.rowsMap(records));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@GetMapping("/warehouseAreas/{id}")
public R get(@PathVariable("id") Long id) {
- return R.ok().add(warehouseAreasService.getById(id));
+ WarehouseAreas warehouseAreas = warehouseAreasService.getById(id);
+ if (warehouseAreas != null) {
+ }
+ return R.ok().add(buildPageRowsUtils.rowsMap(warehouseAreas));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:save')")
@@ -89,7 +139,7 @@
if (!warehouseAreasService.save(warehouseAreas)) {
return R.error("Save Fail");
}
- return R.ok("Save Success").add(warehouseAreas);
+ return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(warehouseAreas));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:update')")
@@ -136,7 +186,7 @@
if (!warehouseAreasService.updateById(warehouseAreas)) {
return R.error("Update Fail");
}
- return R.ok("Update Success").add(warehouseAreas);
+ return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(warehouseAreas));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:remove')")
@@ -150,7 +200,7 @@
if (!warehouseAreasService.removeByIds(Arrays.asList(ids))) {
return R.error("Delete Fail");
}
- return R.ok("Delete Success").add(ids);
+ return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@@ -164,13 +214,18 @@
warehouseAreasService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
item -> vos.add(new KeyValVo(item.getId(), item.getType()))
);
- return R.ok().add(vos);
+ return R.ok().add(buildPageRowsUtils.rowsMap(vos));
}
@PreAuthorize("hasAuthority('manager:warehouseAreas:list')")
@PostMapping("/warehouseAreas/export")
public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
- ExcelUtil.build(ExcelUtil.create(warehouseAreasService.list(), WarehouseAreas.class), response);
+ listExportService.export(
+ map,
+ exportMap -> buildParam(exportMap, BaseParam.class),
+ warehouseAreasExportHandler,
+ response
+ );
}
}
--
Gitblit v1.9.1