From 60633a391e1840291272a6a678868620cfa915df Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期五, 17 四月 2026 10:11:22 +0800
Subject: [PATCH] 入库类型不会
---
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java | 92 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java b/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java
index f450eb6..044f763 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java
@@ -12,7 +12,6 @@
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.system.entity.DictData;
import com.vincent.rsf.server.system.service.DictDataService;
-import com.vincent.rsf.server.system.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -42,14 +41,57 @@
@PreAuthorize("hasAuthority('system:dictData:list')")
@PostMapping({"/dictData/many/{ids}", "/dictDatas/many/{ids}"})
- public R many(@PathVariable Long[] ids) {
- return R.ok().add(dictDataService.listByIds(Arrays.asList(ids)));
+ public R many(@PathVariable String[] ids) {
+ if (ids == null || ids.length == 0) {
+ return R.ok().add(Collections.emptyList());
+ }
+ List<Long> idList = new ArrayList<>();
+ List<String> valueList = new ArrayList<>();
+ for (String raw : ids) {
+ if (raw == null) {
+ continue;
+ }
+ String item = raw.trim();
+ if (item.isEmpty()) {
+ continue;
+ }
+ valueList.add(item);
+ if (item.matches("^\\d+$")) {
+ try {
+ idList.add(Long.parseLong(item));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+ if (valueList.isEmpty()) {
+ return R.ok().add(Collections.emptyList());
+ }
+ LambdaQueryWrapper<DictData> wrapper = new LambdaQueryWrapper<>();
+ wrapper.in(DictData::getValue, valueList);
+ if (!idList.isEmpty()) {
+ wrapper.or().in(DictData::getId, idList);
+ }
+ return R.ok().add(dictDataService.list(wrapper));
}
@PreAuthorize("hasAuthority('system:dictData:list')")
@GetMapping("/dictData/{id}")
- public R get(@PathVariable("id") Long id) {
- return R.ok().add(dictDataService.getById(id));
+ public R get(@PathVariable("id") String id) {
+ if (id == null || id.trim().isEmpty()) {
+ return R.ok().add(null);
+ }
+ String key = id.trim();
+ DictData data = null;
+ if (key.matches("^\\d+$")) {
+ try {
+ data = dictDataService.getById(Long.parseLong(key));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ if (data == null) {
+ data = dictDataService.getOne(new LambdaQueryWrapper<DictData>().eq(DictData::getValue, key), false);
+ }
+ return R.ok().add(data);
}
@PreAuthorize("hasAuthority('system:dictData:save')")
@@ -91,8 +133,44 @@
@PreAuthorize("hasAuthority('system:dictData:remove')")
@OperationLog("Delete 瀛楀吀鏁版嵁闆�")
@PostMapping("/dictData/remove/{ids}")
- public R remove(@PathVariable Long[] ids) {
- if (!dictDataService.removeByIds(Arrays.asList(ids))) {
+ public R remove(@PathVariable String[] ids) {
+ if (ids == null || ids.length == 0) {
+ return R.ok("Delete Success").add(Collections.emptyList());
+ }
+ List<Long> idList = new ArrayList<>();
+ List<String> valueList = new ArrayList<>();
+ for (String raw : ids) {
+ if (raw == null) {
+ continue;
+ }
+ String item = raw.trim();
+ if (item.isEmpty()) {
+ continue;
+ }
+ valueList.add(item);
+ if (item.matches("^\\d+$")) {
+ try {
+ idList.add(Long.parseLong(item));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+ if (valueList.isEmpty()) {
+ return R.ok("Delete Success").add(Collections.emptyList());
+ }
+ LambdaQueryWrapper<DictData> wrapper = new LambdaQueryWrapper<>();
+ wrapper.in(DictData::getValue, valueList);
+ if (!idList.isEmpty()) {
+ wrapper.or().in(DictData::getId, idList);
+ }
+ List<DictData> rows = dictDataService.list(wrapper);
+ List<Long> removeIds = new ArrayList<>();
+ for (DictData row : rows) {
+ if (row != null && row.getId() != null) {
+ removeIds.add(row.getId());
+ }
+ }
+ if (!removeIds.isEmpty() && !dictDataService.removeByIds(removeIds)) {
return R.error("Delete Fail");
}
return R.ok("Delete Success").add(ids);
--
Gitblit v1.9.1