feat(新增-商品规格管理): 删除功能

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-26 14:38:47 +08:00
parent 605647283a
commit 27105b3220
5 changed files with 43 additions and 0 deletions

View File

@ -35,4 +35,11 @@ public class ProductSpecController {
productSpecService.updateById(productSpec);
return Result.success();
}
@Operation(summary = "删除功能", description = "删除功能")
@DeleteMapping("deleteById/{id}")
public Result<Long> removeById(@PathVariable Long id) {
productSpecService.deleteById(id);
return Result.success();
}
}

View File

@ -27,4 +27,11 @@ public interface ProductSpecMapper {
* @param productSpec 商品规格实体类
*/
void updateById(ProductSpec productSpec);
/**
* 删除功能
*
* @param id 要删除的ID
*/
void deleteById(Long id);
}

View File

@ -26,4 +26,11 @@ public interface ProductSpecService {
* @param productSpec 商品规格实体类
*/
void updateById(ProductSpec productSpec);
/**
* 删除功能
*
* @param id 要删除的ID
*/
void deleteById(Long id);
}

View File

@ -5,6 +5,7 @@ import com.atguigu.exception.BunnyException;
import com.atguigu.spzx.manger.mapper.ProductSpecMapper;
import com.atguigu.spzx.manger.service.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.atguigu.utils.StringEmptyUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -17,6 +18,8 @@ import java.util.List;
public class ProductSpecServiceImpl implements ProductSpecService {
@Autowired
private ProductSpecMapper productSpecMapper;
@Autowired
private StringEmptyUtil emptyUtil;
/**
* 列表查询
@ -61,4 +64,15 @@ public class ProductSpecServiceImpl implements ProductSpecService {
productSpecMapper.updateById(productSpec);
}
/**
* 删除功能
*
* @param id 要删除的ID
*/
@Override
public void deleteById(Long id) {
emptyUtil.isEmpty(id, MessageConstant.UPDATE_ID_IS_NOT_EMPTY);
productSpecMapper.deleteById(id);
}
}

View File

@ -26,6 +26,14 @@
where id = #{id}
</update>
<!-- 删除功能 -->
<update id="deleteById">
update product_spec
set is_deleted = 1,
update_time = now()
where id = #{id}
</update>
<!-- 列表查询 -->
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
select