package com.ym.controller;

import com.ym.service.ChatroomService;
import com.ym.service.MessageService;
import io.rong.models.chatroom.ChatroomMember;
import io.rong.models.chatroom.ChatroomModel;
import io.rong.models.message.ChatroomMessage;
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("/chatroom")
public class ChatroomController{

    @Autowired
    MessageService messageService;
    @Autowired
    ChatroomService chatroomCreate;

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

    @RequestMapping(value = "/broadcast", method = RequestMethod.POST)
    public Object broadcast(@RequestBody ChatroomMessage chatroomMessage) throws Exception {
        return messageService.chatroomBroadcast(chatroomMessage);
    }

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Object create(@RequestBody ChatroomModel[] chatroomModels) throws Exception {
        return chatroomCreate.chatroomCreate(chatroomModels);
    }

    @RequestMapping(value = "/destory", method = RequestMethod.POST)
    public Object destory(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomDestory(chatroomModel);
    }

    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public Object get(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomGet(chatroomModel);
    }

    @RequestMapping(value = "/isExist", method = RequestMethod.POST)
    public Object isExist(@RequestBody ChatroomMember chatroomMember) throws Exception {
        return chatroomCreate.chatroomIsExit(chatroomMember);
    }

    @RequestMapping(value = "/block/add", method = RequestMethod.POST)
    public Object blockAdd(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomBlockAdd(chatroomModel);
    }

    @RequestMapping(value = "/block/remove", method = RequestMethod.POST)
    public Object blockRemove(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomBlockRemove(chatroomModel);
    }

    @RequestMapping(value = "/block/getList", method = RequestMethod.POST)
    public Object blockGetList(@RequestBody String chatroomId) throws Exception {
        return chatroomCreate.chatroomBlockGetList(chatroomId);
    }

    @RequestMapping(value = "/muteMembers/add", method = RequestMethod.POST)
    public Object muteMembersAdd(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomMuteMembersAdd(chatroomModel);
    }

    @RequestMapping(value = "/muteMembers/remove", method = RequestMethod.POST)
    public Object muteMembersRemove(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomMuteMembersRemove(chatroomModel);
    }

    @RequestMapping(value = "/muteMembers/getList", method = RequestMethod.POST)
    public Object muteMembersGetList(@RequestBody ChatroomModel chatroomModel) throws Exception {
        return chatroomCreate.chatroomMuteMembersGetList(chatroomModel);
    }
}
