Quellcode durchsuchen

商品分类回退

yuanliang vor 1 Jahr
Ursprung
Commit
3e34b34ffc

+ 13 - 1
mec-application/src/main/java/com/ym/mec/teacher/controller/GoodsController.java

@@ -1,5 +1,8 @@
 package com.ym.mec.teacher.controller;
 
+import com.ym.mec.biz.dal.entity.GoodsCategory;
+import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
+import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
@@ -11,6 +14,8 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Objects;
+
 @RequestMapping("${app-config.url.teacher:}/goods")
 @Api(tags = "商品(教材、辅件)服务")
 @RestController
@@ -18,11 +23,18 @@ public class GoodsController extends BaseController {
 
     @Autowired
     private GoodsService goodsService;
+    @Autowired
+    private GoodsCategoryService goodsCategoryService;
 
     @ApiOperation(value = "根据商品(教材、辅件)编号查询商品(教材、辅件)")
     @GetMapping("/get/{id}")
     public Object get(@ApiParam(value = "商品(教材、辅件)编号", required = true) @PathVariable("id") Integer id) {
-        return succeed(goodsService.getDetail(id));
+        GoodsWrapper.Goods goods = goodsService.getDetail(id);
+        GoodsCategory goodsCategory = goodsCategoryService.get(goods.getGoodsCategoryId());
+        if (Objects.nonNull(goodsCategory)) {
+            goods.setGoodsCategoryName(goodsCategory.getName());
+        }
+        return succeed(goods);
     }
 
 }