🎨 产品模块接口调整
This commit is contained in:
parent
7d4d373277
commit
82fb5300bb
@ -58,5 +58,7 @@ public class Product implements Serializable, Cloneable {
|
|||||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date updatedTime;
|
private Date updatedTime;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
private String tags;
|
private String tags;
|
||||||
}
|
}
|
||||||
|
@ -17,26 +17,32 @@ public interface ProductMapper extends Mapper<Product> {
|
|||||||
/**
|
/**
|
||||||
* 保存产品详情
|
* 保存产品详情
|
||||||
*
|
*
|
||||||
* @param idProduct
|
* @param idProduct 产品主键
|
||||||
* @param productContent
|
* @param productContent 产品详情 markdown
|
||||||
* @param productContentHtml
|
* @param productContentHtml 产品详情 html
|
||||||
* @return
|
* @return 更新数量
|
||||||
*/
|
*/
|
||||||
Integer insertProductContent(@Param("idProduct") Integer idProduct, @Param("productContent") String productContent, @Param("productContentHtml") String productContentHtml);
|
Integer insertProductContent(@Param("idProduct") Integer idProduct, @Param("productContent") String productContent, @Param("productContentHtml") String productContentHtml);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询产品列表
|
* 查询产品列表
|
||||||
*
|
*
|
||||||
* @return
|
* @return 产品列表
|
||||||
*/
|
*/
|
||||||
List<ProductDTO> selectProducts();
|
List<ProductDTO> selectProducts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品详情
|
* 获取产品详情
|
||||||
*
|
*
|
||||||
* @param idProduct
|
* @param idProduct 产品 ID
|
||||||
* @param type
|
* @param type 获取类型
|
||||||
* @return
|
* @return 产品信息
|
||||||
*/
|
*/
|
||||||
ProductDTO selectProductDTOById(@Param("idProduct") Long idProduct, @Param("type") Integer type);
|
ProductDTO selectProductDTOById(@Param("idProduct") Long idProduct, @Param("type") Integer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在线产品
|
||||||
|
* @return 产品信息
|
||||||
|
*/
|
||||||
|
List<ProductDTO> selectOnlineProducts();
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,10 @@ public interface ProductService extends Service<Product> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ProductDTO findProductDTOById(Long idProduct, Integer type);
|
ProductDTO findProductDTOById(Long idProduct, Integer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在线商品
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProductDTO> findOnlineProducts();
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,9 @@ public class ProductServiceImpl extends AbstractService<Product> implements Prod
|
|||||||
public ProductDTO findProductDTOById(Long idProduct, Integer type) {
|
public ProductDTO findProductDTOById(Long idProduct, Integer type) {
|
||||||
return productMapper.selectProductDTOById(idProduct, type);
|
return productMapper.selectProductDTOById(idProduct, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProductDTO> findOnlineProducts() {
|
||||||
|
return productMapper.selectOnlineProducts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,14 +141,14 @@ public class CommonApiController {
|
|||||||
@GetMapping("/products")
|
@GetMapping("/products")
|
||||||
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ProductDTO> list = productService.findProducts();
|
List<ProductDTO> list = productService.findOnlineProducts();
|
||||||
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
|
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/product/{id}")
|
@GetMapping("/product/{id}")
|
||||||
@VisitLogger
|
@VisitLogger
|
||||||
public GlobalResult<ProductDTO> product(@PathVariable Integer id) {
|
public GlobalResult<ProductDTO> product(@PathVariable Long id) {
|
||||||
ProductDTO productDTO = productService.findProductDTOById(id, 1);
|
ProductDTO productDTO = productService.findProductDTOById(id, 1);
|
||||||
return GlobalResultGenerator.genSuccessResult(productDTO);
|
return GlobalResultGenerator.genSuccessResult(productDTO);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
<result column="product_description" property="productDescription"></result>
|
<result column="product_description" property="productDescription"></result>
|
||||||
<result column="product_price" property="productPrice"></result>
|
<result column="product_price" property="productPrice"></result>
|
||||||
<result column="product_content" property="productContent"></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>
|
<result column="tags" property="tags"></result>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<insert id="insertProductContent">
|
<insert id="insertProductContent">
|
||||||
@ -23,12 +25,12 @@
|
|||||||
sysdate())
|
sysdate())
|
||||||
</insert>
|
</insert>
|
||||||
<select id="selectProducts" resultMap="DTOResultMap">
|
<select id="selectProducts" resultMap="DTOResultMap">
|
||||||
select *
|
select id, product_title, product_img_url, tags, product_description, product_price, weights, status
|
||||||
from forest_product
|
from forest_product
|
||||||
order by weights
|
order by weights
|
||||||
</select>
|
</select>
|
||||||
<select id="selectProductDTOById" resultMap="DTOResultMap">
|
<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>
|
<choose>
|
||||||
<when test="type == 1">
|
<when test="type == 1">
|
||||||
product_content_html as product_content,
|
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
|
product_img_url from forest_product fp join forest_product_content fpc on fp.id = fpc.id_product
|
||||||
where id = #{idProduct}
|
where id = #{idProduct}
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user