From 1b46f676f2a36dfcdc8f53347a801f94ee079669 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 11 Jul 2022 11:02:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=83=A8=E9=97=A8=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20by=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/SysDeptController.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 2748b040..90101897 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 @@ -11,15 +11,13 @@ import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 部门管理 @@ -47,9 +45,13 @@ public class SysDeptController { @ApiOperation("查询所有部门列表") @LogOperation("查询所有部门列表") // @RequiresPermissions("sys:dept:list") - public Result>> all() { - List> list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); - + public Result>> all(String name) { + List> list = new ArrayList<>(); + if (StringUtils.isNotEmpty(name)) { + list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", name)); + } else { + list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); + } return new Result>>().ok(list); }