package cn.com.ty.lift.ud.chat.controller;

import cn.com.ty.lift.ud.chat.controller.query.ChatMsgQuery;
import cn.com.ty.lift.ud.common.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.ty.lift.ud.chat.mapper.entity.ChatMsgEntity;
import cn.com.ty.lift.ud.chat.service.IChatMsgService;

import cn.com.xwy.boot.web.dto.RestResponse;

import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天记录 API Jing
 * 
 * @author Xson
 * @date 2020-04-22
 */
@Api(tags = "聊天记录 API- 盛文静")
@RestController
@RequestMapping("/api/chatMsgs")
public class ChatMsgController
    extends BaseController<ChatMsgEntity, ChatMsgQuery> {

    private final Logger log = LoggerFactory.getLogger(ChatMsgController.class);
    
    private @Autowired IChatMsgService chatMsgService;

    @Override
    protected IService<ChatMsgEntity> getService() {
        return chatMsgService;
    }
    
    // 根据条件查询
    @PostMapping("/msgHistoryList")
    @ApiOperation(value = "聊天室历史记录分页查询")
    public RestResponse msgHistoryList(@RequestBody ChatMsgQuery request) {
        return chatMsgService.msgHistoryList(request);
    }
    
    // 根据条件查询
    @PostMapping("/query-page")
    @ApiOperation(value = "分页查询")
    @Override
    public RestResponse getCondition(@RequestBody ChatMsgQuery request) {
        return chatMsgService.selectByExample(request);
    }
    
    @PostMapping("/messageHistory")
    @ApiOperation(value = "查询历史聊天记录")
    public RestResponse messageHistory(@RequestBody ChatMsgQuery req )  throws Exception {
       return chatMsgService.messageHistory(req);
    }
} 