package com.red.circle.console.adapter.app.sys;

import com.red.circle.console.app.service.app.sys.RoomTopFixedBackService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.sys.RoomTopFixedCmd;
import com.red.circle.other.inner.model.cmd.sys.RoomTopFixedQryCmd;
import com.red.circle.other.inner.model.dto.sys.SysTopRoomDTO;
import lombok.RequiredArgsConstructor;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author pengliang on 2022/4/6
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/sys-set-top", produces = MediaType.APPLICATION_JSON_VALUE)
public class SysSetTopRoomRestController extends BaseController {

  private final RoomTopFixedBackService roomTopFixedBackService;

  /**
   * 分页列表.
   */
  @GetMapping("/page")
  public PageResult<SysTopRoomDTO> addOrUpdate(RoomTopFixedQryCmd query) {
    return roomTopFixedBackService.pageRoom(query);
  }

  @OpsOperationReqLog("添加或修改房间置顶")
  @PostMapping("/add-or-update")
  public void addOrUpdate(@RequestBody @Validated RoomTopFixedCmd param) {
    roomTopFixedBackService.addOrUpdate(param);
  }

  /**
   * 移除房间.
   */
  @GetMapping("/remove")
  public void remove(@RequestParam Long roomId) {
    roomTopFixedBackService.remove(roomId);
  }

}
