package com.red.circle.other.app.command.room.query;

import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.app.convertor.live.RoomProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.family.RoomSettingCO;
import com.red.circle.other.infra.database.mongo.entity.live.RoomSetting;
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
import com.red.circle.other.inner.asserts.RoomErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * 获取设置信息
 *
 * @author houyong on 2020/12/3
 */
@Component
@RequiredArgsConstructor
public class RoomSettingQryExe {

  private final RoomProfileAppConvertor roomProfileAppConvertor;
  private final RoomProfileManagerService roomProfileManagerService;

  public RoomSettingCO execute(AppRoomIdCmd cmd) {
    // 房间不存在
    RoomSetting roomSettingV2 = roomProfileManagerService.getRoomSettingById(cmd.getRoomId());
    ResponseAssert.notNull(RoomErrorCode.ROOM_NOT_EXISTS, roomSettingV2);
    return roomProfileAppConvertor.toRoomSettingCO(roomSettingV2);
  }
}
