feat(新增-商品管理): 删除商品
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
2b921ce7fd
commit
315659d1f7
|
@ -58,4 +58,11 @@ public class ProductController {
|
|||
productService.updateById(product);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除商品", description = "删除商品")
|
||||
@DeleteMapping("/deleteById/{id}")
|
||||
public Result<Long> deleteById(@Parameter(name = "id", description = "商品id", required = true) @PathVariable Long id) {
|
||||
productService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -26,4 +26,11 @@ public interface ProductDetailsMapper {
|
|||
* @param productDetails ProductDetails
|
||||
*/
|
||||
void updateById(ProductDetails productDetails);
|
||||
|
||||
/**
|
||||
* 根据商品的id删除商品的详情数据
|
||||
*
|
||||
* @param id 删除ID
|
||||
*/
|
||||
void deleteByProductId(Long id);
|
||||
}
|
||||
|
|
|
@ -37,4 +37,11 @@ public interface ProductMapper {
|
|||
* @param product 商品实体类
|
||||
*/
|
||||
void updateById(Product product);
|
||||
|
||||
/**
|
||||
* 根据id删除商品基本数据
|
||||
*
|
||||
* @param id 删除ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
}
|
||||
|
|
|
@ -28,4 +28,11 @@ public interface ProductSkuMapper {
|
|||
* @param productSku 商品实体类
|
||||
*/
|
||||
void updateById(ProductSku productSku);
|
||||
|
||||
/**
|
||||
* 根据商品id删除商品的sku数据
|
||||
*
|
||||
* @param id 删除ID
|
||||
*/
|
||||
void deleteByProductId(Long id);
|
||||
}
|
||||
|
|
|
@ -36,4 +36,11 @@ public interface ProductService {
|
|||
* @param product 商品实体类
|
||||
*/
|
||||
void updateById(Product product);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param id 删除ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
}
|
||||
|
|
|
@ -122,4 +122,16 @@ public class ProductServiceImpl implements ProductService {
|
|||
productDetails.setImageUrls(product.getDetailsImageUrls());
|
||||
productDetailsMapper.updateById(productDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param id 删除ID
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
productMapper.deleteById(id); // 根据id删除商品基本数据
|
||||
productSkuMapper.deleteByProductId(id); // 根据商品id删除商品的sku数据
|
||||
productDetailsMapper.deleteByProductId(id); // 根据商品的id删除商品的详情数据
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 根据商品的id删除商品的详情数据 -->
|
||||
<update id="deleteByProductId">
|
||||
update product_details
|
||||
set update_time = now(),
|
||||
is_deleted = 1
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<select id="selectByProductId" resultType="com.atguigu.spzx.model.entity.product.ProductDetails">
|
||||
select
|
||||
<include refid="columns"/>
|
||||
|
|
|
@ -55,6 +55,14 @@
|
|||
id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 根据id删除商品基本数据 -->
|
||||
<update id="deleteById">
|
||||
update product
|
||||
set update_time = now(),
|
||||
is_deleted = 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 列表查询 -->
|
||||
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Product">
|
||||
select
|
||||
|
|
|
@ -59,6 +59,14 @@
|
|||
id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 根据商品id删除商品的sku数据 -->
|
||||
<update id="deleteByProductId">
|
||||
update product_sku
|
||||
set update_time = now(),
|
||||
is_deleted = 1
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<!-- 根据商品的id查询sku数据 -->
|
||||
<select id="selectByProductId" resultType="com.atguigu.spzx.model.entity.product.ProductSku">
|
||||
select
|
||||
|
|
Loading…
Reference in New Issue