12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.winhc.phoenix.example.controller;
- import com.winhc.phoenix.example.service.HbaseQueryService;
- import com.winhc.phoenix.example.vo.ResponseVo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.AllArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * @Author: XuJiakai
- * @Date: 2020/9/1 17:44
- * @Description:
- */
- @Slf4j
- @AllArgsConstructor
- @RestController
- @Api(tags = "hbase查询", value = "hbase")
- @RequestMapping("hbase")
- public class HbaseQueryController {
- private HbaseQueryService hbaseQueryService;
- @ApiOperation(value = "scan前辍匹配,默认返回前100条数据")
- @GetMapping("scan/{tableName}/{rowPrefix}")
- public ResponseVo scan(@PathVariable String tableName, @PathVariable String rowPrefix, @RequestParam(defaultValue = "100") Long size) {
- long start = System.currentTimeMillis();
- try {
- List<Object> scan = hbaseQueryService.scan(tableName, rowPrefix, size);
- return ResponseVo.success(start, scan);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- return ResponseVo.failure(start, e.getMessage());
- }
- }
- @ApiOperation(value = "点查")
- @GetMapping("get/{tableName}/{rowkey}")
- public ResponseVo get(@PathVariable String tableName, @PathVariable String rowkey) {
- long start = System.currentTimeMillis();
- try {
- Object columnMap = hbaseQueryService.get(tableName, rowkey);
- return ResponseVo.success(start, columnMap);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- return ResponseVo.failure(start, e.getMessage());
- }
- }
- }
|