From 82fb5300bb6f2e77c7575b0306aea2c216b8d5f2 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 28 Feb 2024 09:10:50 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BA=A7=E5=93=81=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/forest/entity/Product.java | 2 ++ .../rymcu/forest/mapper/ProductMapper.java | 22 ++++++++++++------- .../rymcu/forest/service/ProductService.java | 6 +++++ .../service/impl/ProductServiceImpl.java | 5 +++++ .../web/api/common/CommonApiController.java | 4 ++-- src/main/java/mapper/ProductMapper.xml | 12 ++++++++-- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/rymcu/forest/entity/Product.java b/src/main/java/com/rymcu/forest/entity/Product.java index 0686465..d6fcded 100644 --- a/src/main/java/com/rymcu/forest/entity/Product.java +++ b/src/main/java/com/rymcu/forest/entity/Product.java @@ -58,5 +58,7 @@ public class Product implements Serializable, Cloneable { @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date updatedTime; + private Integer status; + private String tags; } diff --git a/src/main/java/com/rymcu/forest/mapper/ProductMapper.java b/src/main/java/com/rymcu/forest/mapper/ProductMapper.java index 173657a..ef57bd0 100644 --- a/src/main/java/com/rymcu/forest/mapper/ProductMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/ProductMapper.java @@ -17,26 +17,32 @@ public interface ProductMapper extends Mapper { /** * 保存产品详情 * - * @param idProduct - * @param productContent - * @param productContentHtml - * @return + * @param idProduct 产品主键 + * @param productContent 产品详情 markdown + * @param productContentHtml 产品详情 html + * @return 更新数量 */ Integer insertProductContent(@Param("idProduct") Integer idProduct, @Param("productContent") String productContent, @Param("productContentHtml") String productContentHtml); /** * 查询产品列表 * - * @return + * @return 产品列表 */ List selectProducts(); /** * 获取产品详情 * - * @param idProduct - * @param type - * @return + * @param idProduct 产品 ID + * @param type 获取类型 + * @return 产品信息 */ ProductDTO selectProductDTOById(@Param("idProduct") Long idProduct, @Param("type") Integer type); + + /** + * 获取在线产品 + * @return 产品信息 + */ + List selectOnlineProducts(); } diff --git a/src/main/java/com/rymcu/forest/service/ProductService.java b/src/main/java/com/rymcu/forest/service/ProductService.java index fa14811..1cf4d47 100644 --- a/src/main/java/com/rymcu/forest/service/ProductService.java +++ b/src/main/java/com/rymcu/forest/service/ProductService.java @@ -29,4 +29,10 @@ public interface ProductService extends Service { * @return */ ProductDTO findProductDTOById(Long idProduct, Integer type); + + /** + * 获取在线商品 + * @return + */ + List findOnlineProducts(); } 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 35f53b5..64c8cf8 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java @@ -32,4 +32,9 @@ public class ProductServiceImpl extends AbstractService implements Prod public ProductDTO findProductDTOById(Long idProduct, Integer type) { return productMapper.selectProductDTOById(idProduct, type); } + + @Override + public List findOnlineProducts() { + return productMapper.selectOnlineProducts(); + } } diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 8d7c562..5a3bdd9 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -141,14 +141,14 @@ public class CommonApiController { @GetMapping("/products") public GlobalResult> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) { PageHelper.startPage(page, rows); - List list = productService.findProducts(); + List list = productService.findOnlineProducts(); PageInfo pageInfo = new PageInfo<>(list); return GlobalResultGenerator.genSuccessResult(pageInfo); } @GetMapping("/product/{id}") @VisitLogger - public GlobalResult product(@PathVariable Integer id) { + public GlobalResult product(@PathVariable Long id) { ProductDTO productDTO = productService.findProductDTOById(id, 1); return GlobalResultGenerator.genSuccessResult(productDTO); } diff --git a/src/main/java/mapper/ProductMapper.xml b/src/main/java/mapper/ProductMapper.xml index 3a8230f..2c07b6b 100644 --- a/src/main/java/mapper/ProductMapper.xml +++ b/src/main/java/mapper/ProductMapper.xml @@ -8,6 +8,8 @@ + + @@ -23,12 +25,12 @@ sysdate()) +