编辑matype不能保存的问题
This commit is contained in:
parent
c2bfd254bb
commit
ed588f5797
|
|
@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM;
|
||||
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;
|
||||
|
|
@ -270,7 +272,11 @@ public class MaTypeController extends BaseController {
|
|||
public AjaxResult edit(@RequestBody MaType maType) {
|
||||
Long parentId = maType.getParentId();
|
||||
List<MaType> subMas = maTypeMapper.getListByParentId(parentId, null);
|
||||
boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
|
||||
List<MaType> filteredItems = subMas.stream().collect(Collectors.toList());
|
||||
if (Objects.nonNull(maType.getTypeId())) {
|
||||
filteredItems = subMas.stream().filter(item -> !maType.getTypeId().equals(item.getTypeId())).collect(Collectors.toList());
|
||||
}
|
||||
boolean containsSameBrother = filteredItems.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
|
||||
if (containsSameBrother) {
|
||||
return AjaxResult.error("修改失败,同级存在相同名称");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue