一、业务层实现
1.创建接口定义方法:
productCommentsService :
public interface productCommentsService {
public ResultVO listCommentsByProductId(String productId);
}
2.创建实现类实现查询操作:
productCommentsServiceImpl :
@Service
public class productCommentsServiceImpl implements productCommentsService {
@Autowired
private ProductCommentsMapper productCommentsMapper;
public ResultVO listCommentsByProductId(String productId) {
List<ProductCommentsVO> productCommentsVOS = productCommentsMapper.selectCommontsByProductId(productId);
ResultVO resultVO = new ResultVO(ResStatus.OK, "success", productCommentsVOS);
return resultVO;
}
}
二、控制层实现
ProductController :
@RestController
@CrossOrigin
@RequestMapping("/product")
@Api(value = "提供商品信息相关的接口",tags = "商品管理")
public class ProductController {
@Autowired
private ProductService productService;
@Autowired
private ProductCommentsService productCommentsService;
@ApiOperation("商品基本信息查询接口")
@GetMapping("/detail-info/{pid}")
public ResultVO getProductBasicInfo(@PathVariable("pid") String pid){
return productService.getProductBasicInfo(pid);
}
@ApiOperation("商品参数信息查询接口")
@GetMapping("/detail-params/{pid}")
public ResultVO getProductParams(@PathVariable("pid") String pid){
return productService.getProductParamsById(pid);
}
@ApiOperation("商品评论信息查询接口")
@GetMapping("/detail-commonts/{pid}")
public ResultVO getProductCommonts(@PathVariable("pid") String pid){
return productCommentsService.listCommentsByProductId(pid);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/128103.html