package com.sqx.modules.gameChat.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.gameChat.service.ChatContentTcwmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value="用户端-订单聊天室",tags={"用户端-订房聊天室"})
@RequestMapping(value = "/app/ordersChat")
public class OrderChatTcwmController {

    @Autowired
    private ChatContentTcwmService chatContentTcwmService;

    @Login
    @GetMapping("/selectOrdersChatPageUser")
    @ApiOperation("用户获取聊天室列表")
    public Result selectOrdersChatPageUser(Integer page, Integer limit, @RequestAttribute Long userId){

        return chatContentTcwmService.selectOrdersChatPage(page, limit, userId, null, null);
    }

    @Login
    @GetMapping("/selectOrdersChatPageRider")
    @ApiOperation("骑手获取聊天室列表")
    public Result selectOrdersChatPageRider(Integer page, Integer limit, @RequestAttribute Long userId){

        return chatContentTcwmService.selectOrdersChatPage(page, limit, null, userId, null);
    }

    @GetMapping("/selectGameChatDetails")
    @ApiOperation("获取聊天内容")
    public Result selectGameChatDetail(Integer page,Integer limit,Long ordersId, Integer type){

        return chatContentTcwmService.selectGameChatDetails(page, limit, ordersId, type);
    }

    @Login
    @ApiOperation("用户获取聊天室未读消息总数")
    @GetMapping(value = "selectUserAllUnreadCount")
    public Result selectUserAllUnreadCount(@RequestAttribute Long userId){

        return chatContentTcwmService.selectAllUnreadCount(userId, null, null);
    }

    @ApiOperation("用户获取聊天室未读消息数")
    @GetMapping(value = "selectUserUnreadCount")
    public Result selectUserUnreadCount(Long ordersId){

        return chatContentTcwmService.selectUnreadMessage(ordersId, 1);
    }

    @Login
    @ApiOperation("骑手获取聊天室未读消息总数")
    @GetMapping(value = "selectRiderAllUnreadCount")
    public Result selectRiderAllUnreadCount(@RequestAttribute("userId") Long userId){

        return chatContentTcwmService.selectAllUnreadCount(null, userId, null);
    }

    @ApiOperation("骑手获取聊天室未读消息数")
    @GetMapping(value = "selectRiderUnreadCount")
    public Result selectRiderUnreadCount(Long ordersId){

        return chatContentTcwmService.selectUnreadMessage(ordersId, 2);
    }

}
