From a4b71c703284826e36bbbf79d04e2f9a6c0c1967 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 4 Nov 2025 15:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BA=AB=E4=BB=BD=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BB=8F=E7=90=86=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/sys/appmanager/RoomRolesEnum.java | 6 +++++ .../app/command/room/RoomEnterCmdExe.java | 10 +++++++- .../user/query/RoomManagerAuthsQueryExe.java | 3 ++- .../user/user/UserIdentityServiceImpl.java | 23 ++++++++++++++++--- .../other/app/dto/h5/UserIdentityVO.java | 5 ++++ .../rds/service/sys/AdministratorService.java | 10 +++++++- .../sys/impl/AdministratorServiceImpl.java | 10 ++++++++ 7 files changed, 61 insertions(+), 6 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/sys/appmanager/RoomRolesEnum.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/sys/appmanager/RoomRolesEnum.java index dba314cd..87840444 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/sys/appmanager/RoomRolesEnum.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/sys/appmanager/RoomRolesEnum.java @@ -9,6 +9,12 @@ import java.util.Objects; * @since 2021/16 */ public enum RoomRolesEnum { + + /** + * 经理 + */ + MANAGER, + /** * 超级管理员. */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java index 23ce609e..1ba673e0 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java @@ -247,6 +247,7 @@ public class RoomEnterCmdExe { checkSysOrigin(cmd.requiredReqUserId(), manager.getSysOrigin()); boolean appAdmin = isAppAdmin(cmd); + boolean appManager = isAppManager(cmd); RoomSetting setting = manager.getSetting(); List roomProfileList = roomProfileManagerService.listProfileByRoomIds(Set.of(cmd.getRoomId())); if (roomProfileList.size() > 0){ @@ -267,7 +268,7 @@ public class RoomEnterCmdExe { } manager.setSetting(setting); // 非管理员情况下, 验证房间是否已关闭 - if (!appAdmin) { + if (!appAdmin && !appManager ) { ResponseAssert.isFalse(RoomErrorCode.ROOM_CLOSE, Objects.equals(manager.getEvent(), RoomEventEnum.CLOSE.name())); } @@ -301,6 +302,13 @@ public class RoomEnterCmdExe { return administratorService.existsSupperAdmin(cmd.requiredReqUserId()); } + /** + * 校验进来的用户是否为App经理. + */ + private boolean isAppManager(RoomEntryCmd cmd) { + return administratorService.existsManager(cmd.requiredReqUserId()); + } + private RoomProfileDTO toRoomProfileDTO(RoomProfileManager manager, UserProfileDTO userProfile) { RoomProfileDTO roomProfile = roomProfileAppConvertor.toRoomProfileDTO(manager); roomProfile.setCountryCode(userProfile.getCountryCode()); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/RoomManagerAuthsQueryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/RoomManagerAuthsQueryExe.java index 1584e45f..600a6a0e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/RoomManagerAuthsQueryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/RoomManagerAuthsQueryExe.java @@ -82,7 +82,8 @@ public class RoomManagerAuthsQueryExe { Boolean admin = Objects.equals(administrator.getRoles(), RoomRolesEnum.ADMIN.name()) && administratorRoomService.isRoomExist(administrator.getUserId(), roomId); - return superAdmin || admin; + Boolean manager = Objects.equals(administrator.getRoles(), RoomRolesEnum.MANAGER.name()); + return superAdmin || admin || manager; } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/UserIdentityServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/UserIdentityServiceImpl.java index ee5616ac..1bec9e15 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/UserIdentityServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/UserIdentityServiceImpl.java @@ -2,15 +2,18 @@ package com.red.circle.other.app.service.user.user; import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.mybatis.constant.PageConstant; import com.red.circle.other.app.dto.cmd.material.PropsStoreTypeQryCmd; import com.red.circle.other.app.dto.h5.UserIdentityVO; import com.red.circle.other.app.service.team.TeamBdService; +import com.red.circle.other.infra.database.rds.entity.sys.Administrator; import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService; import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; import com.red.circle.other.inner.endpoint.team.bd.BdTeamInfoClient; import com.red.circle.other.inner.endpoint.team.bd.BdTeamLeaderClient; import com.red.circle.other.inner.endpoint.team.target.TeamProfileClient; import com.red.circle.other.inner.enums.material.PropsCommodityType; +import com.red.circle.other.inner.enums.sys.appmanager.RoomRolesEnum; import com.red.circle.other.inner.enums.team.TeamMemberRole; import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberDTO; import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; @@ -19,6 +22,7 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Objects; +import java.util.Optional; @Service @RequiredArgsConstructor @@ -35,15 +39,28 @@ public class UserIdentityServiceImpl implements UserIdentityService { public UserIdentityVO getUserIdentity(Long userId) { TeamMemberDTO teamMember = ResponseAssert.requiredSuccess( teamProfileClient.getByMemberId(userId)); - return new UserIdentityVO() + + Administrator administrator = administratorService.getByUserId(userId); + boolean isAdmin = Optional.ofNullable(administrator) + .map(e -> RoomRolesEnum.ADMIN.eq(e.getRoles())) + .orElse(Boolean.FALSE); + boolean isSuperAdmin = Optional.ofNullable(administrator) + .map(e -> RoomRolesEnum.SUPER_ADMIN.eq(e.getRoles())) + .orElse(Boolean.FALSE); + boolean isManager = Optional.ofNullable(administrator) + .map(e -> RoomRolesEnum.MANAGER.eq(e.getRoles())) + .orElse(Boolean.FALSE); + + return new UserIdentityVO() .setAgent(Objects.nonNull(teamMember) && TeamMemberRole.OWN.eq(teamMember.getRole())) .setAnchor(Objects.nonNull(teamMember)) .setBd(ResponseAssert.requiredSuccess(bdTeamInfoClient.check(userId))) .setFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkFreightAgent(userId))) .setSuperFreightAgent(ResponseAssert.requiredSuccess(freightGoldClient.checkSuperFreightAgent(userId))) - .setSuperAdmin(administratorService.existsSupperAdmin(userId)) - .setAdmin(administratorService.existsAdmin(userId)) + .setSuperAdmin(isSuperAdmin) + .setAdmin(isAdmin) .setBdLeader(ResponseAssert.requiredSuccess(bdTeamLeaderClient.check(userId))) + .setManager(isManager) ; } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/UserIdentityVO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/UserIdentityVO.java index 0de7037e..ea0c059d 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/UserIdentityVO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/UserIdentityVO.java @@ -54,6 +54,11 @@ public class UserIdentityVO implements Serializable { */ private Boolean superAdmin; + /** + * 是否是经理 + */ + private Boolean manager; + /** * 历史身份. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/AdministratorService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/AdministratorService.java index bf893e25..6a584876 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/AdministratorService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/AdministratorService.java @@ -40,11 +40,19 @@ public interface AdministratorService extends BaseService { /** * 是否是超级管理员. * - * @param userId 验证用户是否是管理员 + * @param userId 验证用户是否是超级管理员 * @return true 是,false 不是 */ boolean existsSupperAdmin(Long userId); + /** + * 是否是经理. + * + * @param userId 验证用户是否是经理 + * @return true 是,false 不是 + */ + boolean existsManager(Long userId); + /** * 用户组是否存在可用管理员. * diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/AdministratorServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/AdministratorServiceImpl.java index f308af15..f33c77ea 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/AdministratorServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/AdministratorServiceImpl.java @@ -65,6 +65,16 @@ public class AdministratorServiceImpl extends .orElse(Boolean.FALSE); } + @Override + public boolean existsManager(Long userId) { + return query() + .select(Administrator::getId) + .eq(Administrator::getUserId, userId) + .eq(Administrator::getStatus, 1) + .eq(Administrator::getRoles, RoomRolesEnum.MANAGER.name()) + .last(PageConstant.LIMIT_ONE).getOne() != null; + } + @Override public boolean existsAvailable(Set userIds) { return Optional.ofNullable(