package com.red.circle.other.adapter.app.room;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.cmd.room.UpdateRoomBackgroundCmd;
import com.red.circle.other.app.dto.cmd.room.UpdateRoomCmdData;
import com.red.circle.other.app.service.room.RoomProfileService;
import com.red.circle.other.inner.model.dto.live.RoomProfileDTO;
import com.red.circle.other.inner.model.dto.live.RoomProfileManagerDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 房间资料信息.
 *
 * @author houyong on 2020/12/1
 * @eo.api-type http
 * @eo.groupName 直播服务.房间资料
 * @eo.path /room/profile
 */
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping(value = "/room/profile", produces = MediaType.APPLICATION_JSON_VALUE)
public class RoomProfileRestController extends BaseController {

  private final RoomProfileService roomProfileService;

  /**
   * 我的房间资料.
   *
   * @eo.name 我的房间资料.
   * @eo.url
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping
  public RoomProfileManagerDTO getRoomProfile(AppExtCommand cmd) {
    return roomProfileService.getRoomProfile(cmd);
  }

  /**
   * 指定房间资料.
   *
   * @eo.name 指定房间资料.
   * @eo.url /specific
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/specific")
  public RoomProfileManagerDTO getRoomProfile(AppRoomIdCmd cmd) {
    return roomProfileService.getRoomProfile(cmd);
  }

  /**
   * 指定用户房间信息.
   *
   * @eo.name 指定用户房间信息.
   * @eo.url /user
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/user")
  public RoomProfileManagerDTO getRoomProfile(AppUserIdCmd cmd) {
    return roomProfileService.getRoomProfile(cmd);
  }

  /**
   * 修改房间资料.
   *
   * @eo.name 修改房间资料.
   * @eo.url
   * @eo.method put
   * @eo.request-type json
   */
  @PutMapping
  public RoomProfileDTO updateProfileV2(@RequestBody @Validated UpdateRoomCmdData cmd) {
    return roomProfileService.updateProfile(cmd);
  }

  /**
   * 修改房间背景图.
   *
   * @eo.name 修改房间背景图.
   * @eo.url /background
   * @eo.method put
   * @eo.request-type json
   */
  @PutMapping("/background")
  public RoomProfileManagerDTO updateBackground(@RequestBody @Validated UpdateRoomBackgroundCmd cmd) {
    return roomProfileService.updateBackground(cmd);
  }

}
