docs(readme): 重写项目文档,更新技术栈与功能说明
feat(character): 新增人设详情接口并优化获取逻辑
This commit is contained in:
@@ -73,6 +73,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
"/character/listByUser",
|
||||
"/user/detail",
|
||||
"/user/register",
|
||||
"/user/updateInfo",
|
||||
"/character/updateUserCharacterSort",
|
||||
"/character/delUserCharacter",
|
||||
"/user/sendVerifyMail",
|
||||
|
||||
@@ -49,8 +49,7 @@ public class CharacterController {
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "人设详情", description = "人设详情接口")
|
||||
public BaseResponse<KeyboardCharacterRespVO> detail(@RequestParam("id") Long id) {
|
||||
KeyboardCharacter character = characterService.getById(id);
|
||||
return ResultUtils.success(BeanUtil.copyProperties(character, KeyboardCharacterRespVO.class));
|
||||
return ResultUtils.success(characterService.getDetailById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/listByTag")
|
||||
|
||||
@@ -35,4 +35,6 @@ public interface KeyboardCharacterService extends IService<KeyboardCharacter>{
|
||||
List<KeyboardCharacterRespVO> selectListByTagWithNotLogin(Long tagId);
|
||||
|
||||
void addDefaultUserCharacter(Long userId);
|
||||
|
||||
KeyboardCharacterRespVO getDetailById(Long id);
|
||||
}
|
||||
|
||||
@@ -288,4 +288,22 @@ public class KeyboardCharacterServiceImpl extends ServiceImpl<KeyboardCharacterM
|
||||
this.addUserCharacter(keyboardUserCharacterAddDTO, userId);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardCharacterRespVO getDetailById(Long id) {
|
||||
// 根据ID获取人设信息,优先从缓存获取
|
||||
KeyboardCharacter character = this.getById(id);
|
||||
// 将实体对象转换为响应对象
|
||||
KeyboardCharacterRespVO respVO = BeanUtil.copyProperties(character, KeyboardCharacterRespVO.class);
|
||||
// 判断当前用户是否已添加该人设
|
||||
long userId = StpUtil.getLoginIdAsLong();
|
||||
// 查询用户人设关联表,判断当前用户是否已添加该人设
|
||||
KeyboardUserCharacter userCharacter = keyboardUserCharacterMapper.selectOne(
|
||||
new LambdaQueryWrapper<KeyboardUserCharacter>()
|
||||
.eq(KeyboardUserCharacter::getCharacterId, id)
|
||||
.eq(KeyboardUserCharacter::getUserId, userId));
|
||||
// 设置是否已添加的标记
|
||||
respVO.setAdded(userCharacter != null);
|
||||
return respVO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user