diff --git a/src/main/java/com/yingjun/ssm/service/GoodsService.java b/src/main/java/com/yingjun/ssm/service/GoodsService.java index 6dc18949a1ab95793abcb433f366707820a1916b..1b285a61425fa248d31a87e9cb9ae1761d138140 100644 --- a/src/main/java/com/yingjun/ssm/service/GoodsService.java +++ b/src/main/java/com/yingjun/ssm/service/GoodsService.java @@ -1,11 +1,9 @@ package com.yingjun.ssm.service; -import java.util.List; - -import org.springframework.cache.annotation.Cacheable; - import com.yingjun.ssm.entity.Goods; +import java.util.List; + public interface GoodsService { /** @@ -20,7 +18,7 @@ public interface GoodsService { /** * 商品购买 * - * @param userId + * @param userPhone * @param goodsId * @param useProcedure * 是否用存储过程提高并发能力 diff --git a/src/main/java/com/yingjun/ssm/web/GoodsController.java b/src/main/java/com/yingjun/ssm/web/GoodsController.java index dd4af10ccaa9bee683a909c8fbde801d454a91ce..df3ea7f4a5528f54bfc7fb1ba1159c7cc6d0c241 100644 --- a/src/main/java/com/yingjun/ssm/web/GoodsController.java +++ b/src/main/java/com/yingjun/ssm/web/GoodsController.java @@ -1,22 +1,18 @@ package com.yingjun.ssm.web; -import java.util.List; - +import com.yingjun.ssm.dto.BaseResult; +import com.yingjun.ssm.entity.Goods; +import com.yingjun.ssm.enums.ResultEnum; +import com.yingjun.ssm.exception.BizException; +import com.yingjun.ssm.service.GoodsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; -import com.yingjun.ssm.dto.BaseResult; -import com.yingjun.ssm.entity.Goods; -import com.yingjun.ssm.enums.ResultEnum; -import com.yingjun.ssm.service.GoodsService; +import java.util.List; @Controller @RequestMapping("/goods") @@ -43,15 +39,15 @@ public class GoodsController { @PathVariable("goodsId") Long goodsId){ LOG.info("invoke----------/"+goodsId+"/buy userPhone:"+userPhone); if (userPhone == null||goodsId==null) { - return new BaseResult(false, ResultEnum.PARAM_USER.getMsg()); + return new BaseResult(false, ResultEnum.INVALID_USER.getMsg()); } try { goodsService.buyGoods(userPhone, goodsId, false); - }catch (MyException e1) { - return new BaseResult(false, e1.getMessage()); + }catch (BizException e) { + return new BaseResult(false, e.getMessage()); }catch (Exception e) { return new BaseResult(false, ResultEnum.INNER_ERROR.getMsg()); } - return new BaseResult(true, "success"); + return new BaseResult(true, null); } }