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

import com.red.circle.framework.core.dto.ReqSysOrigin;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.dto.cmd.room.UpdateRoomSettingCmd;
import com.red.circle.other.app.service.room.RoomSettingService;
import com.red.circle.other.inner.endpoint.tmp.api.RoomSettingClientRestApi;
import com.red.circle.other.inner.tmp.UpdateRoomSettingRestApiCmd;
import lombok.RequiredArgsConstructor;
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 2024/1/5
 */
@Validated
@RestController
@RequestMapping(value = RoomSettingClientRestApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class RoomSettingClientRestEndpoint implements RoomSettingClientRestApi {

  private final RoomSettingService roomSettingService;

  @Override
  public ResultResponse<Void> updateSetting(UpdateRoomSettingRestApiCmd cmd) {
    UpdateRoomSettingCmd newCmd = new UpdateRoomSettingCmd();
    newCmd.setReqSysOrigin(ReqSysOrigin.of(cmd.getSysOrigin()));
    newCmd.setReqUserId(cmd.getReqUserId());
    newCmd.setRoomId(cmd.getRoomId());
    newCmd.setPassword(cmd.getPassword());
    newCmd.setTouristMike(cmd.getTouristMike());
    newCmd.setTakeMicRole(cmd.getTakeMicRole());
    newCmd.setTouristMsg(cmd.getTouristMsg());
    newCmd.setJoinGolds(cmd.getJoinGolds());
    newCmd.setMikeSize(cmd.getMikeSize());
    newCmd.setAllowMusic(cmd.getAllowMusic());
    newCmd.setAdminLockSeat(cmd.getAdminLockSeat());
    newCmd.setShowHeartbeat(cmd.getShowHeartbeat());
    newCmd.setRoomSpecialMikeType(cmd.getRoomSpecialMikeType());
    newCmd.setOpenKtvMode(cmd.getOpenKtvMode());
    roomSettingService.updateSetting(newCmd);
    return ResultResponse.success();
  }
}
