From be6fed4d5dc633f91e4d4b3b3145aa556f71ac5e Mon Sep 17 00:00:00 2001 From: "jinguo24@163.com" Date: Fri, 10 Aug 2018 22:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=98=E6=83=A0=E5=8A=B5?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/controller/WxCouponController.java | 30 +++++++++++++++---- .../java/com/simple/domain/po/WxCoupon.java | 12 ++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java index e0802816c..7063fb2d8 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java @@ -1,26 +1,39 @@ package com.simple.controller; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; import com.simple.common.Result; import com.simple.common.ResultData; - import com.simple.domain.po.WxCoupon; +import com.simple.domain.po.WxMerchant; import com.simple.service.WxCouponService; +import com.simple.service.WxMerchantService; + +import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @RestController @RequestMapping("wxCoupon") +@Api(description="优惠券接口") public class WxCouponController extends BaseController { @Autowired private WxCouponService wxCouponService; + + @Autowired + private WxMerchantService wxMerchantService; private Logger logger = Logger.getLogger(WxCouponController.class); @@ -43,7 +56,11 @@ public class WxCouponController extends BaseController public ResultData add(@RequestBody WxCoupon wxCoupon) { //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxCouponService.saveOrUpdate(wxCoupon); + if(StringUtils.isNotBlank(wxCoupon.getBusiness())) { + String[] arys = wxCoupon.getBusiness().split(","); + wxCoupon.setBusiness(JSON.toJSONString(arys)); + } + wxCouponService.saveOrUpdate(wxCoupon); return new ResultData(); } @@ -66,7 +83,10 @@ public class WxCouponController extends BaseController @GetMapping("/findById") @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) public ResultData findById(Long id) { - return new ResultData(Result.SUCCESS,"查询成功",wxCouponService.getById(id)); + WxCoupon c = wxCouponService.getById(id); + WxMerchant merchant = wxMerchantService.getById(c.getMerchantId()); + c.setWxMerchant(merchant); + return new ResultData(Result.SUCCESS,"查询成功",c); } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java index cbe651cd7..b2b295daa 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCoupon.java @@ -119,6 +119,18 @@ public class WxCoupon implements Serializable { /*业态**/ @io.swagger.annotations.ApiModelProperty(value="业态",name="business") private String business; + + @Transient + private WxMerchant wxMerchant; + + public WxMerchant getWxMerchant() { + return wxMerchant; + } + + public void setWxMerchant(WxMerchant wxMerchant) { + this.wxMerchant = wxMerchant; + } + public String getTenantId() { return tenantId; }