package com.ytpm.middle.controller;

import com.ytpm.general.Result;
import com.ytpm.general.ResultTable;
import com.ytpm.middle.param.MessageParam;
import com.ytpm.middle.service.MessageService;
import com.ytpm.middle.view.MessageVO;
import com.ytpm.middle.view.MiddleUserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
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;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

/**
 * @author Marx
 * @date 2025/8/5 11:55
 */
@Api(tags = "消息管理模块")
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private MessageService messageService;

    @ApiOperation("消息发送")
    @PostMapping("/sendMessage")
    public Result<String> sendMessage(@RequestBody MessageParam param, @ApiIgnore@AuthenticationPrincipal MiddleUserInfo userInfo) {
        param.setDefaultParam(userInfo.getUserId());
        return messageService.sendMessage(param);
    }

    @ApiOperation("查询消息列表")
    @PostMapping("/queryList")
    public ResultTable<MessageVO> queryList(@RequestBody MessageParam param) {
        return messageService.queryList(param);
    }

}
