package com.ruoyi.cai.controller.app;

import com.ruoyi.cai.dto.app.dto.ImMessageDTO;
import com.ruoyi.cai.dto.app.vo.ImResp;
import com.ruoyi.cai.manager.ImService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.helper.LoginHelper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@RestController
@RequestMapping("/api/im")
@Tag(name = "IM相关的接口")
public class ImController {

    @Autowired
    private ImService imService;

    @PostMapping("/send/message")
    @Operation(summary = "发送消息")
    public R<ImResp> sendMessage(@Validated @RequestBody ImMessageDTO imMessageDTO){
        ImResp resp = imService.sendMessage(LoginHelper.getUserId(), imMessageDTO);
        return R.ok(resp);
    }
}
