zhou zhou
1 天以前 1dcfa3702505f0c431757312b5304531029f90f6
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DeptController.java
@@ -16,6 +16,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.vincent.rsf.server.manager.utils.buildPageRowsUtils;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
@@ -31,19 +32,19 @@
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<Dept, BaseParam> pageParam = new PageParam<>(baseParam, Dept.class);
        return R.ok().add(deptService.page(pageParam, pageParam.buildWrapper(true)));
        return R.ok().add(buildPageRowsUtils.rowsMap(deptService.page(pageParam, pageParam.buildWrapper(true))));
    }
    @PreAuthorize("hasAuthority('system:dept:list')")
    @PostMapping("/dept/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(deptService.list());
        return R.ok().add(buildPageRowsUtils.rowsMap(deptService.list()));
    }
    @PreAuthorize("hasAuthority('system:dept:list')")
    @PostMapping({"/dept/many/{ids}", "/depts/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(deptService.listByIds(Arrays.asList(ids)));
        return R.ok().add(buildPageRowsUtils.rowsMap(deptService.listByIds(Arrays.asList(ids))));
    }
    @PreAuthorize("hasAuthority('system:dept:list')")
@@ -57,13 +58,13 @@
            Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren);
            Utils.treeRemove(treeData, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren);
        }
        return R.ok().add(treeData);
        return R.ok().add(buildPageRowsUtils.rowsMap(treeData));
    }
    @PreAuthorize("hasAuthority('system:dept:list')")
    @GetMapping("/dept/{id}")
    public R get(@PathVariable("id") Long id) {
        return R.ok().add(deptService.getById(id));
        return R.ok().add(buildPageRowsUtils.rowsMap(deptService.getById(id)));
    }
    @PreAuthorize("hasAuthority('system:dept:save')")
@@ -91,7 +92,7 @@
        if (!deptService.save(dept)) {
            return R.error("Save Fail");
        }
        return R.ok("Save Success").add(dept);
        return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(dept));
    }
    @PreAuthorize("hasAuthority('system:dept:update')")
@@ -117,7 +118,7 @@
        if (!deptService.updateById(dept)) {
            return R.error("Update Fail");
        }
        return R.ok("Update Success").add(dept);
        return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(dept));
    }
    @PreAuthorize("hasAuthority('system:dept:remove')")
@@ -127,7 +128,7 @@
        if (!deptService.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('system:dept:list')")
@@ -141,13 +142,13 @@
        deptService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
                item -> vos.add(new KeyValVo(item.getId(), item.getName()))
        );
        return R.ok().add(vos);
        return R.ok().add(buildPageRowsUtils.rowsMap(vos));
    }
    @PreAuthorize("hasAuthority('system:dept:list')")
    @PostMapping("/dept/export")
    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
        ExcelUtil.build(ExcelUtil.create(deptService.list(), Dept.class), response);
        ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(deptService.list()), Dept.class), response);
    }
}