Bladeren bron

feat: #4-#10 后端业务模块全部完成

绩效管理系统后端全栈交付,含项目/产值/审核/绩效/通知/系统管理模块

- Controller层: 5个控制器(PdProject/PdOutputValue/PdPerformance/PdNotification/SysBackup)
- Service层: 4个业务接口+实现(产值校验/绩效自动核算20%/项目导入)
- 权限控制: PerfPermissionService部门级数据权限(@pps)
- 定时任务: PerfTask(填报提醒/审核提醒/逾期标记/自动核算)
- 角色Key: admin(系统管理员)/dept_admin(部门管理员)/reviewer(院班子审核员)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shenzx 1 maand geleden
bovenliggende
commit
df136c5a2b

+ 90 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PerfPermissionService.java

@@ -0,0 +1,90 @@
+package com.ruoyi.framework.web.service;
+
+import org.springframework.stereotype.Component;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.SecurityUtils;
+
+/**
+ * 绩效管理系统权限服务
+ *
+ * @author ruoyi
+ */
+@Component("pps")
+public class PerfPermissionService
+{
+    /** 所有权限前缀 */
+    private static final String ALL_PERMISSION = "*:*:*";
+    private static final String DEPT_ADMIN_ROLE = "dept_admin";
+    private static final String REVIEWER_ROLE = "reviewer";
+    private static final String SUPER_ADMIN_ROLE = "admin";
+
+    /**
+     * 判断当前用户是否有指定权限
+     */
+    public boolean hasPermi(String permission)
+    {
+        return SecurityUtils.hasPermi(permission);
+    }
+
+    /**
+     * 判断当前用户是否为院班子审核员
+     */
+    public boolean isReviewer()
+    {
+        return hasRole(REVIEWER_ROLE) || isAdmin();
+    }
+
+    /**
+     * 判断当前用户是否为部门管理员
+     */
+    public boolean isDeptAdmin()
+    {
+        return hasRole(DEPT_ADMIN_ROLE) || isAdmin();
+    }
+
+    /**
+     * 判断当前用户是否为系统管理员
+     */
+    public boolean isAdmin()
+    {
+        return hasRole(SUPER_ADMIN_ROLE);
+    }
+
+    /**
+     * 判断当前用户是否有权访问指定部门的数据
+     * 部门管理员只能访问本部门数据,院班子和系统管理员可访问所有数据
+     */
+    public boolean hasDeptAccess(Long deptId)
+    {
+        if (isReviewer() || isAdmin())
+        {
+            return true;
+        }
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        return user.getDeptId() != null && user.getDeptId().equals(deptId);
+    }
+
+    /**
+     * 获取当前用户可访问的部门ID
+     * 返回null表示可访问所有部门
+     */
+    public Long getAccessibleDeptId()
+    {
+        if (isReviewer() || isAdmin())
+        {
+            return null; // 所有部门
+        }
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        return user.getDeptId();
+    }
+
+    /**
+     * 验证用户是否具有指定角色
+     */
+    private boolean hasRole(String roleKey)
+    {
+        return SecurityUtils.getLoginUser().getUser().getRoles().stream()
+                .anyMatch(role -> roleKey.equals(role.getRoleKey()));
+    }
+}