🎨 产品模块接口调整

This commit is contained in:
ronger 2024-02-28 09:10:50 +08:00
parent 7d4d373277
commit 82fb5300bb
6 changed files with 39 additions and 12 deletions

View File

@ -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;
}

View File

@ -17,26 +17,32 @@ public interface ProductMapper extends Mapper<Product> {
/**
* 保存产品详情
*
* @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<ProductDTO> selectProducts();
/**
* 获取产品详情
*
* @param idProduct
* @param type
* @return
* @param idProduct 产品 ID
* @param type 获取类型
* @return 产品信息
*/
ProductDTO selectProductDTOById(@Param("idProduct") Long idProduct, @Param("type") Integer type);
/**
* 获取在线产品
* @return 产品信息
*/
List<ProductDTO> selectOnlineProducts();
}

View File

@ -29,4 +29,10 @@ public interface ProductService extends Service<Product> {
* @return
*/
ProductDTO findProductDTOById(Long idProduct, Integer type);
/**
* 获取在线商品
* @return
*/
List<ProductDTO> findOnlineProducts();
}

View File

@ -32,4 +32,9 @@ public class ProductServiceImpl extends AbstractService<Product> implements Prod
public ProductDTO findProductDTOById(Long idProduct, Integer type) {
return productMapper.selectProductDTOById(idProduct, type);
}
@Override
public List<ProductDTO> findOnlineProducts() {
return productMapper.selectOnlineProducts();
}
}

View File

@ -141,14 +141,14 @@ public class CommonApiController {
@GetMapping("/products")
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
PageHelper.startPage(page, rows);
List<ProductDTO> list = productService.findProducts();
List<ProductDTO> list = productService.findOnlineProducts();
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
return GlobalResultGenerator.genSuccessResult(pageInfo);
}
@GetMapping("/product/{id}")
@VisitLogger
public GlobalResult<ProductDTO> product(@PathVariable Integer id) {
public GlobalResult<ProductDTO> product(@PathVariable Long id) {
ProductDTO productDTO = productService.findProductDTOById(id, 1);
return GlobalResultGenerator.genSuccessResult(productDTO);
}

View File

@ -8,6 +8,8 @@
<result column="product_description" property="productDescription"></result>
<result column="product_price" property="productPrice"></result>
<result column="product_content" property="productContent"></result>
<result column="created_time" property="createdTime"></result>
<result column="status" property="status"></result>
<result column="tags" property="tags"></result>
</resultMap>
<insert id="insertProductContent">
@ -23,12 +25,12 @@
sysdate())
</insert>
<select id="selectProducts" resultMap="DTOResultMap">
select *
select id, product_title, product_img_url, tags, product_description, product_price, weights, status
from forest_product
order by weights
</select>
<select id="selectProductDTOById" resultMap="DTOResultMap">
select id, product_title, tags,
select id, product_title, product_img_url, tags, product_description, product_price, weights, status,
<choose>
<when test="type == 1">
product_content_html as product_content,
@ -40,4 +42,10 @@
product_img_url from forest_product fp join forest_product_content fpc on fp.id = fpc.id_product
where id = #{idProduct}
</select>
<select id="selectOnlineProducts" resultMap="DTOResultMap">
select id, product_title, product_img_url, product_description, product_price
from forest_product
where status = 1
order by weights
</select>
</mapper>