|
|
@@ -1,8 +1,11 @@
|
|
|
package com.cyksj.web.controller.manage.group;
|
|
|
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.model.entity.GoodsDonSku;
|
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
|
+import com.cyksj.service.mange.CmsGoodsDonSkuService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
@@ -31,6 +34,8 @@ public class CmsGroupController {
|
|
|
|
|
|
private final CmsGroupService groupService;
|
|
|
|
|
|
+ private final CmsGoodsDonSkuService skuService;
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
|
public Result<SearchResult<GroupsTrips>> get(String account){
|
|
|
SearchResult<GroupsTrips> search = beanSearcher.search(GroupsTrips.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
@@ -41,6 +46,13 @@ public class CmsGroupController {
|
|
|
|
|
|
@PostMapping("/post")
|
|
|
public Result<String> add(@RequestBody GroupsTrips groups){
|
|
|
+ GoodsDonSku sku = skuService.getById(groups.getSkuId());
|
|
|
+ if (sku == null) {
|
|
|
+ throw new BusinessRuntimeException("该商品规格不存在!");
|
|
|
+ }
|
|
|
+ groups.setNum(sku.getNum());
|
|
|
+ groups.setAvailableNum(sku.getNum());
|
|
|
+
|
|
|
groupService.save(groups);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|