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

import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.room.RoomBlackProcessCO;
import com.red.circle.other.app.dto.clientobject.room.RoomUserBlacklistCO;
import com.red.circle.other.app.dto.cmd.room.RoomBlackCmd;
import com.red.circle.other.app.dto.cmd.room.RoomBlackFlowQryCmd;
import com.red.circle.other.app.dto.cmd.room.RoomBlackRemoveCmd;
import com.red.circle.other.app.service.room.BlacklistRoomService;
import java.util.List;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 房间黑名单.
 *
 * @author pengliang on 2023/9/21
 * @eo.api-type http
 * @eo.groupName 直播服务.房间黑名单
 * @eo.path /room/blacklist
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/room/blacklist", produces = MediaType.APPLICATION_JSON_VALUE)
public class BlacklistRoomRestController extends BaseController {

  private final BlacklistRoomService blacklistRoomService;

  /**
   * 分页获取黑名单.
   *
   * @eo.name 分页获取黑名单.
   * @eo.url
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping
  public List<RoomUserBlacklistCO> flowList(@Validated RoomBlackFlowQryCmd cmd) {
    return blacklistRoomService.flowList(cmd);
  }

  /**
   * 加入黑名单.
   *
   * @eo.name 加入黑名单.
   * @eo.url /join
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/join")
  public RoomBlackProcessCO join(@RequestBody @Validated RoomBlackCmd cmd) {
    return blacklistRoomService.join(cmd);
  }


  /**
   * 移除黑名单.
   *
   * @eo.name 移除黑名单.
   * @eo.url /remove
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/remove")
  public void remove(@RequestBody @Validated RoomBlackRemoveCmd cmd) {
    blacklistRoomService.remove(cmd);
  }

}
