cl
2026-04-17 60633a391e1840291272a6a678868620cfa915df
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);