根据登录用户查询对应仓库
This commit is contained in:
@@ -253,4 +253,16 @@ public class SysUserController extends BaseController
|
|||||||
{
|
{
|
||||||
return success(deptService.selectDeptTreeList(dept));
|
return success(deptService.selectDeptTreeList(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户所在部门及所有子部门
|
||||||
|
*/
|
||||||
|
@GetMapping("/myDeptChildren")
|
||||||
|
public AjaxResult getMyDeptChildren(String keyword)
|
||||||
|
{
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<SysDept> list = deptService.selectDeptAndChildrenByUserId(userId, keyword);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,4 +115,13 @@ public interface SysDeptMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeptById(Long deptId);
|
public int deleteDeptById(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门ID查询部门名称
|
||||||
|
*
|
||||||
|
* @param deptId 部门ID
|
||||||
|
* @return 部门名称
|
||||||
|
*/
|
||||||
|
public List<SysDept> selectDeptAndChildren(@Param("deptId") Long deptId,
|
||||||
|
@Param("keyword") String keyword);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,4 +121,12 @@ public interface ISysDeptService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeptById(Long deptId);
|
public int deleteDeptById(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询部门
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 部门信息
|
||||||
|
*/
|
||||||
|
public List<SysDept> selectDeptAndChildrenByUserId(Long userId, String keyword);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.shzg.project.system.domain.SysUser;
|
||||||
|
import com.shzg.project.system.mapper.SysUserMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.shzg.common.constant.UserConstants;
|
import com.shzg.common.constant.UserConstants;
|
||||||
@@ -34,6 +37,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMapper roleMapper;
|
private SysRoleMapper roleMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
@@ -334,4 +340,18 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
{
|
{
|
||||||
return getChildList(list, t).size() > 0 ? true : false;
|
return getChildList(list, t).size() > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> selectDeptAndChildrenByUserId(Long userId, String keyword)
|
||||||
|
{
|
||||||
|
SysUser user = userMapper.selectUserById(userId);
|
||||||
|
if (user == null || user.getDeptId() == null)
|
||||||
|
{
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Long deptId = user.getDeptId();
|
||||||
|
|
||||||
|
return deptMapper.selectDeptAndChildren(deptId, keyword);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,4 +156,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectDeptAndChildren" resultType="com.shzg.project.system.domain.SysDept">
|
||||||
|
SELECT *
|
||||||
|
FROM sys_dept
|
||||||
|
WHERE
|
||||||
|
(dept_id = #{deptId}
|
||||||
|
OR FIND_IN_SET(#{deptId}, ancestors))
|
||||||
|
|
||||||
|
AND del_flag = '0'
|
||||||
|
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
AND dept_name LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user