|
|
@@ -53,7 +53,7 @@ public class MetaPlayerInfoService {
|
|
|
}
|
|
|
SpaceObjectsInfo dbSpaceObjectsInfo = spaceObjectsInfoRepo.findById(spaceObjectsInfo.getId()).orElse(null);
|
|
|
if(Objects.isNull(dbSpaceObjectsInfo)) {
|
|
|
- return MetaRestResult.returnError(String.format("不存在id[%S]的空间物品数据", spaceObjectsInfo.getSpaceId()));
|
|
|
+ return MetaRestResult.returnError(String.format("操作失败:不存在id[%S]的空间物品数据", spaceObjectsInfo.getSpaceId()));
|
|
|
}
|
|
|
List<BuildingPosDTO> buildingPosList = spaceObjectsInfo.getBuildingPosList();
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
@@ -66,12 +66,15 @@ public class MetaPlayerInfoService {
|
|
|
}
|
|
|
});
|
|
|
List<BuildingDTO> buildingDTOS = buildingList(dbSpaceObjectsInfo.getUserId());
|
|
|
+ Set<String> keys = map.keySet();
|
|
|
// 比较个人空间拥有的各物品最大数量
|
|
|
try {
|
|
|
- buildingDTOS.forEach(buildingDTO -> {
|
|
|
- if (map.containsKey(String.valueOf(buildingDTO.getItmeId())) && map.get(String.valueOf(buildingDTO.getItmeId())) > buildingDTO.getCount()) {
|
|
|
- throw new BusinessException(String.format("当前用户[%S]拥有物品[%S]最大数量为[%S]", dbSpaceObjectsInfo.getUserId(), buildingDTO.getItmeId(), buildingDTO.getCount()));
|
|
|
- }
|
|
|
+ keys.forEach(key -> {
|
|
|
+ buildingDTOS.forEach(buildingDTO -> {
|
|
|
+ if (!key.equals(String.valueOf(buildingDTO.getItmeId())) || map.get(key) > buildingDTO.getCount()) {
|
|
|
+ throw new BusinessException("操作失败:当前用户修改该物品数量大于用户持有最大数量");
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
} catch (Exception e) {
|
|
|
return MetaRestResult.returnError(e.getMessage());
|