CouponController
/**
* 根据id查询优惠券--管理端
*/
@ApiOperation("根据id查询优惠券--管理端")
@GetMapping("/{id}")
public CouponPageVO queryCouponById(@PathVariable("id") Long id) {
return couponService.queryCouponById(id);
}
ICouponService
/**
* 根据id查询优惠券--管理端
* @param id
* @return
*/
CouponPageVO queryCouponById(Long id);
CouponServiceImpl
/**
* 根据id查询优惠券--管理端
* @param id
* @return
*/
@Override
public CouponPageVO queryCouponById(Long id) {
//1、校验
if (id == null){
throw new BadRequestException("非法参数!");
}
//2、查询优惠券表
Coupon coupon = this.getById(id);
if (coupon == null) {
throw new BadRequestException("优惠券不存在!");
}
//3、封装vo,返回结果
CouponPageVO vo = BeanUtils.copyBean(coupon, CouponPageVO.class);
return vo;
}