|
@@ -15,11 +15,13 @@ import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
|
import com.qs.mp.common.enums.GoodsStatusEnum;
|
|
|
+import com.qs.mp.common.utils.LogUtil;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
@@ -30,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -162,7 +165,8 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
goods.setSkuProp(getSkuProp(skuList));
|
|
|
goodsService.saveGoods(goods, skuList);
|
|
|
} catch (Exception e) {
|
|
|
- return AjaxResult.error("商品'" + goods.getTitle() + "'新增失败" + e.getMessage());
|
|
|
+ LogUtil.error(logger, e, "商品新增失败。");
|
|
|
+ return AjaxResult.error("商品'" + goods.getTitle() + "'新增失败");
|
|
|
}
|
|
|
return AjaxResult.success("商品'" + goods.getTitle() + "'新增成功");
|
|
|
}
|
|
@@ -220,13 +224,17 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
goods.setSkuProp(getSkuProp(skuList));
|
|
|
goodsService.updateGoods(goods, skuList);
|
|
|
} catch (Exception e) {
|
|
|
- return AjaxResult.error("商品'" + goods.getTitle() + "'新增失败" + e.getMessage());
|
|
|
+ LogUtil.error(logger, e, "商品更新失败。");
|
|
|
+ return AjaxResult.error("商品'" + goods.getTitle() + "'更新失败");
|
|
|
}
|
|
|
- return AjaxResult.success("商品'" + goods.getTitle() + "'新增成功");
|
|
|
+ return AjaxResult.success("商品'" + goods.getTitle() + "'更新成功");
|
|
|
}
|
|
|
|
|
|
// 获取商品的sku
|
|
|
public String getSkuProp(List<GoodsSku> skuList) {
|
|
|
+ if (CollectionUtils.isEmpty(skuList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
LinkedHashMap<String, HashSet<String>> skuProp = new LinkedHashMap<>();
|
|
|
for (GoodsSku sku : skuList) {
|
|
|
if (StringUtils.isNotBlank(sku.getProperties())) {
|