fix(character): 修复用户人设关联字段映射错误
将 KeyboardUserCharacterVO 新增 characterId 字段, 并把 ServiceImpl 中两处 getId() 比对改为 getCharacterId(), 确保用户是否已添加的判断逻辑正确。
This commit is contained in:
@@ -23,7 +23,6 @@ public class KeyboardCharacterRespVO {
|
|||||||
@Schema(description="标题")
|
@Schema(description="标题")
|
||||||
private String characterName;
|
private String characterName;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description="背景描述")
|
@Schema(description="背景描述")
|
||||||
private String characterBackground;
|
private String characterBackground;
|
||||||
|
|
||||||
|
|||||||
@@ -29,5 +29,7 @@ public class KeyboardUserCharacterVO {
|
|||||||
@Schema(description = "emoji")
|
@Schema(description = "emoji")
|
||||||
private String emoji;
|
private String emoji;
|
||||||
|
|
||||||
|
@Schema(description = "角色 Id")
|
||||||
|
private Long characterId;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,10 +52,12 @@ public class KeyboardCharacterServiceImpl extends ServiceImpl<KeyboardCharacterM
|
|||||||
.orderByAsc(KeyboardCharacter::getRank));
|
.orderByAsc(KeyboardCharacter::getRank));
|
||||||
|
|
||||||
List<KeyboardUserCharacterVO> userCharacterVOList = keyboardUserCharacterMapper.selectByUserId(userId);
|
List<KeyboardUserCharacterVO> userCharacterVOList = keyboardUserCharacterMapper.selectByUserId(userId);
|
||||||
|
|
||||||
List<KeyboardCharacterRespVO> keyboardCharacterRespVOS = BeanUtil.copyToList(keyboardCharacters, KeyboardCharacterRespVO.class);
|
List<KeyboardCharacterRespVO> keyboardCharacterRespVOS = BeanUtil.copyToList(keyboardCharacters, KeyboardCharacterRespVO.class);
|
||||||
|
|
||||||
keyboardCharacterRespVOS.forEach(character -> {
|
keyboardCharacterRespVOS.forEach(character -> {
|
||||||
character.setAdded(userCharacterVOList.stream().anyMatch(userCharacter ->
|
character.setAdded(userCharacterVOList.stream().anyMatch(userCharacter ->
|
||||||
userCharacter.getId().equals(character.getId())));
|
userCharacter.getCharacterId().equals(character.getId())));
|
||||||
});
|
});
|
||||||
return keyboardCharacterRespVOS;
|
return keyboardCharacterRespVOS;
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ public class KeyboardCharacterServiceImpl extends ServiceImpl<KeyboardCharacterM
|
|||||||
List<KeyboardCharacterRespVO> keyboardCharacterRespVOS = BeanUtil.copyToList(keyboardCharacters, KeyboardCharacterRespVO.class);
|
List<KeyboardCharacterRespVO> keyboardCharacterRespVOS = BeanUtil.copyToList(keyboardCharacters, KeyboardCharacterRespVO.class);
|
||||||
keyboardCharacterRespVOS.forEach(character -> {
|
keyboardCharacterRespVOS.forEach(character -> {
|
||||||
character.setAdded(userCharacterVOList.stream().anyMatch(userCharacter ->
|
character.setAdded(userCharacterVOList.stream().anyMatch(userCharacter ->
|
||||||
userCharacter.getId().equals(character.getId())));
|
userCharacter.getCharacterId().equals(character.getId())));
|
||||||
});
|
});
|
||||||
return keyboardCharacterRespVOS;
|
return keyboardCharacterRespVOS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user