package com.red.circle.other.inner.endpoint.user.user.api;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.OnlineCountQryCmd;
import com.red.circle.other.inner.model.cmd.user.OnlineStatusUploadCmd;
import com.red.circle.other.inner.model.cmd.user.OnlineUserBackQryCmd;
import com.red.circle.other.inner.model.dto.user.OnlineUserDTO;
import com.red.circle.other.inner.model.dto.user.PageOnlineUserDTO;
import com.red.circle.other.inner.enums.user.UserOnlineStatusEnum;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 在线用户.
 *
 * @author pengliang on 2023/6/2
 */
public interface UserOnlineClientApi {

  String API_PREFIX = "/user-online/client";

  /**
   * 上传在线状态.
   */
  @PostMapping("/uploadOnline")
  ResultResponse<Void> upload(@RequestBody @Validated OnlineStatusUploadCmd cmd);

  /**
   * 获取用户权重.
   */
  @GetMapping("/getWeights")
  ResultResponse<Integer> getWeights(@RequestParam("userId") Long userId);

  /**
   * 统计回话数量.
   */
  @GetMapping("/count-sessionId")
  ResultResponse<Long> countSessionId(@RequestParam("sessionId") Long sessionId);

  /**
   * 获取会话id.
   */
  @GetMapping("/getSessionId")
  ResultResponse<String> getSessionId(@RequestParam("userId") Long userId);

  /**
   * 移除在线用户.
   */
  @GetMapping("/removeByUserId")
  ResultResponse<Void> removeByUserId(@RequestParam("userId") Long userId);

  /**
   * 获取会话在线用户.
   */
  @GetMapping("/flowSessionOnlineUser")
  ResultResponse<List<OnlineUserDTO>> flowSessionOnlineUser(
      @RequestParam("sessionId") String sessionId,
      @RequestParam("status") UserOnlineStatusEnum status,
      @RequestParam(value = "lastTimingId", required = false) Long lastTimingId
  );


  @PostMapping("/onlineTotal")
  ResultResponse<Long> onlineTotal(@RequestBody OnlineCountQryCmd onlineCountQuery);

  @PostMapping("/listBackOnline")
  ResultResponse<List<PageOnlineUserDTO>> listBackOnline(@RequestBody OnlineUserBackQryCmd query);

  /**
   * 获取音频房间top20.
   *
   * @param roomId       房间id
   * @param lastTimingId 时序id
   * @return 观众信息
   */
  @GetMapping("/flowLanguageHallTop200")
  ResultResponse<List<OnlineUserDTO>> flowLanguageHallTop200(
      @RequestParam("roomId") Long roomId,
      @RequestParam(value = "lastTimingId", required = false) Long lastTimingId
  );

  /**
   * 刷新在线用户在线状态
   * @param userId
   * @param onlineStatus
   * @param sessionId
   * @return
   */
  @GetMapping("/updateStatusAndSessionId")
  ResultResponse<Void> updateStatusAndSessionId(@RequestParam("userId")Long userId,
      @RequestParam("onlineStatus") UserOnlineStatusEnum onlineStatus,
      @RequestParam("sessionId") Long sessionId);

}
