package com.mortals.xhx.webflux.service.impl;


import com.mortals.xhx.webflux.req.RobotTransReq;
import com.mortals.xhx.webflux.dto.ChatBaseParam;
import com.mortals.xhx.webflux.dto.CreateSessionParam;
import com.mortals.xhx.webflux.dto.SessionBaseParam;
import com.mortals.xhx.webflux.dto.SessionVO;
import com.mortals.xhx.webflux.enums.FlowChatSceneEnum;
import com.mortals.xhx.webflux.factory.FlowChatContext;
import com.mortals.xhx.webflux.factory.FlowChatFactory;
import com.mortals.xhx.webflux.factory.FlowRobotChatContext;
import com.mortals.xhx.webflux.service.IChatMsgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

import javax.annotation.Resource;

/**
 * ChatMsgService
 * @author: zxfei
 * @date: 2025/3/13 10:03
 */
@Slf4j
@Service
public class ChatMsgServiceImpl implements IChatMsgService {

    @Resource
    private FlowChatFactory chatFactory;

    @Override
    public SessionVO createSession(CreateSessionParam param) {
        // 创建会话...
        return new SessionVO();
    }

    @Override
    public Flux<String> baseChat(RobotTransReq param) {
        return chatFactory.getInstance(FlowChatSceneEnum.BASE_CHAT)
                .request(new FlowChatContext(param));
    }

    @Override
    public void stopChat(SessionBaseParam param) {
        chatFactory.getInstance(FlowChatSceneEnum.BASE_CHAT)
                .stop(param.getSessionId());
    }


}
