2.0 日活数据查询接口
2.1 访问路径
总数 | http://localhost:8070/realtime-total?date=2020-07-18 |
---|---|
分时统计 | http://localhost:8070/realtime-hours?id=dau&date=2020-07-18 |
2.2 要求数据格式
总数 | [{“id”:“dau”,“name”:“新增日活”,“value”:1200}, {“id”:“new_mid”,“name”:“新增设备”,“value”:233}] |
---|---|
分时统计 | {“yesterday”:{“11”:383,“12”:123,“17”:88,“19”:200 }, “today”:{“12”:38,“13”:1233,“17”:123,“19”:688 }} |
2.3 搭建发布工程
略
2.4 配置文件
server.port=8070
logging.level.root=error
spring.datasource.driver-class-name=org.apache.phoenix.jdbc.PhoenixDriver
spring.datasource.url=jdbc:phoenix:hadoop102,hadoop103,hadoop104:2181
spring.datasource.data-username=
spring.datasource.data-password=
#mybatis
#mybatis.typeAliasesPackage=com.example.phoenix.entity
mybatis.mapperLocations=classpath:mapper/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
2.5 代码实现
控制层 | PublisherController | 实现接口的web发布 |
---|---|---|
服务层 | PublisherService | 数据业务查询interface |
PublisherServiceImpl | 业务查询的实现类 | |
数据层 | DauMapper | 数据层查询的interface |
DauMapper.xml | 数据层查询的实现配置 | |
主程序 | GmallPublisherApplication | 增加扫描包 |
2.5.1 GmallPublisherApplication增加扫描包
@SpringBootApplication
@MapperScan(basePackages = "com.atguigu.gmallXXXXXXX.publisher.mapper")
public class Gmall2020PublisherApplication{
public static void main(String[] args) {
SpringApplication.run(Gmall2020PublisherApplication.class, args);
}
}
@MapperScan(basePackages = “com.atguigu.gmallXXXXXXX.publisher.mapper”)
public class Gmall2020PublisherApplication{
public static void main(String[] args) {
SpringApplication.run(Gmall2020PublisherApplication.class, args);
}
}
2.5.2 controller层
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall2020.dw.publisher.service.PublisherService;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.</