package com.zy.asrs.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.core.exception.CoolException; import com.zy.asrs.entity.Node; import com.zy.asrs.mapper.NodeMapper; import com.zy.asrs.service.NodeService; import org.springframework.stereotype.Service; import java.util.Date; @Service("nodeService") public class NodeServiceImpl extends ServiceImpl implements NodeService { @Override public Node getTop() { Node top = this.selectOne(new EntityWrapper().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) { return selectOne(new EntityWrapper().eq("uuid", uuid)); } @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().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().eq("host_id", hostId).eq("uuid", uuid).eq("type", type).eq("parent_id", parentId)); } }