From 7d311bb3a034cab9d9e91275ae3723cc163abf07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 2 Apr 2025 16:13:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/ShopPagePermissionController.java | 8 ++--- .../account/service/ShopPagePathService.java | 3 ++ .../service/impl/ShopPagePathServiceImpl.java | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPagePermissionController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPagePermissionController.java index 32bf9561..1b98294c 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPagePermissionController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPagePermissionController.java @@ -56,12 +56,10 @@ public class ShopPagePermissionController { */ @GetMapping("/detail") public CzgResult> detail(@RequestParam Long staffId) { - Set pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId, - StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, staffId)).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet()); - if (pageIdList.isEmpty()) { - return CzgResult.success(new ArrayList<>()); + if (StpKit.USER.isStaff() && StpKit.USER.getLoginIdAsLong() != staffId) { + return CzgResult.failure("员工无权限"); } - return CzgResult.success(shopPagePathService.list(new QueryWrapper().in(ShopPagePath::getId, pageIdList))); + return CzgResult.success(shopPagePathService.detail(staffId)); } /** diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopPagePathService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopPagePathService.java index 8f4d95c9..76e2e9c5 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopPagePathService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopPagePathService.java @@ -3,6 +3,8 @@ package com.czg.account.service; import com.mybatisflex.core.service.IService; import com.czg.account.entity.ShopPagePath; +import java.util.List; + /** * 服务层。 * @@ -11,4 +13,5 @@ import com.czg.account.entity.ShopPagePath; */ public interface ShopPagePathService extends IService { + List detail(Long staffId); } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPagePathServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPagePathServiceImpl.java index 02cf681d..be3b2357 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPagePathServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopPagePathServiceImpl.java @@ -1,10 +1,22 @@ package com.czg.service.account.service.impl; +import com.czg.account.entity.ShopStaffPagePermission; +import com.czg.account.service.ShopStaffPagePermissionService; +import com.czg.resp.CzgResult; +import com.czg.sa.StpKit; +import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; import com.czg.account.entity.ShopPagePath; import com.czg.account.service.ShopPagePathService; import com.czg.service.account.mapper.ShopPagePathMapper; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 服务层实现。 @@ -14,5 +26,24 @@ import org.springframework.stereotype.Service; */ @Service public class ShopPagePathServiceImpl extends ServiceImpl implements ShopPagePathService{ + @Resource + private ShopStaffPagePermissionService shopStaffPagePermissionService; + @Override + public List detail(Long staffId) { + Set pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId, + StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, staffId)).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet()); + if (pageIdList.isEmpty()) { + list().forEach(item -> { + ShopStaffPagePermission permission = new ShopStaffPagePermission(); + permission.setShopId(StpKit.USER.getShopId()); + permission.setStaffId(staffId); + permission.setPagePathId(item.getId()); + shopStaffPagePermissionService.save(permission); + pageIdList.add(permission.getPagePathId()); + }); + } + + return list(new QueryWrapper().in(ShopPagePath::getId, pageIdList)); + } }