From 2eb9a0c0f502326b7ad0e64afb44b3ba51a9f186 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Mon, 27 Aug 2018 21:50:12 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=88=B8=E8=AF=A6=E6=83=85][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9]:=E8=AE=A2=E5=8D=95=E4=B8=8B=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/controller/WxCouponController.java | 20 ++++++++++++++++--- .../simple/controller/WxOrderController.java | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java index 082651d95..e5da28f68 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponController.java @@ -4,6 +4,7 @@ import com.simple.common.ErrorCode; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponCVo; import io.swagger.annotations.Api; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; @@ -28,10 +29,23 @@ public class WxCouponController extends BaseController { @Autowired private WxCouponService wxCouponService; - @ApiOperation("根据id查询接口") + @ApiOperation("根据id(couponChannel)查询接口") @GetMapping("/detail") - public ResultData detail(@ModelAttribute WxCouponChannel wxCouponChannel) { - if(wxCouponChannel == null) wxCouponChannel = new WxCouponChannel(); + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) + public ResultData detail(String id) { + if (StringUtils.isBlank(id)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id为空"); + } + Long couponChannelId = 0L; + try { + couponChannelId = Long.valueOf(id); + } catch (NumberFormatException e) { + logger.error("id转换失败" + id); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id转换失败" + id); + } + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setId(couponChannelId); wxCouponChannel.setTenantId(getTenantId()); WxCouponCVo wxCouponCVo = wxCouponService.selectDetailForCUser(wxCouponChannel); if (wxCouponCVo == null) diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java b/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java index 05ee45d5e..49d2e59a7 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java @@ -113,6 +113,13 @@ public class WxOrderController extends BaseController { } if (StringUtils.isBlank(couponIdStr)) { couponId = wxCouponChannel.getCouponId(); + } else { + try { + couponId = Long.valueOf(couponIdStr); + } catch (NumberFormatException e) { + logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage()); + return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage()); + } } WxCUser user = getUser();