package com.qiuguo.iot.box.websocket.api.controller;

import com.qiuguo.iot.box.websocket.api.service.WebsocketService;
import com.qiuguo.iot.data.service.system.SystemTalkAnswerConfigService;
import com.qiuguo.iot.third.nlp.Nlp;
import com.qiuguo.iot.third.service.LacNlpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
import reactor.core.publisher.Mono;

@RestController
@Slf4j
@RequestMapping("/websocket")
public class WebsocketController {
    @Autowired
    WebsocketService websocketService;

    @Autowired
    LacNlpService lacNlpService;

    @Autowired
    SystemTalkAnswerConfigService systemTalkAnswerConfigService;

    @GetMapping("/push/message")
    public Mono<String> pushMessage(@RequestParam String message, @RequestParam String id, @RequestParam Integer type) {

        return websocketService.pushMessage(message, id, type);
    }

    @GetMapping("/init/sysTalkAnswer")
    public Mono<String> sysTalkAnswer() {

        systemTalkAnswerConfigService.initGroup();
        return Mono.just("重新读取指令完成");
    }

    @GetMapping("/test/nlp")
    public Mono<Nlp> nlp(@RequestParam String value) {

        return lacNlpService.geSingletNlp(value);
    }
}
