提交 dac8d4c4 编写于 作者: Y yingjun

代码完善

上级 412845c9
package com.yingjun.ssm.service; package com.yingjun.ssm.service;
import java.util.List;
import org.springframework.cache.annotation.Cacheable;
import com.yingjun.ssm.entity.Goods; import com.yingjun.ssm.entity.Goods;
import java.util.List;
public interface GoodsService { public interface GoodsService {
/** /**
...@@ -20,7 +18,7 @@ public interface GoodsService { ...@@ -20,7 +18,7 @@ public interface GoodsService {
/** /**
* 商品购买 * 商品购买
* *
* @param userId * @param userPhone
* @param goodsId * @param goodsId
* @param useProcedure * @param useProcedure
* 是否用存储过程提高并发能力 * 是否用存储过程提高并发能力
......
package com.yingjun.ssm.web; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.*;
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 com.yingjun.ssm.dto.BaseResult; import java.util.List;
import com.yingjun.ssm.entity.Goods;
import com.yingjun.ssm.enums.ResultEnum;
import com.yingjun.ssm.service.GoodsService;
@Controller @Controller
@RequestMapping("/goods") @RequestMapping("/goods")
...@@ -43,15 +39,15 @@ public class GoodsController { ...@@ -43,15 +39,15 @@ public class GoodsController {
@PathVariable("goodsId") Long goodsId){ @PathVariable("goodsId") Long goodsId){
LOG.info("invoke----------/"+goodsId+"/buy userPhone:"+userPhone); LOG.info("invoke----------/"+goodsId+"/buy userPhone:"+userPhone);
if (userPhone == null||goodsId==null) { if (userPhone == null||goodsId==null) {
return new BaseResult<Object>(false, ResultEnum.PARAM_USER.getMsg()); return new BaseResult<Object>(false, ResultEnum.INVALID_USER.getMsg());
} }
try { try {
goodsService.buyGoods(userPhone, goodsId, false); goodsService.buyGoods(userPhone, goodsId, false);
}catch (MyException e1) { }catch (BizException e) {
return new BaseResult<Object>(false, e1.getMessage()); return new BaseResult<Object>(false, e.getMessage());
}catch (Exception e) { }catch (Exception e) {
return new BaseResult<Object>(false, ResultEnum.INNER_ERROR.getMsg()); return new BaseResult<Object>(false, ResultEnum.INNER_ERROR.getMsg());
} }
return new BaseResult<Object>(true, "success"); return new BaseResult<Object>(true, null);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册