|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.web.controller.manage.goods;
|
|
package com.cyksj.web.controller.manage.goods;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
@@ -8,6 +9,7 @@ import com.cyksj.model.entity.GoodsDon;
|
|
|
import com.cyksj.model.entity.GoodsDonSpec;
|
|
import com.cyksj.model.entity.GoodsDonSpec;
|
|
|
import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
|
|
import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
|
|
|
import com.cyksj.model.manage.request.ReqGoodsSpecSingle;
|
|
import com.cyksj.model.manage.request.ReqGoodsSpecSingle;
|
|
|
|
|
+import com.cyksj.service.mange.CmsGoodsDonService;
|
|
|
import com.cyksj.service.mange.CmsGoodsDonSpecService;
|
|
import com.cyksj.service.mange.CmsGoodsDonSpecService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
@@ -38,6 +40,8 @@ public class CmsGoodsDonSpecController {
|
|
|
|
|
|
|
|
private final CmsGoodsDonSpecService goodsDonSpecService;
|
|
private final CmsGoodsDonSpecService goodsDonSpecService;
|
|
|
|
|
|
|
|
|
|
+ private final CmsGoodsDonService goodsDonService;
|
|
|
|
|
+
|
|
|
@PostMapping("/post")
|
|
@PostMapping("/post")
|
|
|
public Result<String> specAppend(@RequestBody ReqGoodsSpecSingle specSingle) throws Exception {
|
|
public Result<String> specAppend(@RequestBody ReqGoodsSpecSingle specSingle) throws Exception {
|
|
|
|
|
|
|
@@ -84,10 +88,10 @@ public class CmsGoodsDonSpecController {
|
|
|
/**
|
|
/**
|
|
|
* 删除 商品spec
|
|
* 删除 商品spec
|
|
|
*/
|
|
*/
|
|
|
- @DeleteMapping(value = "/delete/{specId}")
|
|
|
|
|
- public Result<String> delete(@PathVariable Long specId) throws Exception {
|
|
|
|
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
|
|
+ public Result<String> delete(Integer specId, Long goodsId) throws Exception {
|
|
|
//TODO
|
|
//TODO
|
|
|
- GoodsDonSpec loveSpec = goodsDonSpecService.getById(specId);
|
|
|
|
|
|
|
+ GoodsDonSpec loveSpec = goodsDonSpecService.getOne(Wrappers.lambdaQuery(GoodsDonSpec.class).eq(GoodsDonSpec::getGoodsId,goodsId));
|
|
|
if (null == loveSpec) {
|
|
if (null == loveSpec) {
|
|
|
throw new RuntimeException("该商品未设置总规格, 请设置总规格.");
|
|
throw new RuntimeException("该商品未设置总规格, 请设置总规格.");
|
|
|
}
|
|
}
|
|
@@ -96,7 +100,7 @@ public class CmsGoodsDonSpecController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
JavaType type = Jsons.javaType().constructMapType(HashMap.class, Integer.class, ReqGoodsSpecSingle.class);
|
|
JavaType type = Jsons.javaType().constructMapType(HashMap.class, Integer.class, ReqGoodsSpecSingle.class);
|
|
|
- Map<Integer, ReqGoodsSpecSingle> map = Jsons.parseObject(loveSpec.getSpecMapping(), type);
|
|
|
|
|
|
|
+ Map<Long, ReqGoodsSpecSingle> map = Jsons.parseObject(loveSpec.getSpecMapping(), type);
|
|
|
if (!map.containsKey(specId)) {
|
|
if (!map.containsKey(specId)) {
|
|
|
throw new RuntimeException("该id指向的规格属性 不存在.");
|
|
throw new RuntimeException("该id指向的规格属性 不存在.");
|
|
|
}
|
|
}
|