package com.keao.edu.im.api.client;

import java.util.List;

import com.keao.edu.im.api.entity.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.keao.edu.common.config.FeignConfiguration;
import com.keao.edu.im.api.client.callback.ImFeignServiceFallback;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "im-server", configuration = FeignConfiguration.class, fallback = ImFeignServiceFallback.class)
public interface ImFeignService {

	/**
	 * 用户注册
	 * @param userModel
	 * @return
	 */
	@PostMapping(value = "user/register", consumes = MediaType.APPLICATION_JSON_VALUE)
	ImResult register(@RequestBody ImUserModel userModel);

	/**
	 * 用户信息修改
	 * @param userModel
	 * @return
	 */
	@PostMapping(value = "user/update", consumes = MediaType.APPLICATION_JSON_VALUE)
	void update(@RequestBody ImUserModel userModel);

	/**
	 * 创建群组
	 * @param groupModel
	 * @return
	 */
	@PostMapping(value = "group/create")
	Object groupCreate(@RequestBody ImGroupModel groupModel);

	/**
	 * 批量创建群组
	 * @param groupModels
	 * @return
	 */
	@PostMapping(value = "group/batchCreate")
	void groupBatchCreate(@RequestBody List<ImGroupModel> groupModels);

	/**
	 * 加入群组
	 * @param groupModel
	 * @return
	 */
	@PostMapping(value = "group/join")
	Object groupJoin(@RequestBody ImGroupModel groupModel);

	/**
	 * 退出群组
	 * @param groupModel
	 * @return
	 */
	@PostMapping(value = "group/quit")
	Object groupQuit(@RequestBody ImGroupModel groupModel);

	/**
	 * 解散群组
	 * @param groupModel
	 * @return
	 */
	@PostMapping(value = "group/dismiss")
	Object groupDismiss(@RequestBody ImGroupModel groupModel);

	/**
	 * 批量解散群组
	 * @param groupModels
	 * @return
	 */
	@PostMapping(value = "group/batchDismiss")
	Object groupBatchDismiss(@RequestBody List<ImGroupModel> groupModels);

	/**
	 * 批量退出群组
	 * @param groupModels
	 * @return
	 */
	@PostMapping(value = "group/batchQuit")
	Object groupBatchQuit(@RequestBody List<ImGroupModel> groupModels);

	/**
	 * 发送私聊消息
	 * @param privateMessage
	 * @return
	 */
	@PostMapping(value = "private/send")
	Object privateSend(@RequestBody ImPrivateMessage privateMessage);

	/**
	 * 踢出教室
	 * @param reqUserData
	 * @return
	 */
	@PostMapping(value = "room/kick")
	void kickRoom(@RequestBody ReqUserData reqUserData);

	/**
	 * 加群
	 * @param userIds
	 * @param groupId
	 * @param groupName
	 */
	@PostMapping(value = "room/joinGroup")
	void joinGroup(@RequestParam("userIds") String userIds,@RequestParam("groupId") String groupId,@RequestParam("groupName") String groupName);

	/**
	 * 退群
	 * @param userIds
	 * @param groupId
	 */
	@PostMapping(value = "room/quitGroup")
	void quitGroup(@RequestParam("userIds") String userIds,@RequestParam("groupId") String groupId);

	/**
	 * 解散群
	 * @param userId
	 * @param groupId
	 */
	@PostMapping(value = "room/dismissGroup")
	void dismissGroup(@RequestParam("userId") String userId,@RequestParam("groupId") String groupId);

	/**
	 * 发送消息
	 * @param publishMessageDto
	 * @return
	 */
	@PostMapping(value = "room/publishMessage")
	void publishMessage(@RequestBody PublishMessageDto publishMessageDto);

	/**
	 * 销毁房间
	 * @param roomId
	 * @return
	 */
	@PostMapping(value = "room/destroyRoom")
	@Async
	void destroyRoom(@RequestParam("roomId") Long roomId,@RequestParam("userId") String userId);
}
