dev798
wxy 2024-04-05 15:57:51 +08:00
parent fb716982f1
commit cb15936f61
7 changed files with 30 additions and 5 deletions

View File

@ -38,9 +38,12 @@ public class CategoryController {
@PostMapping
@ApiOperation("分类添加")
public AjaxResult insertCategory(@RequestBody Category category){
public AjaxResult insertCategory(@RequestBody(required = false) Category category){
if (category == null) {
return AjaxResult.error("请求体不能为空");
}
Integer res = categoryService.insertCategory(category);
return AjaxResult.success(res==1?"添加成功":"添加失败");
return AjaxResult.success(res == 1 ? "添加成功" : "添加失败");
}
@PutMapping

View File

@ -57,6 +57,13 @@ public class ProductController {
return R.ok();
}
@ApiOperation("删除商品")
@DeleteMapping("{id}")
public AjaxResult deleteProduct(@PathVariable Integer id){
Integer res = productService.deleteProduct(id);
return AjaxResult.success(res==1?"删除成功":"删除失败");
}
@ApiOperation("图片上传")
@PostMapping("/upload")

View File

@ -20,4 +20,6 @@ public interface ProductMapper {
void updateMothodId(Integer id);
Integer findProductNumber(ProductReq productReq);
Integer deleteProduct(Integer id);
}

View File

@ -18,4 +18,5 @@ public interface ProductService {
void productInsert(ProductReq productReq);
Integer deleteProduct(Integer id);
}

View File

@ -30,13 +30,13 @@ public class CategoryServiceImpl implements CategoryService {
@Override
public Integer insertCategory(Category category) {
category.setCategoryName(SecurityUtils.getUsername());
category.setCreateBy(SecurityUtils.getUsername());
return categoryMapper.insertCategory(category);
}
@Override
public Integer updateCategory(Category category) {
category.setCategoryName(SecurityUtils.getUsername());
category.setCreateBy(SecurityUtils.getUsername());
return categoryMapper.updateCategory(category);
}
}

View File

@ -124,6 +124,11 @@ public class ProductServiceImpl implements ProductService {
}
@Override
public Integer deleteProduct(Integer id) {
return productMapper.deleteProduct(id);
}
private void insertProductSku(ProductReq productReq) {
List<ProductSku> productSkuList = productReq.getProductSkus();
int productId = productReq.getProduct().getId();

View File

@ -64,8 +64,15 @@
NOW()
);
</insert>
<update id="updateMothodId">
<update id="updateMothodId">
update t_product set method_id =#{methodId} where id = #{id}
</update>
<update id="deleteProduct">
update t_product set id_delete = 0 where id = #{id}
</update>