From 0017cc88620501d55cd8bf11c802ad435525e138 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Sun, 22 Mar 2026 00:15:34 +0800
Subject: [PATCH] 首页新增通知公告消息提醒
---
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 77 +++++++++++++++++++++++++++++++++-----
1 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
index 6d89724..8a01479 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -6,11 +6,14 @@
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
+import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysRole;
import com.ruoyi.system.domain.vo.TreeSelect;
@@ -46,6 +49,19 @@
}
/**
+ * 查询部门树结构信息
+ *
+ * @param dept 部门信息
+ * @return 部门树信息集合
+ */
+ @Override
+ public List<TreeSelect> selectDeptTreeList(SysDept dept)
+ {
+ List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+ return buildDeptTreeSelect(depts);
+ }
+
+ /**
* 构建前端所需要树结构
*
* @param depts 部门列表
@@ -55,14 +71,9 @@
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
List<SysDept> returnList = new ArrayList<SysDept>();
- List<Long> tempList = new ArrayList<Long>();
+ List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts)
{
- tempList.add(dept.getDeptId());
- }
- for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
- {
- SysDept dept = (SysDept) iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId()))
{
@@ -97,7 +108,7 @@
* @return 选中部门列表
*/
@Override
- public List<Integer> selectDeptListByRoleId(Long roleId)
+ public List<Long> selectDeptListByRoleId(Long roleId)
{
SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
@@ -137,7 +148,7 @@
public boolean hasChildByDeptId(Long deptId)
{
int result = deptMapper.hasChildByDeptId(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -150,7 +161,7 @@
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -160,7 +171,7 @@
* @return 结果
*/
@Override
- public String checkDeptNameUnique(SysDept dept)
+ public boolean checkDeptNameUnique(SysDept dept)
{
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
@@ -169,6 +180,26 @@
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
+ }
+
+ /**
+ * 校验部门是否有数据权限
+ *
+ * @param deptId 部门id
+ */
+ @Override
+ public void checkDeptDataScope(Long deptId)
+ {
+ if (!SecurityUtils.isAdmin() && StringUtils.isNotNull(deptId))
+ {
+ SysDept dept = new SysDept();
+ dept.setDeptId(deptId);
+ List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+ if (StringUtils.isEmpty(depts))
+ {
+ throw new ServiceException("没有权限访问部门数据!");
+ }
+ }
}
/**
@@ -251,6 +282,32 @@
}
/**
+ * 保存部门排序
+ *
+ * @param deptIds 部门ID数组
+ * @param orderNums 排序数组
+ */
+ @Override
+ @Transactional
+ public void updateDeptSort(String[] deptIds, String[] orderNums)
+ {
+ try
+ {
+ for (int i = 0; i < deptIds.length; i++)
+ {
+ SysDept dept = new SysDept();
+ dept.setDeptId(Convert.toLong(deptIds[i]));
+ dept.setOrderNum(Convert.toInt(orderNums[i]));
+ deptMapper.updateDeptSort(dept);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ServiceException("保存排序异常,请联系管理员");
+ }
+ }
+
+ /**
* 删除部门管理信息
*
* @param deptId 部门ID
--
Gitblit v1.9.3