[Claude Code] After prompt #0

This commit is contained in:
2025-12-23 13:53:53 +08:00
parent 619c59d786
commit 2b0fa71c40
3 changed files with 11 additions and 5 deletions

View File

@@ -85,9 +85,9 @@ public class ThemesController {
@GetMapping("/recommended")
@Operation(summary = "推荐主题列表", description = "按真实下载数量降序返回推荐主题")
public BaseResponse<List<KeyboardThemesRespVO>> getRecommendedThemes() {
public BaseResponse<List<KeyboardThemesRespVO>> getRecommendedThemes(@RequestParam Long themeId) {
Long userId = StpUtil.getLoginIdAsLong();
List<KeyboardThemesRespVO> result = themesService.getRecommendedThemes(userId);
List<KeyboardThemesRespVO> result = themesService.getRecommendedThemes(userId, themeId);
return ResultUtils.success(result);
}

View File

@@ -34,7 +34,7 @@ public interface KeyboardThemesService extends IService<KeyboardThemes>{
* @param userId 用户ID
* @return 推荐主题列表
*/
List<KeyboardThemesRespVO> getRecommendedThemes(Long userId);
List<KeyboardThemesRespVO> getRecommendedThemes(Long userId,Long themeId);
/**
* 根据主题名称模糊搜索主题

View File

@@ -118,12 +118,13 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
@Override
/*
获取推荐主题列表
<p>推荐规则根据真实下载量降序排序排除用户已购买的主题最多返回8个主题</p>
<p>推荐规则:根据真实下载量降序排序,排除用户已购买的主题和当前查看的主题最多返回8个主题</p>
@param userId 用户ID
@param themeId 当前主题ID需要从推荐列表中排除
* @return 推荐主题列表,包含主题详情和购买状态(推荐列表中的主题购买状态均为未购买)
*/
public List<KeyboardThemesRespVO> getRecommendedThemes(Long userId) {
public List<KeyboardThemesRespVO> getRecommendedThemes(Long userId, Long themeId) {
// 查询用户已购买的主题ID集合
Set<Long> purchasedThemeIds = purchaseService.lambdaQuery()
.eq(KeyboardThemePurchase::getUserId, userId)
@@ -139,6 +140,11 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
.eq(KeyboardThemes::getThemeStatus, true)
.orderByDesc(KeyboardThemes::getRealDownloadCount);
// 排除传入的当前主题ID
if (themeId != null) {
queryWrapper.ne(KeyboardThemes::getId, themeId);
}
// 如果有已购买的主题,排除它们
if (!purchasedThemeIds.isEmpty()) {
queryWrapper.notIn(KeyboardThemes::getId, purchasedThemeIds);