feat(approve): 添加审批实例按当前用户过滤功能
- 在 ApprovalInstanceDto 中新增 currentUserId 字段用于存储当前用户ID
- 在 ApprovalInstanceMapper.xml 中添加SQL条件过滤当前用户相关的审批实例
- 在 ApprovalInstanceServiceImpl 中自动注入当前用户ID到查询条件
- 实现申请人和审核人的数据权限过滤功能
| | |
| | | |
| | | @Schema(description = "出库批号") |
| | | private String outboundBatches; |
| | | |
| | | @Schema(description = "当前用户ID(查询时自动注入,用于过滤申请人和审核人)") |
| | | private Long currentUserId; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R listPage(Page<ApprovalInstanceVo> page, ApprovalInstanceDto approvalInstanceDto) { |
| | | // 注入当前用户ID,用于过滤只查看申请人和审核人是自己的数据 |
| | | approvalInstanceDto.setCurrentUserId(SecurityUtils.getUserId()); |
| | | IPage<ApprovalInstanceVo> approvalInstanceVoIPage = approvalInstanceMapper.listPage(page, approvalInstanceDto); |
| | | |
| | | List<ApprovalInstanceVo> records = approvalInstanceVoIPage.getRecords(); |
| | |
| | | <if test="ew.applicantName != null and ew.applicantName !=''"> |
| | | and ai.applicant_name = #{ew.applicantName} |
| | | </if> |
| | | <if test="ew.currentUserId != null"> |
| | | and (ai.applicant_id = #{ew.currentUserId} |
| | | or exists (select 1 from approval_task at2 |
| | | where at2.instance_id = ai.id |
| | | and at2.approver_id = #{ew.currentUserId} |
| | | and at2.deleted = 0)) |
| | | </if> |
| | | </where> |
| | | order by ai.create_time desc |
| | | </select> |