package com.ruoyi.xq.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.xq.dto.app.im.ImMessageDTO;
import com.ruoyi.xq.dto.app.im.ImResp;
import com.ruoyi.xq.manager.ImManager;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
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相关的接口")
@Slf4j
public class ImAppController {

    @Autowired
    private ImManager imManager;

    @PostMapping("/send/message")
    @Operation(summary = "发送消息")
    @Log(title = "发送消息", businessType = BusinessType.OTHER, isSaveDb = true)
    public R<ImResp> sendMessage(@Validated @RequestBody ImMessageDTO imMessageDTO){
        imMessageDTO.setFromUserId(LoginHelper.getUserId());
        ImResp resp = imManager.sendMessage(imMessageDTO);
        return R.ok(resp);
    }

    /*@PostMapping("/send/saveSendImImg")
    @Operation(summary = "更新发送的图片消息")
    @Log(title = "更新发送的图片消息", businessType = BusinessType.OTHER, isSaveDb = false)
    public R<Void> saveSendImImg(@Validated @RequestBody SaveSendImImgReq saveSendImImgReq){
        imService.saveSendImImg(saveSendImImgReq);
        return R.ok();
    }*/




}
