feat(theme): 新增主题详情查询接口

支持根据主题ID和用户ID查询主题详情,包含购买状态
This commit is contained in:
2025-12-11 13:32:05 +08:00
parent 77e8e9a2a7
commit 262c822585
4 changed files with 41 additions and 1 deletions

View File

@@ -90,7 +90,8 @@ public class SaTokenConfigure implements WebMvcConfigurer {
"/wallet/balance",
"/themes/purchase",
"/themes/purchased",
"/themes/purchase/list"
"/themes/purchase/list",
"/themes/detail"
};
}
@Bean

View File

@@ -75,4 +75,12 @@ public class ThemesController {
return ResultUtils.success(result);
}
@GetMapping("/detail")
@Operation(summary = "查询主题详情", description = "根据主题ID查询主题详情")
public BaseResponse<KeyboardThemesRespVO> getThemeDetail(@RequestParam Long themeId) {
Long userId = StpUtil.getLoginIdAsLong();
KeyboardThemesRespVO result = themesService.getThemeDetail(themeId, userId);
return ResultUtils.success(result);
}
}

View File

@@ -21,4 +21,12 @@ public interface KeyboardThemesService extends IService<KeyboardThemes>{
*/
List<KeyboardThemesRespVO> selectThemesByStyle(Long themeStyle, Long userId);
/**
* 查询主题详情
* @param themeId 主题ID
* @param userId 用户ID
* @return 主题详情
*/
KeyboardThemesRespVO getThemeDetail(Long themeId, Long userId);
}

View File

@@ -58,4 +58,27 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
return vo;
}).collect(Collectors.toList());
}
@Override
public KeyboardThemesRespVO getThemeDetail(Long themeId, Long userId) {
KeyboardThemes theme = this.lambdaQuery()
.eq(KeyboardThemes::getId, themeId)
.eq(KeyboardThemes::getDeleted, false)
.eq(KeyboardThemes::getThemeStatus, true)
.one();
if (theme == null) {
return null;
}
boolean isPurchased = purchaseService.lambdaQuery()
.eq(KeyboardThemePurchase::getUserId, userId)
.eq(KeyboardThemePurchase::getThemeId, themeId)
.eq(KeyboardThemePurchase::getPayStatus, (short) 1)
.exists();
KeyboardThemesRespVO vo = BeanUtil.copyProperties(theme, KeyboardThemesRespVO.class);
vo.setIsPurchased(isPurchased);
return vo;
}
}