From a6620a396a944e51fff7e3f46652a3f27675dce9 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 25 Oct 2022 15:04:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8C=BA=E5=9F=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E7=AE=A1=E7=90=86=E7=9A=84=E9=83=A8=E9=97=A8?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/SysDeptController.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java index 65bf5687..cd1e026d 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java @@ -7,8 +7,11 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.security.user.SecurityUser; import io.renren.modules.sys.dto.SysDeptDTO; +import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.service.SysDeptService; +import io.renren.modules.sys.service.SysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -30,6 +33,8 @@ public class SysDeptController { private SysDeptService sysDeptService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysUserService sysUserService; @GetMapping("list") @ApiOperation("查询部门列表") @@ -41,6 +46,21 @@ public class SysDeptController { return new Result>().ok(list); } + @GetMapping("listForRegion") + @ApiOperation("查询区域管理员管理的部门") + @LogOperation("查询区域管理员管理的部门") + public Result>> listForRegion() { + List> list = new ArrayList<>(); + SysUserDTO userDTO = sysUserService.get(SecurityUser.getUserId()); + if (userDTO.getDeptId() != null) { // 区域管理员 + SysDeptDTO sysDeptDTO = sysDeptService.get(userDTO.getDeptId()); + list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `district` = %d", sysDeptDTO.getDistrict())); + } else if (userDTO.getSuperAdmin() == 1) { // 超级管理员 + list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); + } + return new Result>>().ok(list); + } + @GetMapping("all") @ApiOperation("查询所有部门列表") @LogOperation("查询所有部门列表")