From c635d78b479510ebe2556a420948effcd30a0731 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期六, 21 十二月 2024 18:40:43 +0800
Subject: [PATCH] 新建德森项目分支

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/DeptController.java |  306 +++++++++++++++++++++++++-------------------------
 1 files changed, 153 insertions(+), 153 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/DeptController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/DeptController.java
index dd700f1..0ccdcf5 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/DeptController.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/DeptController.java
@@ -1,153 +1,153 @@
-package com.zy.asrs.wms.system.controller;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.zy.asrs.framework.common.Cools;
-import com.zy.asrs.framework.common.R;
-import com.zy.asrs.wms.common.annotation.CacheData;
-import com.zy.asrs.wms.common.annotation.OperationLog;
-import com.zy.asrs.wms.common.domain.BaseParam;
-import com.zy.asrs.wms.common.domain.KeyValVo;
-import com.zy.asrs.wms.common.domain.PageParam;
-import com.zy.asrs.wms.system.entity.Dept;
-import com.zy.asrs.wms.system.service.DeptService;
-import com.zy.asrs.wms.utils.ExcelUtil;
-import com.zy.asrs.wms.utils.NodeUtils;
-import com.zy.asrs.wms.utils.Utils;
-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 java.util.*;
-
-@RestController
-@RequestMapping("/api")
-public class DeptController extends BaseController {
-
-    @Autowired
-    private DeptService deptService;
-
-    @PreAuthorize("hasAuthority('system:dept:list')")
-    @PostMapping("/dept/page")
-    @CacheData(tableName = {"sys_dept"})
-    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)));
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:list')")
-    @PostMapping("/dept/list")
-    @CacheData(tableName = {"sys_dept"})
-    public R list(@RequestBody Map<String, Object> map) {
-        return R.ok().add(deptService.list());
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:list')")
-    @PostMapping("/dept/tree")
-    @CacheData(tableName = {"sys_dept"})
-    public R tree(@RequestBody Map<String, Object> map) {
-//        PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class);
-//        QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort"));
-        List<Dept> deptList = deptService.list(new LambdaQueryWrapper<Dept>().orderByAsc(Dept::getSort));
-        List<Dept> treeData = Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren);
-        if (!Cools.isEmpty(map.get("condition"))) {
-            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);
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:list')")
-    @GetMapping("/dept/{id}")
-    @CacheData(tableName = {"sys_dept"})
-    public R get(@PathVariable("id") Long id) {
-        return R.ok().add(deptService.getById(id));
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:save')")
-    @OperationLog("娣诲姞閮ㄩ棬")
-    @PostMapping("/dept/save")
-    public R save(@RequestBody Dept dept) {
-        if (dept.getParentId() != null && dept.getParentId() > 0) {
-            Dept parent = deptService.getById(dept.getParentId());
-            if (parent != null) {
-                dept.setParentName(parent.getName());
-            }
-        } else {
-            dept.setParentId(0L);
-        }
-
-        NodeUtils nodeUtils = new NodeUtils();
-        nodeUtils.generatePath0(item -> deptService.getById(item.getParentId()), dept, Dept::getId, Dept::getName, Dept::getParentId);
-        dept.setPath(nodeUtils.path.toString());
-        dept.setPathName(nodeUtils.pathName.toString());
-
-        dept.setCreateBy(getLoginUserId());
-        dept.setCreateTime(new Date());
-        dept.setUpdateBy(getLoginUserId());
-        dept.setUpdateTime(new Date());
-        if (!deptService.save(dept)) {
-            return R.error("娣诲姞澶辫触");
-        }
-        return R.ok("娣诲姞鎴愬姛");
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:update')")
-    @OperationLog("淇敼閮ㄩ棬")
-    @PostMapping("/dept/update")
-    public R update(@RequestBody Dept dept) {
-        if (dept.getParentId() != null && dept.getParentId() > 0) {
-            Dept parent = deptService.getById(dept.getParentId());
-            if (parent != null) {
-                dept.setParentName(parent.getName());
-            }
-        } else {
-            dept.setParentId(0L);
-        }
-
-        NodeUtils nodeUtils = new NodeUtils();
-        nodeUtils.generatePath0(item -> deptService.getById(item.getParentId()), dept, Dept::getId, Dept::getName, Dept::getParentId);
-        dept.setPath(nodeUtils.path.toString());
-        dept.setPathName(nodeUtils.pathName.toString());
-
-        dept.setUpdateBy(getLoginUserId());
-        dept.setUpdateTime(new Date());
-        if (!deptService.updateById(dept)) {
-            return R.error("淇敼澶辫触");
-        }
-        return R.ok("淇敼鎴愬姛");
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:remove')")
-    @OperationLog("鍒犻櫎閮ㄩ棬")
-    @PostMapping("/dept/remove/{ids}")
-    public R remove(@PathVariable Long[] ids) {
-        if (!deptService.removeByIds(Arrays.asList(ids))) {
-            return R.error("鍒犻櫎澶辫触");
-        }
-        return R.ok("鍒犻櫎鎴愬姛");
-    }
-
-    @PreAuthorize("hasAuthority('system:dept:list')")
-    @PostMapping("/dept/query")
-    public R query(@RequestParam(required = false) String condition) {
-        List<KeyValVo> vos = new ArrayList<>();
-        LambdaQueryWrapper<Dept> wrapper = new LambdaQueryWrapper<>();
-        if (!Cools.isEmpty(condition)) {
-            wrapper.like(Dept::getName, condition);
-        }
-        deptService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
-                item -> vos.add(new KeyValVo(item.getId(), item.getName()))
-        );
-        return R.ok().add(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);
-    }
-
-}
+package com.zy.asrs.wms.system.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.R;
+import com.zy.asrs.wms.common.annotation.CacheData;
+import com.zy.asrs.wms.common.annotation.OperationLog;
+import com.zy.asrs.wms.common.domain.BaseParam;
+import com.zy.asrs.wms.common.domain.KeyValVo;
+import com.zy.asrs.wms.common.domain.PageParam;
+import com.zy.asrs.wms.system.entity.Dept;
+import com.zy.asrs.wms.system.service.DeptService;
+import com.zy.asrs.wms.utils.ExcelUtil;
+import com.zy.asrs.wms.utils.NodeUtils;
+import com.zy.asrs.wms.utils.Utils;
+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 java.util.*;
+
+@RestController
+@RequestMapping("/api")
+public class DeptController extends BaseController {
+
+    @Autowired
+    private DeptService deptService;
+
+    @PreAuthorize("hasAuthority('system:dept:list')")
+    @PostMapping("/dept/page")
+    @CacheData(tableName = {"sys_dept"})
+    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)));
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:list')")
+    @PostMapping("/dept/list")
+    @CacheData(tableName = {"sys_dept"})
+    public R list(@RequestBody Map<String, Object> map) {
+        return R.ok().add(deptService.list());
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:list')")
+    @PostMapping("/dept/tree")
+    @CacheData(tableName = {"sys_dept"})
+    public R tree(@RequestBody Map<String, Object> map) {
+//        PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class);
+//        QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort"));
+        List<Dept> deptList = deptService.list(new LambdaQueryWrapper<Dept>().orderByAsc(Dept::getSort));
+        List<Dept> treeData = Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren);
+        if (!Cools.isEmpty(map.get("condition"))) {
+            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);
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:list')")
+    @GetMapping("/dept/{id}")
+    @CacheData(tableName = {"sys_dept"})
+    public R get(@PathVariable("id") Long id) {
+        return R.ok().add(deptService.getById(id));
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:save')")
+    @OperationLog("娣诲姞閮ㄩ棬")
+    @PostMapping("/dept/save")
+    public R save(@RequestBody Dept dept) {
+        if (dept.getParentId() != null && dept.getParentId() > 0) {
+            Dept parent = deptService.getById(dept.getParentId());
+            if (parent != null) {
+                dept.setParentName(parent.getName());
+            }
+        } else {
+            dept.setParentId(0L);
+        }
+
+        NodeUtils nodeUtils = new NodeUtils();
+        nodeUtils.generatePath0(item -> deptService.getById(item.getParentId()), dept, Dept::getId, Dept::getName, Dept::getParentId);
+        dept.setPath(nodeUtils.path.toString());
+        dept.setPathName(nodeUtils.pathName.toString());
+
+        dept.setCreateBy(getLoginUserId());
+        dept.setCreateTime(new Date());
+        dept.setUpdateBy(getLoginUserId());
+        dept.setUpdateTime(new Date());
+        if (!deptService.save(dept)) {
+            return R.error("娣诲姞澶辫触");
+        }
+        return R.ok("娣诲姞鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:update')")
+    @OperationLog("淇敼閮ㄩ棬")
+    @PostMapping("/dept/update")
+    public R update(@RequestBody Dept dept) {
+        if (dept.getParentId() != null && dept.getParentId() > 0) {
+            Dept parent = deptService.getById(dept.getParentId());
+            if (parent != null) {
+                dept.setParentName(parent.getName());
+            }
+        } else {
+            dept.setParentId(0L);
+        }
+
+        NodeUtils nodeUtils = new NodeUtils();
+        nodeUtils.generatePath0(item -> deptService.getById(item.getParentId()), dept, Dept::getId, Dept::getName, Dept::getParentId);
+        dept.setPath(nodeUtils.path.toString());
+        dept.setPathName(nodeUtils.pathName.toString());
+
+        dept.setUpdateBy(getLoginUserId());
+        dept.setUpdateTime(new Date());
+        if (!deptService.updateById(dept)) {
+            return R.error("淇敼澶辫触");
+        }
+        return R.ok("淇敼鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:remove')")
+    @OperationLog("鍒犻櫎閮ㄩ棬")
+    @PostMapping("/dept/remove/{ids}")
+    public R remove(@PathVariable Long[] ids) {
+        if (!deptService.removeByIds(Arrays.asList(ids))) {
+            return R.error("鍒犻櫎澶辫触");
+        }
+        return R.ok("鍒犻櫎鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('system:dept:list')")
+    @PostMapping("/dept/query")
+    public R query(@RequestParam(required = false) String condition) {
+        List<KeyValVo> vos = new ArrayList<>();
+        LambdaQueryWrapper<Dept> wrapper = new LambdaQueryWrapper<>();
+        if (!Cools.isEmpty(condition)) {
+            wrapper.like(Dept::getName, condition);
+        }
+        deptService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
+                item -> vos.add(new KeyValVo(item.getId(), item.getName()))
+        );
+        return R.ok().add(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);
+    }
+
+}

--
Gitblit v1.9.1