package com.ruoyi.project.common.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.common.dto.MessageChatDto;
import com.ruoyi.project.common.service.IMessageChatService;
import com.ruoyi.project.common.service.IMessageContentUserService;
import org.apache.commons.math3.analysis.function.Abs;
import org.aspectj.apache.bcel.generic.RET;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 聊天室Controller
 *
 * @author jubs
 * @date 2024-05-14
 */
@RestController
@RequestMapping("/common/messageChat")
public class MessageChatController extends BaseController {
    @Resource
    private IMessageChatService messageChatService;

    @Resource
    private IMessageContentUserService iMessageContentUserService;


    @PostMapping("/readMessage")
    public AjaxResult readMessage(@RequestBody MessageChatDto messageChatDto) {
        return AjaxResult.success(messageChatService.readMessage(messageChatDto));
    }

    @GetMapping("/getChatRoomByQuery")
    public AjaxResult getChatRoomByQuery(MessageChatDto messageChatDto) {
        return AjaxResult.success(messageChatService.getChatRoomByQuery(messageChatDto));
    }

    @GetMapping("getUnreadTotal")
    public AjaxResult getUnreadTotal() {
        return AjaxResult.success(iMessageContentUserService.getUnReadMessageByUserIdNeChatRoomId(SecurityUtils.getUserId(), 0L));
    }





}
