From 235cb37b7b69e69de0cffb0eac6a236c4b52c920 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 29 Jul 2026 11:28:07 +0800 Subject: [PATCH] =?UTF-8?q?2026-07-29=20Lab=EF=BC=9A=201=E3=80=81=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E9=83=A8=E9=97=A8=E8=AE=BE=E7=BD=AE=E4=B8=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E5=85=B8=E5=8F=96=E5=80=BC=EF=BC=8C=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E5=8F=96site=20=3D=2041=EF=BC=9B=202=E3=80=81?= =?UTF-8?q?=E3=80=90=E5=88=A0=E9=99=A4=E3=80=91=E9=9C=80=E8=A6=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9C=89=E6=9D=83=E9=99=90=20=E4=B8=94=20=EF=BC=88?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E4=BA=BA=E4=B8=80=E8=87=B4=20=E6=88=96?= =?UTF-8?q?=E8=80=85=20=E6=98=AF=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=EF=BC=89=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/lab/controller/LabController.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/spring/modules/lab/controller/LabController.java b/src/main/java/com/spring/modules/lab/controller/LabController.java index 1d769546..d000c440 100644 --- a/src/main/java/com/spring/modules/lab/controller/LabController.java +++ b/src/main/java/com/spring/modules/lab/controller/LabController.java @@ -11,6 +11,7 @@ import com.spring.modules.lab.vo.LabSubmitVo; import com.spring.modules.oss.entity.SysOssEntity; import com.spring.modules.oss.service.SysOssService; import com.spring.modules.sift.vo.QuerySavedVo; +import com.spring.modules.sys.dao.SysMenuDao; import com.spring.modules.sys.entity.SysUserEntity; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; @@ -41,6 +42,9 @@ public class LabController { @Autowired private TransNoControlService transNoControlService; + @Autowired + private SysMenuDao sysMenuDao; + /** * 列表查询 */ @@ -240,6 +244,9 @@ public class LabController { if (!"草稿".equals(exists.getStatus())) { return R.error("仅草稿状态的单据允许删除"); } + if (!canDeleteLabByApplicantOrSuperAdmin(exists)) { + return R.error("仅申请人本人或超级管理员允许删除"); + } QueryWrapper deleteWrapper = new QueryWrapper<>(); deleteWrapper.eq("site", lab.getSite()).eq("reference_no", lab.getReferenceNo()); @@ -258,4 +265,18 @@ public class LabController { SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); return user == null ? "" : user.getUsername(); } + + private boolean canDeleteLabByApplicantOrSuperAdmin(LabEntity exists) { + SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + if (currentUser == null) { + return false; + } + boolean isSuperAdmin = !sysMenuDao.checkSuperAdmin(currentUser.getUserId()).isEmpty(); + if (isSuperAdmin) { + return true; + } + String currentUserName = StringUtils.trimToEmpty(currentUser.getUsername()); + String applicant = exists == null ? "" : StringUtils.trimToEmpty(exists.getApplicant()); + return StringUtils.equals(currentUserName, applicant); + } }