package com.zy.crm.manager.service.impl; 
 | 
  
 | 
import com.baomidou.mybatisplus.mapper.EntityWrapper; 
 | 
import com.baomidou.mybatisplus.service.impl.ServiceImpl; 
 | 
import com.core.exception.CoolException; 
 | 
import org.springframework.stereotype.Service; 
 | 
import com.zy.crm.manager.entity.Node; 
 | 
import com.zy.crm.manager.mapper.NodeMapper; 
 | 
import com.zy.crm.manager.service.NodeService; 
 | 
  
 | 
import java.util.Date; 
 | 
  
 | 
@Service("nodeService") 
 | 
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService { 
 | 
  
 | 
    @Override 
 | 
    public Node getTop() { 
 | 
        Node top = this.selectOne(new EntityWrapper<Node>().eq("type", 0).eq("level", 0)); 
 | 
        if (top == null) { 
 | 
            top = new Node(); 
 | 
            top.setName("全部"); 
 | 
            top.setUuid("全部"); 
 | 
            top.setType(0); 
 | 
            top.setLevel(0); 
 | 
            top.setSort(0); 
 | 
            top.setStatus(1); 
 | 
            top.setCreateTime(new Date()); 
 | 
            top.setUpdateTime(new Date()); 
 | 
            Integer insert = this.baseMapper.insert(top); 
 | 
            if (insert == 0) { 
 | 
                throw new CoolException("服务器异常"); 
 | 
            } 
 | 
        } 
 | 
        return top; 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public Node selectByUuid(String uuid, Long hostId) { 
 | 
        return this.baseMapper.selectByUuid(uuid, hostId); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public Node selectByUuid(String uuid, Long hostId, Integer type) { 
 | 
        return selectOne(new EntityWrapper<Node>().eq("host_id", hostId).eq("uuid", uuid).eq("type", type)); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public Node selectByUuid(String uuid, Long hostId, Integer type, Long parentId) { 
 | 
        return selectOne(new EntityWrapper<Node>().eq("host_id", hostId).eq("uuid", uuid).eq("type", type).eq("parent_id", parentId)); 
 | 
    } 
 | 
} 
 |