dev798
parent
fb716982f1
commit
cb15936f61
|
@ -38,9 +38,12 @@ public class CategoryController {
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("分类添加")
|
@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);
|
Integer res = categoryService.insertCategory(category);
|
||||||
return AjaxResult.success(res==1?"添加成功":"添加失败");
|
return AjaxResult.success(res == 1 ? "添加成功" : "添加失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
|
|
@ -57,6 +57,13 @@ public class ProductController {
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除商品")
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
public AjaxResult deleteProduct(@PathVariable Integer id){
|
||||||
|
Integer res = productService.deleteProduct(id);
|
||||||
|
return AjaxResult.success(res==1?"删除成功":"删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("图片上传")
|
@ApiOperation("图片上传")
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
|
|
|
@ -20,4 +20,6 @@ public interface ProductMapper {
|
||||||
void updateMothodId(Integer id);
|
void updateMothodId(Integer id);
|
||||||
|
|
||||||
Integer findProductNumber(ProductReq productReq);
|
Integer findProductNumber(ProductReq productReq);
|
||||||
|
|
||||||
|
Integer deleteProduct(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,5 @@ public interface ProductService {
|
||||||
void productInsert(ProductReq productReq);
|
void productInsert(ProductReq productReq);
|
||||||
|
|
||||||
|
|
||||||
|
Integer deleteProduct(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer insertCategory(Category category) {
|
public Integer insertCategory(Category category) {
|
||||||
category.setCategoryName(SecurityUtils.getUsername());
|
category.setCreateBy(SecurityUtils.getUsername());
|
||||||
return categoryMapper.insertCategory(category);
|
return categoryMapper.insertCategory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer updateCategory(Category category) {
|
public Integer updateCategory(Category category) {
|
||||||
category.setCategoryName(SecurityUtils.getUsername());
|
category.setCreateBy(SecurityUtils.getUsername());
|
||||||
return categoryMapper.updateCategory(category);
|
return categoryMapper.updateCategory(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,11 @@ public class ProductServiceImpl implements ProductService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteProduct(Integer id) {
|
||||||
|
return productMapper.deleteProduct(id);
|
||||||
|
}
|
||||||
|
|
||||||
private void insertProductSku(ProductReq productReq) {
|
private void insertProductSku(ProductReq productReq) {
|
||||||
List<ProductSku> productSkuList = productReq.getProductSkus();
|
List<ProductSku> productSkuList = productReq.getProductSkus();
|
||||||
int productId = productReq.getProduct().getId();
|
int productId = productReq.getProduct().getId();
|
||||||
|
|
|
@ -64,8 +64,15 @@
|
||||||
NOW()
|
NOW()
|
||||||
);
|
);
|
||||||
</insert>
|
</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>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue