[Claude Code] After prompt #0
This commit is contained in:
@@ -85,9 +85,9 @@ public class ThemesController {
|
|||||||
|
|
||||||
@GetMapping("/recommended")
|
@GetMapping("/recommended")
|
||||||
@Operation(summary = "推荐主题列表", description = "按真实下载数量降序返回推荐主题")
|
@Operation(summary = "推荐主题列表", description = "按真实下载数量降序返回推荐主题")
|
||||||
public BaseResponse<List<KeyboardThemesRespVO>> getRecommendedThemes() {
|
public BaseResponse<List<KeyboardThemesRespVO>> getRecommendedThemes(@RequestParam Long themeId) {
|
||||||
Long userId = StpUtil.getLoginIdAsLong();
|
Long userId = StpUtil.getLoginIdAsLong();
|
||||||
List<KeyboardThemesRespVO> result = themesService.getRecommendedThemes(userId);
|
List<KeyboardThemesRespVO> result = themesService.getRecommendedThemes(userId, themeId);
|
||||||
return ResultUtils.success(result);
|
return ResultUtils.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface KeyboardThemesService extends IService<KeyboardThemes>{
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 推荐主题列表
|
* @return 推荐主题列表
|
||||||
*/
|
*/
|
||||||
List<KeyboardThemesRespVO> getRecommendedThemes(Long userId);
|
List<KeyboardThemesRespVO> getRecommendedThemes(Long userId,Long themeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主题名称模糊搜索主题
|
* 根据主题名称模糊搜索主题
|
||||||
|
|||||||
@@ -118,12 +118,13 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
|
|||||||
@Override
|
@Override
|
||||||
/*
|
/*
|
||||||
获取推荐主题列表
|
获取推荐主题列表
|
||||||
<p>推荐规则:根据真实下载量降序排序,排除用户已购买的主题,最多返回8个主题</p>
|
<p>推荐规则:根据真实下载量降序排序,排除用户已购买的主题和当前查看的主题,最多返回8个主题</p>
|
||||||
|
|
||||||
@param userId 用户ID
|
@param userId 用户ID
|
||||||
|
@param themeId 当前主题ID,需要从推荐列表中排除
|
||||||
* @return 推荐主题列表,包含主题详情和购买状态(推荐列表中的主题购买状态均为未购买)
|
* @return 推荐主题列表,包含主题详情和购买状态(推荐列表中的主题购买状态均为未购买)
|
||||||
*/
|
*/
|
||||||
public List<KeyboardThemesRespVO> getRecommendedThemes(Long userId) {
|
public List<KeyboardThemesRespVO> getRecommendedThemes(Long userId, Long themeId) {
|
||||||
// 查询用户已购买的主题ID集合
|
// 查询用户已购买的主题ID集合
|
||||||
Set<Long> purchasedThemeIds = purchaseService.lambdaQuery()
|
Set<Long> purchasedThemeIds = purchaseService.lambdaQuery()
|
||||||
.eq(KeyboardThemePurchase::getUserId, userId)
|
.eq(KeyboardThemePurchase::getUserId, userId)
|
||||||
@@ -139,6 +140,11 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
|
|||||||
.eq(KeyboardThemes::getThemeStatus, true)
|
.eq(KeyboardThemes::getThemeStatus, true)
|
||||||
.orderByDesc(KeyboardThemes::getRealDownloadCount);
|
.orderByDesc(KeyboardThemes::getRealDownloadCount);
|
||||||
|
|
||||||
|
// 排除传入的当前主题ID
|
||||||
|
if (themeId != null) {
|
||||||
|
queryWrapper.ne(KeyboardThemes::getId, themeId);
|
||||||
|
}
|
||||||
|
|
||||||
// 如果有已购买的主题,排除它们
|
// 如果有已购买的主题,排除它们
|
||||||
if (!purchasedThemeIds.isEmpty()) {
|
if (!purchasedThemeIds.isEmpty()) {
|
||||||
queryWrapper.notIn(KeyboardThemes::getId, purchasedThemeIds);
|
queryWrapper.notIn(KeyboardThemes::getId, purchasedThemeIds);
|
||||||
|
|||||||
Reference in New Issue
Block a user