From 2bdcf12109e62a731eb16e90b6e1c39a67853fb1 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期一, 13 十月 2025 18:46:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaApprovalApplicationAssetController.java | 72 +++++++++++++++++++++++++++++++-----
1 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaApprovalApplicationAssetController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaApprovalApplicationAssetController.java
index 1c1835a..b684ab7 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaApprovalApplicationAssetController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaApprovalApplicationAssetController.java
@@ -6,9 +6,11 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.system.constants.AssetDeptConstant;
import com.ruoyi.system.dto.asset.OaApprovalApplicationAssetReceiveDTO;
import com.ruoyi.system.dto.asset.OaApprovalApplicationAssetReturnDTO;
import com.ruoyi.system.query.OaApprovalApplicationAssetPageQuery;
+import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.OaApprovalApplicationAssetService;
import com.ruoyi.system.vo.asset.AssetMainVO;
import com.ruoyi.system.vo.asset.OaApprovalApplicationAssetDetailVO;
@@ -18,6 +20,7 @@
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -41,12 +44,12 @@
public class OaApprovalApplicationAssetController {
private final OaApprovalApplicationAssetService oaApprovalApplicationAssetService;
+ private final ISysUserService sysUserService;
@ApiOperation("提交资产领用申请")
@PostMapping("/submit-receive")
@Log(title = "资产领用申请-提交", businessType = BusinessType.INSERT)
public R<Void> submitReceive(@Valid @RequestBody OaApprovalApplicationAssetReceiveDTO dto) {
- //TODO 提交时需要校验资产状态,是否已经被领用借用处置
oaApprovalApplicationAssetService.submitReceiveBorrow(dto);
return R.ok();
}
@@ -54,14 +57,26 @@
@ApiOperation("获取资产领用申请分页列表")
@PostMapping("/page-list")
public R<IPage<OaApprovalApplicationAssetPageVO>> getReceivePageList(@RequestBody OaApprovalApplicationAssetPageQuery pageQuery) {
- // 数据权限:非管理员仅能查看本部门
+ // 数据权限:超级管理员/资产管理部查看所有数据,其他部门查看当前及下级部门的数据
Long userId = SecurityUtils.getUserId();
boolean isAdmin = SecurityUtils.isAdmin(userId);
+
if (!isAdmin) {
try {
- pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getDeptId()));
+ // 获取当前用户的部门名称
+ String deptName = sysUserService.selectUserById(userId).getDept().getDeptName();
+
+ // 非超级管理员且非资产管理部,设置部门权限
+ if (!AssetDeptConstant.ASSET_DEPARTMENT_NAME.equals(deptName)) {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ }
} catch (Exception e) {
- // ignore parse, leave null if cannot parse
+ // 如果获取部门信息失败,默认设置部门权限
+ try {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ } catch (Exception ex) {
+ // ignore parse, leave null if cannot parse
+ }
}
}
IPage<OaApprovalApplicationAssetPageVO> page = oaApprovalApplicationAssetService.getReceivePageList(pageQuery);
@@ -132,14 +147,26 @@
@ApiOperation("获取资产归还申请分页列表")
@PostMapping("/page-return-list")
public R<IPage<OaApprovalApplicationAssetPageVO>> getReturnPageList(@RequestBody OaApprovalApplicationAssetPageQuery pageQuery) {
- // 数据权限:非管理员仅能查看本部门
+ // 数据权限:超级管理员/资产管理部查看所有数据,其他部门查看当前及下级部门的数据
Long userId = SecurityUtils.getUserId();
boolean isAdmin = SecurityUtils.isAdmin(userId);
+
if (!isAdmin) {
try {
- pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getDeptId()));
+ // 获取当前用户的部门名称
+ String deptName = sysUserService.selectUserById(userId).getDept().getDeptName();
+
+ // 非超级管理员且非资产管理部,设置部门权限
+ if (!AssetDeptConstant.ASSET_DEPARTMENT_NAME.equals(deptName)) {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ }
} catch (Exception e) {
- // ignore parse, leave null if cannot parse
+ // 如果获取部门信息失败,默认设置部门权限
+ try {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ } catch (Exception ex) {
+ // ignore parse, leave null if cannot parse
+ }
}
}
IPage<OaApprovalApplicationAssetPageVO> page = oaApprovalApplicationAssetService.getReturnPageList(pageQuery);
@@ -149,17 +176,42 @@
@ApiOperation("获取资产归还提醒分页列表")
@PostMapping("/page-return-notify-list")
public R<IPage<OaApprovalApplicationAssetPageVO>> getReturnNotifyPageList(@RequestBody OaApprovalApplicationAssetPageQuery pageQuery) {
- // 数据权限:非管理员仅能查看本部门
+ // 数据权限:超级管理员/资产管理部查看所有数据,其他部门查看当前及下级部门的数据
Long userId = SecurityUtils.getUserId();
boolean isAdmin = SecurityUtils.isAdmin(userId);
+
if (!isAdmin) {
try {
- pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getDeptId()));
+ // 获取当前用户的部门名称
+ String deptName = sysUserService.selectUserById(userId).getDept().getDeptName();
+
+ // 非超级管理员且非资产管理部,设置部门权限
+ if (!AssetDeptConstant.ASSET_DEPARTMENT_NAME.equals(deptName)) {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ }
} catch (Exception e) {
- // ignore parse, leave null if cannot parse
+ // 如果获取部门信息失败,默认设置部门权限
+ try {
+ pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId()));
+ } catch (Exception ex) {
+ // ignore parse, leave null if cannot parse
+ }
}
}
IPage<OaApprovalApplicationAssetPageVO> page = oaApprovalApplicationAssetService.getReturnNotifyPageList(pageQuery);
return R.ok(page);
}
+
+ @ApiOperation("获取资产归还详情")
+ @GetMapping("/detail/return/{id}")
+ public R<OaApprovalApplicationAssetDetailVO> getReturnDetail(@ApiParam(name = "id", value = "审批单ID", required = true) @PathVariable Integer id) {
+ OaApprovalApplicationAssetDetailVO detail = oaApprovalApplicationAssetService.getReturnDetail(id);
+ return R.ok(detail);
+ }
+ @ApiOperation("删除/领用/借用/归还申请")
+ @DeleteMapping("/{id}")
+ public R<?> delete(@ApiParam(name = "id",value = "审批记录ID",required = true) @PathVariable Integer id){
+ oaApprovalApplicationAssetService.deleteByApplicationId(id);
+ return R.ok();
+ }
}
--
Gitblit v1.7.1