shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.iplatform.chat.api;
 
import com.iplatform.base.PlatformAdapterController;
import com.iplatform.chat.ChatService;
import com.iplatform.chat.Constants;
import com.iplatform.chat.MsgType;
import com.iplatform.model.vo.ChatVo;
import com.walker.web.ResponseValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/test/chat")
public class TestChatApi extends PlatformAdapterController {
 
//    private ChatEngine chatEngine;
    private ChatService chatService;
 
    private long me = 10110;
    private long customerService = Constants.USER_ID_ROBOT;
 
    @Autowired
    public TestChatApi(ChatService chatService){
        this.chatService = chatService;
    }
 
    @RequestMapping("/list")
    public ResponseValue listPage(int pageIndex){
//        this.chatService.queryPageChatList();
        return ResponseValue.success();
    }
 
    @RequestMapping("/send")
    public ResponseValue sendChat(String msg){
        logger.debug("我发送一个消息:" + msg);
//        this.chatEngine.sendChat(this.createTestChatVo(msg, null, customerService));
        return ResponseValue.success();
    }
 
    @RequestMapping("/switch_human")
    public ResponseValue switchToHuman(){
        this.customerService = 12345;
        return ResponseValue.success();
    }
 
    private ChatVo createTestChatVo(String text, String bizId, long customerService){
        ChatVo response = new ChatVo();
        if(bizId != null){
            response.setBizId(bizId);
        }
        response.setMe(me);
        response.setCustomerService(customerService);
        response.setMsgType(MsgType.INDEX_TEXT);   // 注意:这里根据情况设置消息类型
        response.setMessage(text);
        response.setCustomerServiceSend(false);
        return response;
    }
}