Vue3.0高阶实战:开发高质量音乐Web app
V: ititit111222333
@ApiOperation(value = "根据一级分类最新商品六条数据", notes = "根据一级分类最新商品六条数据", httpMethod = "GET")
@GetMapping("/getNewSixItems/{root}")
public IMOOCJSONResult getNewSixItems(@ApiParam(name = "root", value = "一级分类id", required = true)
@PathVariable("root") Integer root) {
if (Objects.isNull(root)) {
return IMOOCJSONResult.errorMsg("一级分类id不能为空");
}
List<NewItemsVO> newSixItems;
String rootCategory = redisOperator.get("newSixItems");
if (StringUtils.isBlank(rootCategory)) {
newSixItems = categoryService.getNewSixItems(root);
redisOperator.set("firstCategory", JsonUtils.objectToJson(newSixItems));
} else {
newSixItems = JsonUtils.jsonToList(rootCategory, NewItemsVO.class);
}
return IMOOCJSONResult.ok(newSixItems);
}