发布数据接口
1代码清单
控制层
PublisherController
实现接口的web发布
服务层
ClickhouseService
数据业务查询interface
ClickhouseServiceImpl
业务查询的实现类
数据层
OrderMapper
数据层查询的interface
OrderMapper.xml
数据层查询的实现配置
2接口
2.1访问路径
总数
http://publisher:8070/realtime-total?date=2019-02-01
分时统计
http://publisher:8070/realtime-hour?id=order_amount&date=2019-02-01
2.2要求数据格式
总数
[{"id":"dau","name":"新增日活","value":1200},
{"id":"new_mid","name":"新增设备","value":233 },
{"id":"order_amount","name":"新增交易额","value":1000.2 }]
分时统计
{"yesterday":{"11":383,"12":123,"17":88,"19":200 },
"today":{"12":38,"13":1233,"17":123,"19":688 }}
3代码开发
3.1 pom.xml
View Code
3.2OrderMapper
package com.atguigu.gmall0105.publisher.mapper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public interface OrderWideMapper {
//查询当日总额
public BigDecimal selectOrderAmount(String date);
//查询当日分时交易额
public List selectOrderAmountHour(String date);
}
3.3 OrderMapper.xml