diff --git a/src/main/java/com/rymcu/forest/mapper/ProductMapper.java b/src/main/java/com/rymcu/forest/mapper/ProductMapper.java index 4fb8757..173657a 100644 --- a/src/main/java/com/rymcu/forest/mapper/ProductMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/ProductMapper.java @@ -38,5 +38,5 @@ public interface ProductMapper extends Mapper { * @param type * @return */ - ProductDTO selectProductDTOById(@Param("idProduct") Integer idProduct, @Param("type") Integer type); + ProductDTO selectProductDTOById(@Param("idProduct") Long idProduct, @Param("type") Integer type); } diff --git a/src/main/java/com/rymcu/forest/service/ProductService.java b/src/main/java/com/rymcu/forest/service/ProductService.java index 3851c37..fa14811 100644 --- a/src/main/java/com/rymcu/forest/service/ProductService.java +++ b/src/main/java/com/rymcu/forest/service/ProductService.java @@ -28,5 +28,5 @@ public interface ProductService extends Service { * @param type * @return */ - ProductDTO findProductDTOById(Integer idProduct, Integer type); + ProductDTO findProductDTOById(Long idProduct, Integer type); } diff --git a/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java index b6ddaa6..35f53b5 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java @@ -29,7 +29,7 @@ public class ProductServiceImpl extends AbstractService implements Prod } @Override - public ProductDTO findProductDTOById(Integer idProduct, Integer type) { + public ProductDTO findProductDTOById(Long idProduct, Integer type) { return productMapper.selectProductDTOById(idProduct, type); } } diff --git a/src/main/java/com/rymcu/forest/web/api/product/ProductController.java b/src/main/java/com/rymcu/forest/web/api/product/ProductController.java index 6675a1f..c3229ae 100644 --- a/src/main/java/com/rymcu/forest/web/api/product/ProductController.java +++ b/src/main/java/com/rymcu/forest/web/api/product/ProductController.java @@ -1,8 +1,10 @@ package com.rymcu.forest.web.api.product; +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.dto.ProductDTO; import com.rymcu.forest.service.ProductService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -20,4 +22,12 @@ public class ProductController { @Resource private ProductService productService; + + + @GetMapping("/detail/{idProduct}") + public GlobalResult detail(@PathVariable Long idProduct, @RequestParam(defaultValue = "2") Integer type) { + ProductDTO dto = productService.findProductDTOById(idProduct, type); + return GlobalResultGenerator.genSuccessResult(dto); + } + }