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

import cn.com.ty.lift.ud.chat.controller.model.ChatSessionReq;
import cn.com.ty.lift.ud.chat.controller.query.ChatSessionQuery;
import cn.com.ty.lift.ud.common.BaseController;

import java.time.LocalDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.service.IService;

import cn.com.ty.lift.ud.chat.mapper.entity.ChatSessionEntity;
import cn.com.ty.lift.ud.chat.service.IChatSessionService;
import cn.com.xwy.boot.web.dto.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 会话 API Jing
 * 
 * @author Xson
 * @date 2020-04-22
 */
@Api(tags = "会话 API- 盛文静")
@RestController
@RequestMapping("/api/chatSessions")
public class ChatSessionController extends BaseController<ChatSessionEntity, ChatSessionQuery> {

    private final Logger log = LoggerFactory.getLogger(ChatSessionController.class);

    private @Autowired IChatSessionService chatSessionService;

    @Override
    protected IService<ChatSessionEntity> getService() {
        return chatSessionService;
    }

    @PutMapping("/update-batch")
    @ApiOperation(value = "批量修改屏蔽状态")
    public RestResponse batchUpdate(@RequestBody ChatSessionReq req) {
        return chatSessionService.batchUpdate(req);
    }

    @PostMapping("/set-top")
    @ApiOperation(value = "置顶")
    public RestResponse setTop(@RequestBody ChatSessionReq req) {
        return chatSessionService.setTop(req);
    }

    @PostMapping("/query-page")
    @ApiOperation(value = "分页查询")
    @Override
    public RestResponse getCondition(@RequestBody ChatSessionQuery request) {
        return chatSessionService.selectByExample(request);
    }

    @PostMapping("/findFriendList")
    @ApiOperation(value = "获取我的聊天列表")
    public RestResponse findFriendList(@RequestBody ChatSessionQuery request) {
        return chatSessionService.findDBListByUserId(request);
    }

    @PostMapping("/findOneByLiftCase")
    @ApiOperation(value = "根据诊单id查询房间信息")
    public RestResponse findOneByLiftCase(@RequestBody ChatSessionQuery req) {
        return chatSessionService.findOneByLiftCase(req);
    }

    @PostMapping("/createPrivateChatRoom")
    @ApiOperation(value = "进入私聊初始化房间号")
    public RestResponse createPrivateChatRoom(@RequestBody ChatSessionQuery req) {
        return chatSessionService.createPrivateChatRoom(req);
    }
}