国家列表排序更改
(cherry picked from commit 3d52e519415915d97b1472c075eeed736ab38660)
This commit is contained in:
parent
4d4640a105
commit
8c2b965e6d
@ -182,8 +182,8 @@ public class LiveVoiceRoomRestController extends BaseController {
|
|||||||
* @eo.request-type formdata
|
* @eo.request-type formdata
|
||||||
*/
|
*/
|
||||||
@GetMapping("/country")
|
@GetMapping("/country")
|
||||||
public List<CountryCO> listCountry() {
|
public List<CountryCO> listCountry(AppExtCommand cmd) {
|
||||||
return liveVoiceRoomService.listRoomCountry();
|
return liveVoiceRoomService.listRoomCountry(cmd.requiredReqUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
package com.red.circle.other.app.command.room.query;
|
package com.red.circle.other.app.command.room.query;
|
||||||
|
|
||||||
import com.red.circle.other.app.dto.clientobject.room.CountryCO;
|
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.entity.sys.SysCountryCode;
|
||||||
import com.red.circle.other.infra.database.rds.service.sys.SysCountryCodeService;
|
import com.red.circle.other.infra.database.rds.service.sys.SysCountryCodeService;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -18,10 +23,43 @@ import org.springframework.stereotype.Component;
|
|||||||
public class RoomCountryListQryExe {
|
public class RoomCountryListQryExe {
|
||||||
|
|
||||||
private final SysCountryCodeService sysCountryCodeService;
|
private final SysCountryCodeService sysCountryCodeService;
|
||||||
|
private final UserRegionGateway userRegionGateway;
|
||||||
|
private final UserProfileGateway userProfileGateway;
|
||||||
|
|
||||||
public List<CountryCO> execute() {
|
public List<CountryCO> execute(Long userId) {
|
||||||
List<SysCountryCode> countries = sysCountryCodeService.listOpenCountry();
|
List<SysCountryCode> all = sysCountryCodeService.listOpenCountry();
|
||||||
return countries.stream().map(this::toCountryCO).toList();
|
|
||||||
|
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) {
|
private CountryCO toCountryCO(SysCountryCode entity) {
|
||||||
|
|||||||
@ -99,8 +99,8 @@ public class LiveVoiceRoomServiceImpl implements LiveVoiceRoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CountryCO> listRoomCountry() {
|
public List<CountryCO> listRoomCountry(Long userId) {
|
||||||
return roomCountryListQryExe.execute();
|
return roomCountryListQryExe.execute(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public interface LiveVoiceRoomService {
|
|||||||
|
|
||||||
List<RoomVoiceProfileCO> explore(RoomExploreQryCmd cmd);
|
List<RoomVoiceProfileCO> explore(RoomExploreQryCmd cmd);
|
||||||
|
|
||||||
List<CountryCO> listRoomCountry();
|
List<CountryCO> listRoomCountry(Long userId);
|
||||||
|
|
||||||
String createPublicRoomByRegion(AppExtCommand cmd);
|
String createPublicRoomByRegion(AppExtCommand cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user