Skip to content

Commit

Permalink
Merge pull request #304 from n3A87/0607
Browse files Browse the repository at this point in the history
feat: add showSpaces function
  • Loading branch information
knqiufan authored Jun 11, 2024
2 parents 5bd87a2 + 23bd150 commit de369c3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,10 @@ private int randomAge() {
double randomAge = Math.random() * 140;
return (int) randomAge;
}

@Test
public void showSpacesTest() {
List<String> spaces = repository.showSpaces();
System.out.println(spaces);
}
}
21 changes: 21 additions & 0 deletions src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import com.sun.istack.NotNull;
import com.vesoft.nebula.client.graph.data.ResultSet;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.nebula.contrib.ngbatis.exception.QueryException;
Expand Down Expand Up @@ -551,4 +553,23 @@ default List<NgPath<I>> shortestOptionalPath(@Param("srcId") I srcId,@Param("dst

// endregion


/**
* 列出所有图空间
* @return 所有图空间
*/
default List<String> showSpaces() {
MethodModel methodModel = getMethodModel();
methodModel.setReturnType(ResultSet.class);
methodModel.setResultType(ResultSet.class);
ClassModel classModel = getClassModel(this.getClass());
ResultSet resultSet = (ResultSet) MapperProxy.invoke(classModel, methodModel);
List<String> spaceNames = new ArrayList();
for (int i = 0; i < resultSet.rowsSize(); i++) {
spaceNames.add(resultSet.rowValues(i).get("Name").toString());
}
return spaceNames;
}


}
5 changes: 5 additions & 0 deletions src/main/resources/NebulaDaoBasic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,9 @@
</select>
<!--endregion-->

<select id="showSpaces">
SHOW SPACES;
</select>


</mapper>

0 comments on commit de369c3

Please sign in to comment.