|
|
@@ -21,6 +21,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.constraints.Null;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
@@ -42,13 +43,16 @@ public class MerchantClassificationController extends BaseController {
|
|
|
MerchantClassification orig = merchantClassificationRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
ObjUtils.merge(orig, record);
|
|
|
MerchantClassification byName = merchantClassificationRepo.findByMerchantIdAndName(orig.getMerchantId(), orig.getName());
|
|
|
- if (!byName.getId().equals(orig.getId())){
|
|
|
- throw new BusinessException("该分类已存在");
|
|
|
+ if (ObjectUtil.isNotNull(byName)) {
|
|
|
+ if (!byName.getId().equals(orig.getId())) {
|
|
|
+ throw new BusinessException("该分类已存在");
|
|
|
+ }
|
|
|
}
|
|
|
return merchantClassificationRepo.save(orig);
|
|
|
}
|
|
|
+ MerchantClassification add = merchantClassificationService.add(SecurityUtils.getAuthenticatedUser().getId(), record);
|
|
|
//添加
|
|
|
- return merchantClassificationService.add(SecurityUtils.getAuthenticatedUser().getId(), record);
|
|
|
+ return add;
|
|
|
//return merchantClassificationRepo.save(record);
|
|
|
}
|
|
|
|
|
|
@@ -67,7 +71,7 @@ public class MerchantClassificationController extends BaseController {
|
|
|
@PostMapping("/del/{id}")
|
|
|
public void del(@PathVariable Long id) {
|
|
|
MerchantClassification classification = merchantClassificationRepo.findById(id).orElseThrow(new BusinessException("无分类"));
|
|
|
- if (StrUtil.isNotBlank(classification.getGoodsIds())){
|
|
|
+ if (StrUtil.isNotBlank(classification.getGoodsIds())) {
|
|
|
throw new BusinessException("该分类下有商品,暂无法删除");
|
|
|
}
|
|
|
merchantClassificationRepo.deleteById(id);
|