国家列表排序更改

(cherry picked from commit 3d52e519415915d97b1472c075eeed736ab38660)
This commit is contained in:
tianfeng 2026-04-23 19:05:45 +08:00
parent 4d4640a105
commit 8c2b965e6d
4 changed files with 46 additions and 8 deletions

View File

@ -182,8 +182,8 @@ public class LiveVoiceRoomRestController extends BaseController {
* @eo.request-type formdata
*/
@GetMapping("/country")
public List<CountryCO> listCountry() {
return liveVoiceRoomService.listRoomCountry();
public List<CountryCO> listCountry(AppExtCommand cmd) {
return liveVoiceRoomService.listRoomCountry(cmd.requiredReqUserId());
}
}

View File

@ -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<CountryCO> execute() {
List<SysCountryCode> countries = sysCountryCodeService.listOpenCountry();
return countries.stream().map(this::toCountryCO).toList();
public List<CountryCO> execute(Long userId) {
List<SysCountryCode> 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<CountryCO> current = new ArrayList<>();
List<CountryCO> arList = new ArrayList<>();
List<CountryCO> 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<CountryCO> 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) {

View File

@ -99,8 +99,8 @@ public class LiveVoiceRoomServiceImpl implements LiveVoiceRoomService {
}
@Override
public List<CountryCO> listRoomCountry() {
return roomCountryListQryExe.execute();
public List<CountryCO> listRoomCountry(Long userId) {
return roomCountryListQryExe.execute(userId);
}
@Override

View File

@ -40,7 +40,7 @@ public interface LiveVoiceRoomService {
List<RoomVoiceProfileCO> explore(RoomExploreQryCmd cmd);
List<CountryCO> listRoomCountry();
List<CountryCO> listRoomCountry(Long userId);
String createPublicRoomByRegion(AppExtCommand cmd);
}