|
@@ -1,5 +1,6 @@
|
|
|
package com.etotem.cfc.service;
|
|
package com.etotem.cfc.service;
|
|
|
|
|
|
|
|
|
|
+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.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -191,4 +192,15 @@ public class ProductService {
|
|
|
int rows = productMapper.decreaseStockAtomic(productId, quantity);
|
|
int rows = productMapper.decreaseStockAtomic(productId, quantity);
|
|
|
return rows > 0;
|
|
return rows > 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public Result<String> updateImages(Long productId, Long vendorId, List<String> images) {
|
|
|
|
|
+ Product product = productMapper.selectById(productId);
|
|
|
|
|
+ if (product == null) return Result.error("商品不存在");
|
|
|
|
|
+ if (!product.getVendorId().equals(vendorId)) return Result.error("无权修改");
|
|
|
|
|
+ String imagesJson = JSON.toJSONString(images);
|
|
|
|
|
+ product.setImages(imagesJson);
|
|
|
|
|
+ product.setUpdatedAt(new Date());
|
|
|
|
|
+ productMapper.updateById(product);
|
|
|
|
|
+ return Result.success("更新成功");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|