keyhub-projects / kh-data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyHub-Data

  • This repository contains some classes about DataSet used in the KeyHub project.

How to start

Maven

<dependency>
    <groupId>io.github.keyhub-projects</groupId>
    <artifactId>kh-data</artifactId>
    <version>2.0.1</version>
</dependency>

Gradle

implementation 'io.github.keyhub-projects:kh-data:2.0.1'

Structure

Tbl

Class Diagram

class_diagram

How to Use

  • Almost setter made by fluent interface.
    • It returns the instance itself.
      • It means that you can chain methods.
      • For example, tbl.where("b", EQUAL, 10).selectAll().
  • You can use the Tbl.from() method to convert the List<Map<String, Object>> to Tbl.
  • You can use the toRowMapList() method to convert the Tbl to List<Map<String, Object>>.
  • This is an example of how to use the Tbl class.
public List<OrderDetailView> findOrderedDetailViewList(String userId) throws IllegalAccessException {
        List<Order> orderList = orderJpaRepository.findByUserId(userId);
        List<PgView> pgViewList = pgClient.findPgViewListByUserId(userId);
        List<WmsView> wmsViewList = wmsClient.findWmsViewListByUserId(userId);

        Tbl orderTbl = Tbl.from(orderList);
        Tbl pgTbl = Tbl.from(pgViewList);
        Tbl wmsTbl = Tbl.from(wmsViewList);
        Tbl result = orderTbl.innerJoin(pgTbl)
                .on("id", "orderId")
                .selectAll()
                .toTbl()
                .innerJoin(wmsTbl)
                .on("id", "orderId")
                .selectAll()
                .toTbl();
        List<Map<String, Object>> mapList = result.toRowMapList();
        return mapList.stream()
                .map(OrderDetailView::fromRowMap)
                .toList();
    }

About

License:MIT License


Languages

Language:Java 97.5%Language:JavaScript 2.5%