From a11f8ef4936715eaefc21d6be798f32434af8914 Mon Sep 17 00:00:00 2001 From: zzc <1278921369@qq.com> Date: Mon, 16 Jun 2025 23:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=86=E4=BA=AB=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/app/EqHomeController.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java index 820f20605..b6649661d 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java @@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaIgnore; import cn.dev33.satoken.secure.BCrypt; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import jakarta.validation.constraints.NotEmpty; import lombok.RequiredArgsConstructor; import org.dromara.common.core.domain.R; @@ -250,17 +251,27 @@ public class EqHomeController extends BaseController { SysUserVo sysUserVo = userService.selectUserByUserName(bo.getSharedUserName()); if (sysUserVo==null) throw new RuntimeException("被分享者用户名不存在"); - if (bo.getShareUserId() == null){ + String currentUserName = LoginHelper.getUsername(); + if (currentUserName.equals(bo.getSharedUserName())) throw new RuntimeException("不能分享给自己"); + bo.setShareUserId(LoginHelper.getUserId()); + /*if (bo.getShareUserId() == null){ bo.setShareUserId(LoginHelper.getUserId()); - String currentUserName = LoginHelper.getUsername(); - if (currentUserName.equals(bo.getSharedUserName())) throw new RuntimeException("不能分享给自己"); bo.setShareUserName(currentUserName); - } + }*/ bo.setSharedUserId(sysUserVo.getUserId()); + List eqShareVos = shareService.queryList(bo); + bo.setShareUserName(currentUserName); bo.setSharedUserName(sysUserVo.getUserName()); -// List eqShareVos = shareService.queryList(bo); -// if (!eqShareVos.isEmpty()) throw new RuntimeException("该成员已被分享"); - return toAjax(shareService.insertByBo(bo)); + if (CollUtil.isEmpty(eqShareVos)){ + return toAjax(shareService.insertByBo(bo)); + }else{ + EqShareVo eqShareVo = eqShareVos.get(0); + String sharedEquipmentIds = eqShareVo.getSharedEquipmentIds(); + if (sharedEquipmentIds.contains(bo.getSharedEquipmentIds())) throw new RuntimeException("该设备已经分享到该成员"); + sharedEquipmentIds = sharedEquipmentIds + "," + bo.getSharedEquipmentIds(); + eqShareVo.setSharedEquipmentIds(sharedEquipmentIds); + return toAjax(shareService.updateByBo(bo)); + } } /**