package com.ym.controller;

import com.ym.service.GroupService;
import com.ym.service.MessageService;
import io.rong.models.group.GroupModel;
import io.rong.models.group.UserGroup;
import io.rong.models.message.GroupMessage;
import io.rong.models.message.MentionMessage;
import io.rong.models.message.RecallMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by weiqinxiao on 2019/2/25.
 */
@RestController
@RequestMapping("/group")
public class GroupController{

    @Autowired
    MessageService messageService;
    @Autowired
    GroupService groupService;

    @RequestMapping(value = "/send", method = RequestMethod.POST)
    public Object send(@RequestBody GroupMessage groupMessage) throws Exception {
        return messageService.groupSend(groupMessage);
    }

    @RequestMapping(value = "/sendDirection", method = RequestMethod.POST)
    public Object sendDirection(@RequestBody GroupMessage groupMessage) throws Exception {
        return messageService.groupSendDirection(groupMessage);
    }

    @RequestMapping(value = "/sendMention", method = RequestMethod.POST)
    public Object sendMention(@RequestBody MentionMessage mentionMessage) throws Exception {
        return messageService.groupSendMention(mentionMessage);
    }

    @RequestMapping(value = "/recall", method = RequestMethod.POST)
    public Object recall(@RequestBody RecallMessage recallMessage) throws Exception {
        return messageService.groupRecall(recallMessage);
    }

    @RequestMapping(value = "/sync", method = RequestMethod.POST)
    public Object sync(@RequestBody UserGroup userGroup) throws Exception {
        return groupService.groupSync(userGroup);
    }

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Object create(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupCreate(groupModel);
    }

    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public Object get(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupGet(groupModel);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Object update(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupUpdate(groupModel);
    }

    @RequestMapping(value = "/join", method = RequestMethod.POST)
    public Object join(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupJoin(groupModel);
    }

    @RequestMapping(value = "/quit", method = RequestMethod.POST)
    public Object quit(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupQuit(groupModel);
    }

    @RequestMapping(value = "/dismiss", method = RequestMethod.POST)
    public Object dismiss(@RequestBody GroupModel groupModel) throws Exception {
        return groupService.groupDismiss(groupModel);
    }
}
