package com.example.controller;

import com.example.bean.Message;
import com.example.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.List;

@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;

    @GetMapping("/getMessage")
    public List<Message> getMessage(@RequestParam(name="userid1") String userid1, @RequestParam(name="userid2") String userid2)
    {
        return this.messageService.getMessage(userid1,userid2);
    }

    @GetMapping("/sendMessage")
    public void sendMessage(@RequestParam(name="senderid") String senderid,@RequestParam(name="message")String message,@RequestParam(name="receiverid")String receiverid)
    {
        messageService.sendMessage(senderid,message,receiverid);
    }
}
