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

This commit is contained in:
337031187
2020-11-20 15:09:18 +08:00
parent 333fba16c8
commit ad136fca15
6 changed files with 29 additions and 21 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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