diff --git a/src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java b/src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java index ba21840..25b4c29 100644 --- a/src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java @@ -1,30 +1,30 @@ package cn.chjyj.szwh.controller.admin; -import cn.chjyj.szwh.annotation.PassToken; import cn.chjyj.szwh.bean.Goods; +import cn.chjyj.szwh.bean.GoodsDetail; +import cn.chjyj.szwh.controller.BaseController; +import cn.chjyj.szwh.exception.ChException; +import cn.chjyj.szwh.service.GoodsDetailService; import cn.chjyj.szwh.service.GoodsService; import com.alibaba.fastjson.JSONObject; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import java.util.List; -@Controller -@RequestMapping("/admin/admin.Goods") -public class AdminGoodsController { +@RestController +@RequestMapping(value = "/admin/admin.Goods",method = RequestMethod.POST) +public class AdminGoodsController extends BaseController { @Autowired private GoodsService goodsService; + @Autowired + private GoodsDetailService goodsDetailService; /** * 商品列表 * @return */ - @ResponseBody @RequestMapping("/list") public String list(@RequestParam(name = "page",defaultValue = "1") String page){ int ipage=Integer.parseInt(page); @@ -34,4 +34,25 @@ public class AdminGoodsController { jsonObject.put("data",goodsList); return jsonObject.toJSONString(); } + + /** + * 商品详情 + * @param islicode + * @return + */ + @RequestMapping("/goodsDetail") + public JSONObject goodsDetail(String islicode){ + // 商品明细id + Goods goods = goodsService.getGoodsByIsli(islicode); + if(goods!=null){ + GoodsDetail goodsDetail = goodsDetailService.getGoodsDetailBygid(goods.getGoodsDetailsId()); + + }else{ + throw new ChException("未查询到该标的"); + } + jsonObject.put("code",200); + jsonObject.put("msg","success"); + // jsonObject.put("data",goodsDetail); + return jsonObject; + } } diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsDetailService.java b/src/main/java/cn/chjyj/szwh/service/GoodsDetailService.java new file mode 100644 index 0000000..80b11d0 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/GoodsDetailService.java @@ -0,0 +1,15 @@ +package cn.chjyj.szwh.service; + +import cn.chjyj.szwh.bean.GoodsDetail; + +/** + * 商品详情 + */ +public interface GoodsDetailService { + /** + * 商品详情 + * @param goodDetailId + * @return + */ + GoodsDetail getGoodsDetailBygid(Integer goodDetailId); +} diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsService.java b/src/main/java/cn/chjyj/szwh/service/GoodsService.java index 4bf8f2e..12a6739 100644 --- a/src/main/java/cn/chjyj/szwh/service/GoodsService.java +++ b/src/main/java/cn/chjyj/szwh/service/GoodsService.java @@ -14,4 +14,11 @@ public interface GoodsService { * @return */ List getGoodsList(int page); + + /** + * 根据goodsIsli 查询商品信息 + * @param goodsIsli + * @return + */ + Goods getGoodsByIsli(String goodsIsli); } diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsDetailServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsDetailServiceImpl.java new file mode 100644 index 0000000..4e831d8 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsDetailServiceImpl.java @@ -0,0 +1,18 @@ +package cn.chjyj.szwh.service.impl; + +import cn.chjyj.szwh.bean.GoodsDetail; +import cn.chjyj.szwh.mapper.GoodsDetailMapper; +import cn.chjyj.szwh.service.GoodsDetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GoodsDetailServiceImpl implements GoodsDetailService { + @Autowired + private GoodsDetailMapper goodsDetailMapper; + + @Override + public GoodsDetail getGoodsDetailBygid(Integer goodDetailId) { + return goodsDetailMapper.getGoodsDetailBygid(goodDetailId); + } +} diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java index c9183d5..78c452d 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -21,4 +21,9 @@ public class GoodsServiceImpl implements GoodsService { //todo 字段转化啥的 return goodsList; } + + @Override + public Goods getGoodsByIsli(String goodsIsli) { + return goodsMapper.getGoodsByIsli(goodsIsli); + } } diff --git a/src/main/resources/mapper/szwh/GoodsDetailMapper.xml b/src/main/resources/mapper/szwh/GoodsDetailMapper.xml index 0bdeff3..751e7ea 100644 --- a/src/main/resources/mapper/szwh/GoodsDetailMapper.xml +++ b/src/main/resources/mapper/szwh/GoodsDetailMapper.xml @@ -27,7 +27,20 @@ diff --git a/src/main/resources/mapper/szwh/GoodsMapper.xml b/src/main/resources/mapper/szwh/GoodsMapper.xml index 0c50787..20ca898 100644 --- a/src/main/resources/mapper/szwh/GoodsMapper.xml +++ b/src/main/resources/mapper/szwh/GoodsMapper.xml @@ -41,11 +41,16 @@ diff --git a/src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java b/src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java index 0aa5c86..b87600b 100644 --- a/src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java +++ b/src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java @@ -29,6 +29,6 @@ public class GoodsMapperTest { public void goodslictest(){ String gc="010007-00000000002799999999-9"; Goods goods = goodsMapper.getGoodsByIsli(gc); - System.out.println(goods.getUsername()); + System.out.println(goods.toString()); } } \ No newline at end of file