更新删除商品 和回收站删除商品的问题

This commit is contained in:
stivepeim
2020-11-20 15:09:18 +08:00
parent 30a90cf45c
commit 138d2a2c62
6 changed files with 29 additions and 21 deletions

View File

@@ -39,10 +39,11 @@ export function productDetailApi(id) {
* 删除商品
* @param pram
*/
export function productDeleteApi(id) {
export function productDeleteApi(id, type) {
return request({
url: `/admin/store/product/delete/${id}`,
method: 'get'
method: 'get',
params:{type:type}
})
}
@@ -245,10 +246,9 @@ export function importProductApi(params) {
* 恢复
* @param pram
*/
export function restoreApi(params) {
export function restoreApi(id) {
return request({
url: `/admin/store/product/importProduct`,
method: 'post',
params
url: `/admin/store/product/restore/${id}`,
method: 'get'
})
}

View File

@@ -254,9 +254,10 @@ export default {
this.getList()
},
// 删除
handleDelete(id, idx) {
this.$modalSure().then(() => {
productDeleteApi(id).then(() => {
handleDelete(id, type) {
this.$modalSure(`删除 id 为 ${id} 的商品`).then(() => {
const deleteFlag = type == 5 ? 'delete':'recycle';
productDeleteApi(id,deleteFlag).then(() => {
this.$message.success('删除成功')
this.getList()
this.goodHeade();

View File

@@ -74,15 +74,16 @@ public class StoreProductController {
}
/**
* 删除商品
* @param id Integer
* @author Mr.Zhang
* @since 2020-05-27
* 删除商品
* @param id 商品id
* @param type 删除类型 recycle 回收站 delete 物理删除
* @return
*/
@ApiOperation(value = "删除")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
public CommonResult<String> delete(@RequestBody @PathVariable Integer id){
if(storeProductService.deleteProduct(id)){
public CommonResult<String> delete(@PathVariable Integer id,
@RequestParam(value = "type", required = false, defaultValue = "recycle")String type){
if(storeProductService.deleteProduct(id, type)){
// if(storeProductService.removeById(id)){
storeCartService.productStatusNotEnable(id);
return CommonResult.success();

View File

@@ -126,7 +126,7 @@ public interface StoreProductService extends IService<StoreProduct> {
* @param productId 商品id
* @return 删除结果
*/
boolean deleteProduct(Integer productId);
boolean deleteProduct(Integer productId, String type);
/**
* 恢复已删除商品

View File

@@ -1,5 +1,6 @@
package com.zbkj.crmeb.store.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -919,8 +920,13 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
* @return
*/
@Override
public boolean deleteProduct(Integer productId) {
public boolean deleteProduct(Integer productId, String type) {
LambdaUpdateWrapper<StoreProduct> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
if (StrUtil.isNotBlank(type) && "delete".equals(type)) {
lambdaUpdateWrapper.eq(StoreProduct::getId, productId);
int delete = dao.delete(lambdaUpdateWrapper);
return delete > 0;
}
lambdaUpdateWrapper.eq(StoreProduct::getId, productId);
lambdaUpdateWrapper.set(StoreProduct::getIsDel, true);
return update(lambdaUpdateWrapper);

View File

@@ -223,10 +223,10 @@
<!--</appender>-->
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT"/>
<!-- <appender-ref ref="DEBUG_FILE" />-->
<!-- <appender-ref ref="INFO_FILE" />-->
<!-- <appender-ref ref="WARN_FILE" />-->
<!-- <appender-ref ref="STDOUT"/>-->
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
<!--<appender-ref ref="LOGSTASH"/>-->
</root>