mirror of https://github.com/jumpserver/jumpserver
				
				
				
			perf: 优化创建子节点时锁置后
							parent
							
								
									d70351e6b3
								
							
						
					
					
						commit
						a78ccc9667
					
				| 
						 | 
				
			
			@ -39,16 +39,16 @@ class NodeChildrenApi(generics.ListCreateAPIView):
 | 
			
		|||
        self.instance = self.get_object()
 | 
			
		||||
 | 
			
		||||
    def perform_create(self, serializer):
 | 
			
		||||
        data = serializer.validated_data
 | 
			
		||||
        _id = data.get("id")
 | 
			
		||||
        value = data.get("value")
 | 
			
		||||
        if value:
 | 
			
		||||
            children = self.instance.get_children()
 | 
			
		||||
            if children.filter(value=value).exists():
 | 
			
		||||
                raise JMSException(_('The same level node name cannot be the same'))
 | 
			
		||||
        else:
 | 
			
		||||
            value = self.instance.get_next_child_preset_name()
 | 
			
		||||
        with NodeAddChildrenLock(self.instance):
 | 
			
		||||
            data = serializer.validated_data
 | 
			
		||||
            _id = data.get("id")
 | 
			
		||||
            value = data.get("value")
 | 
			
		||||
            if value:
 | 
			
		||||
                children = self.instance.get_children()
 | 
			
		||||
                if children.filter(value=value).exists():
 | 
			
		||||
                    raise JMSException(_('The same level node name cannot be the same'))
 | 
			
		||||
            else:
 | 
			
		||||
                value = self.instance.get_next_child_preset_name()
 | 
			
		||||
            node = self.instance.create_child(value=value, _id=_id)
 | 
			
		||||
            # 避免查询 full value
 | 
			
		||||
            node._full_value = node.value
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue