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;
|
}
|
}
|