package com.lanyuanxiaoyao.service.web.controller;

import com.lanyuanxiaoyao.service.forest.service.PulsarService;
import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse;
import com.lanyuanxiaoyao.service.web.controller.base.BaseController;
import com.lanyuanxiaoyao.service.web.entity.TopicVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Pulsar 查询
 *
 * @author lanyuanxiaoyao
 * @date 2023-04-28
 */
@RestController
@RequestMapping("pulsar")
public class PulsarController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(PulsarController.class);

    private final PulsarService pulsarService;

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public PulsarController(PulsarService pulsarService) {
        this.pulsarService = pulsarService;
    }

    @GetMapping("topic")
    public AmisResponse<TopicVO> topic(@RequestParam("pulsar_url") String pulsarUrl, @RequestParam("topic") String topic) {
        return AmisResponse.responseSuccess(new TopicVO(pulsarService.topic(pulsarService.name(pulsarUrl), topic)));
    }
}
