Git Product home page Git Product logo

tdengine-demo's Introduction

tdengine-demo

TDengine ORM demo

ORM 框架

SQLI

    <dependency>
         <groupId>io.xream.x7</groupId>
         <artifactId>x7-spring-boot-starter</artifactId>
         ....
    </dependency>

实体类注解

public class HeatSupply {

    @X.Key
    private Long id; //System.currentTimeMillis()
    private BigDecimal value;
    @X.Tag
    private String city;
    @X.Tag
    private String zone;
    @X.TagTarget //标注sn作为子表名后缀
    private String sn;
    
    ....

Repository

@Repository
public interface HeatSupplyRepository extends BaseRepository<HeatSupply>, ResultMapRepository {}

插入

    HeatSupply heatSupply = new HeatSupply();
    heatSupply.setId(System.currentTimeMillis());
    heatSupply.setCity("北京市");
    heatSupply.setZone("朝阳区");
    heatSupply.setSn("H100003");
    heatSupply.setValue(new BigDecimal(15));
    
    this.heatSupplyRepository.create(heatSupply);

查找

    CriteriaBuilder.ResultMapBuilder criteriaBuilder = CriteriaBuilder.resultMapBuilder();
    criteriaBuilder.reduce(ReduceType.SUM, "value");
    criteriaBuilder.eq("city","北京市").eq("zone","朝阳区");
    //criteriaBuilder.xAggr("INTERVAL(?)", interval); //报语法错误 INTERVAL('2s'), 等TDengine官方支持
    if (StringUtil.isNotNull(interval)) {//需要显示判断是否为null
        criteriaBuilder.xAggr("INTERVAL(" + interval + ")");//INTERVAL(2s)
    }

    criteriaBuilder.paged().page(1).rows(10).ignoreTotalRows();
    
    Criteria.ResultMapCriteria criteria = criteriaBuilder.build();

    List<Map<String,Object>> list = this.heatSupplyRepository.find(criteria);

tdengine-demo's People

Contributors

sim-wangyan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dengcp shyding

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.