查询部门信息 by name

This commit is contained in:
wangliwen 2022-07-11 11:02:39 +08:00
parent c7a4e1219c
commit 1b46f676f2
1 changed files with 9 additions and 7 deletions

View File

@ -11,15 +11,13 @@ import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.service.SysDeptService; import io.renren.modules.sys.service.SysDeptService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/** /**
* 部门管理 * 部门管理
@ -47,9 +45,13 @@ public class SysDeptController {
@ApiOperation("查询所有部门列表") @ApiOperation("查询所有部门列表")
@LogOperation("查询所有部门列表") @LogOperation("查询所有部门列表")
// @RequiresPermissions("sys:dept:list") // @RequiresPermissions("sys:dept:list")
public Result<List<Map<String, Object>>> all() { public Result<List<Map<String, Object>>> all(String name) {
List<Map<String, Object>> list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); List<Map<String, Object>> 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<List<Map<String, Object>>>().ok(list); return new Result<List<Map<String, Object>>>().ok(list);
} }