package com.red.circle.other.app.inner.endpoint.room;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.live.ActiveVoiceRoomClientService;
import com.red.circle.other.infra.database.mongo.entity.live.ActiveVoiceRoom;
import com.red.circle.other.inner.model.dto.live.ActiveVoiceRoomCO;
import com.red.circle.other.inner.endpoint.live.ActiveVoiceRoomClient;
import com.red.circle.other.inner.model.cmd.live.AppActiveVoiceRoomQryCmd;
import com.red.circle.other.inner.model.dto.live.ActiveVoiceRoomDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统管理员.
 *
 * @author pengliang on 2023/8/11
 */
@Validated
@RestController
@RequestMapping(value = ActiveVoiceRoomClient.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ActiveVoiceRoomClientEndpoint implements ActiveVoiceRoomClient {

  private final ActiveVoiceRoomClientService activeVoiceRoomClientService;

  @Override
  public ResultResponse<Long> count(String sysOrigin) {
    return ResultResponse.success(activeVoiceRoomClientService.count(sysOrigin));
  }

  @Override
  public ResultResponse<List<ActiveVoiceRoomDTO>> listOps(AppActiveVoiceRoomQryCmd qryCmd) {
    return ResultResponse.success(activeVoiceRoomClientService.listOps(qryCmd));
  }

  @Override
  public ResultResponse<ActiveVoiceRoomCO> createNoBodyRoom(Long roomId) {
    ActiveVoiceRoomCO activeVoiceRoomCO = new ActiveVoiceRoomCO();
    ActiveVoiceRoom nobodyRoom = activeVoiceRoomClientService.createNobodyRoom(roomId);
    BeanUtils.copyProperties(nobodyRoom, activeVoiceRoomCO);
    return ResultResponse.success(activeVoiceRoomCO);
  }

}
