一 后端接口
判断数据库中是否存在已支付订单
1 Controller
ApiOrderController
/**
* 功能描述:判断课程是否购买
*
* @param courseId 课时id
* @param request http请求
* @return R 返回给前端的数据
* @author cakin
* @date 2021/1/3
*/
@ApiOperation("判断课程是否购买")
@GetMapping("auth/is-buy/{courseId}")
public R isBuyByCourseId(@PathVariable String courseId, HttpServletRequest request) {
JwtInfo jwtInfo = JwtUtils.getMemberIdByJwtToken(request);
Boolean isBuy = orderService.isBuyByCourseId(courseId, jwtInfo.getId());
return R.ok().data("isBuy", isBuy);
}
2 Service
接口
/**
* 功能描述:判断课程是否购买
*
* @author cakin
* @date 2021/1/3
* @param courseId 课程Id
* @param memberId 会员id
* @return Boolean 课程是否购买
*/
Boolean isBuyByCourseId(String courseId, String memberId);
实现