From 8c2b965e6da927114789db6073e8248d30678455 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 23 Apr 2026 19:05:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E5=AE=B6=E5=88=97=E8=A1=A8=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 3d52e519415915d97b1472c075eeed736ab38660) --- .../app/room/LiveVoiceRoomRestController.java | 4 +- .../room/query/RoomCountryListQryExe.java | 44 +++++++++++++++++-- .../room/LiveVoiceRoomServiceImpl.java | 4 +- .../service/room/LiveVoiceRoomService.java | 2 +- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/room/LiveVoiceRoomRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/room/LiveVoiceRoomRestController.java index 25430328..28079373 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/room/LiveVoiceRoomRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/room/LiveVoiceRoomRestController.java @@ -182,8 +182,8 @@ public class LiveVoiceRoomRestController extends BaseController { * @eo.request-type formdata */ @GetMapping("/country") - public List listCountry() { - return liveVoiceRoomService.listRoomCountry(); + public List listCountry(AppExtCommand cmd) { + return liveVoiceRoomService.listRoomCountry(cmd.requiredReqUserId()); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomCountryListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomCountryListQryExe.java index 364d0531..2305999d 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomCountryListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomCountryListQryExe.java @@ -1,9 +1,14 @@ package com.red.circle.other.app.command.room.query; import com.red.circle.other.app.dto.clientobject.room.CountryCO; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; +import com.red.circle.other.domain.model.user.UserProfile; +import com.red.circle.other.infra.constant.RegionConstants; import com.red.circle.other.infra.database.rds.entity.sys.SysCountryCode; import com.red.circle.other.infra.database.rds.service.sys.SysCountryCodeService; import com.red.circle.tool.core.text.StringUtils; +import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -18,10 +23,43 @@ import org.springframework.stereotype.Component; public class RoomCountryListQryExe { private final SysCountryCodeService sysCountryCodeService; + private final UserRegionGateway userRegionGateway; + private final UserProfileGateway userProfileGateway; - public List execute() { - List countries = sysCountryCodeService.listOpenCountry(); - return countries.stream().map(this::toCountryCO).toList(); + public List execute(Long userId) { + List all = sysCountryCodeService.listOpenCountry(); + + String userRegion = userRegionGateway.getRegionCode(userId); + UserProfile userProfile = userProfileGateway.getByUserId(userId); + String userCountryCode = userProfile != null ? userProfile.getCountryCode() : null; + + boolean isArRegion = RegionConstants.AR.equals(userRegion); + + List current = new ArrayList<>(); + List arList = new ArrayList<>(); + List otherList = new ArrayList<>(); + + for (SysCountryCode entity : all) { + CountryCO co = toCountryCO(entity); + if (StringUtils.isNotBlank(userCountryCode) && userCountryCode.equals(entity.getAlphaTwo())) { + current.add(co); + } else if (RegionConstants.AR_REGIONS.contains(entity.getAlphaTwo())) { + arList.add(co); + } else { + otherList.add(co); + } + } + + List result = new ArrayList<>(); + result.addAll(current); + if (isArRegion) { + result.addAll(arList); + result.addAll(otherList); + } else { + result.addAll(otherList); + result.addAll(arList); + } + return result; } private CountryCO toCountryCO(SysCountryCode entity) { diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomServiceImpl.java index 456292af..32a60fa1 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomServiceImpl.java @@ -99,8 +99,8 @@ public class LiveVoiceRoomServiceImpl implements LiveVoiceRoomService { } @Override - public List listRoomCountry() { - return roomCountryListQryExe.execute(); + public List listRoomCountry(Long userId) { + return roomCountryListQryExe.execute(userId); } @Override diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomService.java index 06f4fab8..92025a8f 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/room/LiveVoiceRoomService.java @@ -40,7 +40,7 @@ public interface LiveVoiceRoomService { List explore(RoomExploreQryCmd cmd); - List listRoomCountry(); + List listRoomCountry(Long userId); String createPublicRoomByRegion(AppExtCommand cmd); }