feat(theme): 新增主题详情查询接口
支持根据主题ID和用户ID查询主题详情,包含购买状态
This commit is contained in:
@@ -90,7 +90,8 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||||||
"/wallet/balance",
|
"/wallet/balance",
|
||||||
"/themes/purchase",
|
"/themes/purchase",
|
||||||
"/themes/purchased",
|
"/themes/purchased",
|
||||||
"/themes/purchase/list"
|
"/themes/purchase/list",
|
||||||
|
"/themes/detail"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -75,4 +75,12 @@ public class ThemesController {
|
|||||||
return ResultUtils.success(result);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,12 @@ public interface KeyboardThemesService extends IService<KeyboardThemes>{
|
|||||||
*/
|
*/
|
||||||
List<KeyboardThemesRespVO> selectThemesByStyle(Long themeStyle, Long userId);
|
List<KeyboardThemesRespVO> selectThemesByStyle(Long themeStyle, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询主题详情
|
||||||
|
* @param themeId 主题ID
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 主题详情
|
||||||
|
*/
|
||||||
|
KeyboardThemesRespVO getThemeDetail(Long themeId, Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,27 @@ public class KeyboardThemesServiceImpl extends ServiceImpl<KeyboardThemesMapper,
|
|||||||
return vo;
|
return vo;
|
||||||
}).collect(Collectors.toList());
|
}).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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user